diff --git a/deps/mbedtls/aes.c b/deps/mbedtls/aes.c index 58603849cc..d36b231fb4 100644 --- a/deps/mbedtls/aes.c +++ b/deps/mbedtls/aes.c @@ -54,10 +54,7 @@ #if !defined(MBEDTLS_AES_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; -} +#include "arc4_alt.h" /* * 32-bit integer manipulation macros (little endian) diff --git a/deps/mbedtls/arc4.c b/deps/mbedtls/arc4.c index 05b33d3fdb..26954c6f35 100644 --- a/deps/mbedtls/arc4.c +++ b/deps/mbedtls/arc4.c @@ -47,10 +47,7 @@ #if !defined(MBEDTLS_ARC4_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; -} +#include "arc4_alt.h" void mbedtls_arc4_init( mbedtls_arc4_context *ctx ) { diff --git a/deps/mbedtls/arc4_alt.h b/deps/mbedtls/arc4_alt.h new file mode 100644 index 0000000000..9c6a49b206 --- /dev/null +++ b/deps/mbedtls/arc4_alt.h @@ -0,0 +1,9 @@ +#ifndef _ARC4_ALT_H +#define _ARC4_ALT_H + +/* 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; +} + +#endif