From 56453937a15d8de5e64a61158feb67cee87ee0b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 21 Feb 2018 10:08:31 +0100 Subject: [PATCH] aria: use mbedtls_zeroize() --- library/aria.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/library/aria.c b/library/aria.c index 9b5febc26..5a5222f6a 100644 --- a/library/aria.c +++ b/library/aria.c @@ -48,6 +48,11 @@ #if !defined(MBEDTLS_ARIA_ALT) +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize( void *v, size_t n ) { + volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; +} + // 32-bit integer manipulation macros (little endian) #ifndef GET_UINT32_LE @@ -489,8 +494,7 @@ void mbedtls_aria_free( mbedtls_aria_context *ctx ) if( ctx == NULL ) return; - // compiler can't remove this since this is not a static function - memset( ctx, 0, sizeof( mbedtls_aria_context ) ); + mbedtls_zeroize( ctx, sizeof( mbedtls_aria_context ) ); } #if defined(MBEDTLS_CIPHER_MODE_CBC)