From 3d01f2313b289fcc5a607237b3999a61a0b0506c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 22 Oct 2019 09:54:55 +0200 Subject: [PATCH] Use plain memset() in HMAC-DRBG seeding The line above the memset() relies on the fact that V is all-zero at that point (see the comment above), so it doesn't contain a sensitive value. --- library/hmac_drbg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/hmac_drbg.c b/library/hmac_drbg.c index 03c7d67f7..b51e9b18d 100644 --- a/library/hmac_drbg.c +++ b/library/hmac_drbg.c @@ -141,7 +141,7 @@ int mbedtls_hmac_drbg_seed_buf( mbedtls_hmac_drbg_context *ctx, if( ( ret = mbedtls_md_hmac_starts( &ctx->md_ctx, ctx->V, mbedtls_md_get_size( md_info ) ) ) != 0 ) return( ret ); - mbedtls_platform_memset( ctx->V, 0x01, mbedtls_md_get_size( md_info ) ); + memset( ctx->V, 0x01, mbedtls_md_get_size( md_info ) ); if( ( ret = mbedtls_hmac_drbg_update_ret( ctx, data, data_len ) ) != 0 ) return( ret ); @@ -268,7 +268,7 @@ int mbedtls_hmac_drbg_seed( mbedtls_hmac_drbg_context *ctx, */ if( ( ret = mbedtls_md_hmac_starts( &ctx->md_ctx, ctx->V, md_size ) ) != 0 ) return( ret ); - mbedtls_platform_memset( ctx->V, 0x01, md_size ); + memset( ctx->V, 0x01, md_size ); ctx->f_entropy = f_entropy; ctx->p_entropy = p_entropy;