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/chachapoly.c b/library/chachapoly.c
index dc643dd..419fe80 100644
--- a/library/chachapoly.c
+++ b/library/chachapoly.c
@@ -68,7 +68,7 @@
if( partial_block_len == 0U )
return( 0 );
- memset( zeroes, 0, sizeof( zeroes ) );
+ mbedtls_platform_memset( zeroes, 0, sizeof( zeroes ) );
return( mbedtls_poly1305_update( &ctx->poly1305_ctx,
zeroes,
@@ -88,7 +88,7 @@
if( partial_block_len == 0U )
return( 0 );
- memset( zeroes, 0, sizeof( zeroes ) );
+ mbedtls_platform_memset( zeroes, 0, sizeof( zeroes ) );
return( mbedtls_poly1305_update( &ctx->poly1305_ctx,
zeroes,
16U - partial_block_len ) );
@@ -150,7 +150,7 @@
* Only the first 256-bits (32 bytes) of the key is used for Poly1305.
* The other 256 bits are discarded.
*/
- memset( poly1305_key, 0, sizeof( poly1305_key ) );
+ mbedtls_platform_memset( poly1305_key, 0, sizeof( poly1305_key ) );
ret = mbedtls_chacha20_update( &ctx->chacha20_ctx, sizeof( poly1305_key ),
poly1305_key, poly1305_key );
if( ret != 0 )