From 7124fb63be173bec1f73af56e5a14328f51780d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 22 May 2018 16:05:33 +0200 Subject: [PATCH] Use zeroize function from new platform_util --- library/aria.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/library/aria.c b/library/aria.c index 25beafc09..e9bcd6d13 100644 --- a/library/aria.c +++ b/library/aria.c @@ -48,16 +48,13 @@ #if !defined(MBEDTLS_ARIA_ALT) +#include "mbedtls/platform_util.h" + #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ !defined(inline) && !defined(__cplusplus) #define inline __inline #endif -/* 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) */ @@ -494,7 +491,7 @@ int mbedtls_aria_setkey_enc( mbedtls_aria_context *ctx, aria_rot128( ctx->rk[16], w[0], w[1], 19 ); /* w holds enough info to reconstruct the round keys */ - mbedtls_zeroize( w, sizeof( w ) ); + mbedtls_platform_zeroize( w, sizeof( w ) ); return( 0 ); } @@ -598,7 +595,7 @@ void mbedtls_aria_free( mbedtls_aria_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_aria_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_aria_context ) ); } #if defined(MBEDTLS_CIPHER_MODE_CBC)