From 088ef49681737fb4968c464a8e7a494a5cceed64 Mon Sep 17 00:00:00 2001 From: "Christoph M. Wintersteiger" Date: Fri, 15 Feb 2019 16:25:48 +0000 Subject: [PATCH] 3rdparty: Make proper use of mbedtls_platform_zeroize in Everest x25519 --- 3rdparty/everest/library/x25519.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/3rdparty/everest/library/x25519.c b/3rdparty/everest/library/x25519.c index 52496c6e1..7660b6433 100644 --- a/3rdparty/everest/library/x25519.c +++ b/3rdparty/everest/library/x25519.c @@ -41,7 +41,7 @@ */ void mbedtls_x25519_init( mbedtls_x25519_context *ctx ) { - memset( ctx, 0, sizeof( mbedtls_x25519_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_x25519_context ) ); } /* @@ -138,7 +138,8 @@ int mbedtls_x25519_calc_secret( mbedtls_x25519_context *ctx, size_t *olen, Hacl_Curve25519_crypto_scalarmult( buf, ctx->our_secret, ctx->peer_point); /* Wipe the DH secret and don't let the peer chose a small subgroup point */ - memset( ctx->our_secret, 0, MBEDTLS_X25519_KEY_SIZE_BYTES ); + mbedtls_platform_zeroize( ctx->our_secret, MBEDTLS_X25519_KEY_SIZE_BYTES ); + if( memcmp( buf, ctx->our_secret, MBEDTLS_X25519_KEY_SIZE_BYTES) == 0 ) return MBEDTLS_ERR_ECP_RANDOM_FAILED;