ECDH: Fix context initialization

This commit is contained in:
Christoph M. Wintersteiger 2019-02-18 15:45:23 +00:00 committed by Janos Follath
parent e7e74ba33b
commit 30bc9cebda

View file

@ -186,6 +186,7 @@ static void ecdh_init_internal( mbedtls_ecdh_context_mbed *ctx )
void mbedtls_ecdh_init( mbedtls_ecdh_context *ctx ) void mbedtls_ecdh_init( mbedtls_ecdh_context *ctx )
{ {
ECDH_VALIDATE( ctx != NULL ); ECDH_VALIDATE( ctx != NULL );
memset( ctx, 0, sizeof( mbedtls_ecdh_context ) );
#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) #if defined(MBEDTLS_ECDH_LEGACY_CONTEXT)
ecdh_init_internal( ctx ); ecdh_init_internal( ctx );
@ -193,8 +194,6 @@ void mbedtls_ecdh_init( mbedtls_ecdh_context *ctx )
mbedtls_ecp_point_init( &ctx->Vf ); mbedtls_ecp_point_init( &ctx->Vf );
mbedtls_mpi_init( &ctx->_d ); mbedtls_mpi_init( &ctx->_d );
#else #else
memset( ctx, 0, sizeof( mbedtls_ecdh_context ) );
ctx->var = MBEDTLS_ECDH_VARIANT_NONE; ctx->var = MBEDTLS_ECDH_VARIANT_NONE;
#endif #endif
ctx->point_format = MBEDTLS_ECP_PF_UNCOMPRESSED; ctx->point_format = MBEDTLS_ECP_PF_UNCOMPRESSED;