Replace memset() with mbedtls_platform_memset()
Steps:
1. sed -i 's/\bmemset(\([^)]\)/mbedtls_platform_memset(\1/g' library/*.c tinycrypt/*.c include/mbedtls/*.h scripts/data_files/*.fmt
2. Manually edit library/platform_util.c to revert to memset() in the
implementations of mbedtls_platform_memset() and mbedtls_platform_memcpy()
3. egrep -n '\<memset\>' library/*.c include/mbedtls/*.h tinycrypt/*.c
The remaining occurrences are in three categories:
a. From point 2 above.
b. In comments.
c. In the initialisation of memset_func, to be changed in a future commit.
diff --git a/library/camellia.c b/library/camellia.c
index 22262b8..9021a9a 100644
--- a/library/camellia.c
+++ b/library/camellia.c
@@ -328,7 +328,7 @@
void mbedtls_camellia_init( mbedtls_camellia_context *ctx )
{
CAMELLIA_VALIDATE( ctx != NULL );
- memset( ctx, 0, sizeof( mbedtls_camellia_context ) );
+ mbedtls_platform_memset( ctx, 0, sizeof( mbedtls_camellia_context ) );
}
void mbedtls_camellia_free( mbedtls_camellia_context *ctx )
@@ -359,8 +359,8 @@
RK = ctx->rk;
- memset( t, 0, 64 );
- memset( RK, 0, sizeof(ctx->rk) );
+ mbedtls_platform_memset( t, 0, 64 );
+ mbedtls_platform_memset( RK, 0, sizeof(ctx->rk) );
switch( keybits )
{
@@ -390,7 +390,7 @@
* Key storage in KC
* Order: KL, KR, KA, KB
*/
- memset( KC, 0, sizeof(KC) );
+ mbedtls_platform_memset( KC, 0, sizeof(KC) );
/* Store KL, KR */
for( i = 0; i < 8; i++ )
@@ -951,7 +951,7 @@
mbedtls_camellia_context ctx;
- memset( key, 0, 32 );
+ mbedtls_platform_memset( key, 0, 32 );
for( j = 0; j < 6; j++ ) {
u = j >> 1;