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/x509write_crt.c b/library/x509write_crt.c
index 4804d7a..40db15a 100644
--- a/library/x509write_crt.c
+++ b/library/x509write_crt.c
@@ -58,7 +58,7 @@
void mbedtls_x509write_crt_init( mbedtls_x509write_cert *ctx )
{
- memset( ctx, 0, sizeof( mbedtls_x509write_cert ) );
+ mbedtls_platform_memset( ctx, 0, sizeof( mbedtls_x509write_cert ) );
mbedtls_mpi_init( &ctx->serial );
ctx->version = MBEDTLS_X509_CRT_VERSION_3;
@@ -150,7 +150,7 @@
unsigned char *c = buf + sizeof(buf);
size_t len = 0;
- memset( buf, 0, sizeof(buf) );
+ mbedtls_platform_memset( buf, 0, sizeof(buf) );
if( is_ca && max_pathlen > 127 )
return( MBEDTLS_ERR_X509_BAD_INPUT_DATA );
@@ -181,7 +181,7 @@
unsigned char *c = buf + sizeof(buf);
size_t len = 0;
- memset( buf, 0, sizeof(buf) );
+ mbedtls_platform_memset( buf, 0, sizeof(buf) );
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_pk_write_pubkey( &c, buf, ctx->subject_key ) );
ret = mbedtls_sha1_ret( buf + sizeof( buf ) - len, len,
@@ -206,7 +206,7 @@
unsigned char *c = buf + sizeof( buf );
size_t len = 0;
- memset( buf, 0, sizeof(buf) );
+ mbedtls_platform_memset( buf, 0, sizeof(buf) );
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_pk_write_pubkey( &c, buf, ctx->issuer_key ) );
ret = mbedtls_sha1_ret( buf + sizeof( buf ) - len, len,