Make utils module part of the platform
diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h
new file mode 100644
index 0000000..bda9710
--- /dev/null
+++ b/include/mbedtls/platform_util.h
@@ -0,0 +1,57 @@
+/**
+ * \file platform_util.h
+ *
+ * \brief Common and shared functions used by multiple modules in the Mbed TLS
+ * library.
+ */
+/*
+ * Copyright (C) 2018, Arm Limited, All Rights Reserved
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This file is part of Mbed TLS (https://tls.mbed.org)
+ */
+#ifndef MBEDTLS_PLATFORM_UTIL_H
+#define MBEDTLS_PLATFORM_UTIL_H
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Securely zeroize a buffer
+ *
+ * \param buf Buffer to be zeroized
+ * \param len Length of the buffer in bytes
+ *
+ * \note This implementation should never be optimized out by the
+ * compiler
+ *
+ * \note It is extremely difficult to guarantee that calls to
+ * mbedtls_platform_zeroize() are not removed by aggressive
+ * compiler optimizations in a portable way. For this reason, Mbed
+ * TLS provides the configuration option
+ * MBEDTLS_PLATFORM_ZEROIZE_ALT, which allows users to configure
+ * mbedtls_platform_zeroize() to use a suitable implementation for
+ * their platform and needs
+ */
+void mbedtls_platform_zeroize( void *buf, size_t len );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MBEDTLS_PLATFORM_UTIL_H */
diff --git a/include/mbedtls/utils.h b/include/mbedtls/utils.h
deleted file mode 100644
index 7eb2b68..0000000
--- a/include/mbedtls/utils.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * \file utils.h
- *
- * \brief Mbed TLS utility functions
- *
- * Copyright (C) 2018, Arm Limited, All Rights Reserved
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This file is part of Mbed TLS (https://tls.mbed.org)
- */
-#ifndef MBEDTLS_UTILS_H
-#define MBEDTLS_UTILS_H
-
-#include <stddef.h>
-
-/**
- * \brief Securely zeroize a buffer
- *
- * \param buf Buffer to be zeroized
- * \param len Length of the buffer in bytes
- *
- * \note This implementation should never be optimized out by the
- * compiler
- *
- * \note It is extremely difficult to guarantee that calls to
- * mbedtls_zeroize() are not removed by aggressive compiler
- * optimizations in a portable way. For this reason, Mbed TLS
- * provides the configuration option MBEDTLS_UTILS_ZEROIZE_ALT,
- * which allows users to configure mbedtls_zeroize() to use a
- * suitable implementation for their platform and needs
- */
-void mbedtls_zeroize( void *buf, size_t len );
-
-#endif /* MBEDTLS_UTILS_H */
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index 24a2484..648b151 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -57,7 +57,7 @@
version.c
version_features.c
xtea.c
- utils.c
+ platform_util.c
)
set(src_x509
diff --git a/library/Makefile b/library/Makefile
index 46dce4e..fd4544a 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -66,7 +66,7 @@
sha1.o sha256.o sha512.o \
threading.o timing.o version.o \
version_features.o xtea.o \
- utils.o
+ platform_util.o
OBJS_X509= certs.o pkcs11.o x509.o \
x509_create.o x509_crl.o x509_crt.o \
diff --git a/library/utils.c b/library/platform_util.c
similarity index 70%
rename from library/utils.c
rename to library/platform_util.c
index 34629eb..498e214 100644
--- a/library/utils.c
+++ b/library/platform_util.c
@@ -1,5 +1,6 @@
/*
- * Mbed TLS utility functions
+ * Common and shared functions used by multiple modules in the Mbed TLS
+ * library.
*
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
@@ -30,12 +31,12 @@
#include <stddef.h>
#include <string.h>
-#if !defined(MBEDTLS_UTILS_ZEROIZE_ALT)
+#if !defined(MBEDTLS_PLATFORM_ZEROIZE_ALT)
/*
* This implementation should never be optimized out by the compiler
*
- * This implementation for mbedtls_zeroize() was inspired from Colin Percival's
- * blog article at:
+ * This implementation for mbedtls_platform_zeroize() was inspired from Colin
+ * Percival's blog article at:
*
* http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html
*
@@ -50,17 +51,17 @@
* if( memset_func != memset )
* memset_func( buf, 0, len );
*
- * Note that it is extremely difficult to guarantee that mbedtls_zeroize()
- * will not be optimized out by aggressive compilers in a portable way. For
- * this reason, Mbed TLS also provides the configuration option
- * MBEDTLS_UTILS_ZEROIZE_ALT, which allows users to configure
- * mbedtls_zeroize() to use a suitable implementation for their platform and
- * needs.
+ * Note that it is extremely difficult to guarantee that
+ * mbedtls_platform_zeroize() will not be optimized out by aggressive compilers
+ * in a portable way. For this reason, Mbed TLS also provides the configuration
+ * option MBEDTLS_PLATFORM_ZEROIZE_ALT, which allows users to configure
+ * mbedtls_platform_zeroize() to use a suitable implementation for their
+ * platform and needs.
*/
static void * (* const volatile memset_func)( void *, int, size_t ) = memset;
-void mbedtls_zeroize( void *buf, size_t len )
+void mbedtls_platform_zeroize( void *buf, size_t len )
{
memset_func( buf, 0, len );
}
-#endif /* MBEDTLS_UTILS_ZEROIZE_ALT */
+#endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */