mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-16 08:42:50 +00:00
ECDH: Fix memory leaks due to context re-initialization
This commit is contained in:
parent
2be66d44a5
commit
2f563e3482
@ -162,6 +162,12 @@ int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z,
|
|||||||
|
|
||||||
static void ecdh_init_internal( mbedtls_ecdh_context_mbed *ctx )
|
static void ecdh_init_internal( mbedtls_ecdh_context_mbed *ctx )
|
||||||
{
|
{
|
||||||
|
mbedtls_ecp_group_free( &ctx->grp );
|
||||||
|
mbedtls_mpi_free( &ctx->d );
|
||||||
|
mbedtls_ecp_point_free( &ctx->Q );
|
||||||
|
mbedtls_ecp_point_free( &ctx->Qp );
|
||||||
|
mbedtls_mpi_free( &ctx->z );
|
||||||
|
|
||||||
mbedtls_ecp_group_init( &ctx->grp );
|
mbedtls_ecp_group_init( &ctx->grp );
|
||||||
mbedtls_mpi_init( &ctx->d );
|
mbedtls_mpi_init( &ctx->d );
|
||||||
mbedtls_ecp_point_init( &ctx->Q );
|
mbedtls_ecp_point_init( &ctx->Q );
|
||||||
@ -169,6 +175,7 @@ static void ecdh_init_internal( mbedtls_ecdh_context_mbed *ctx )
|
|||||||
mbedtls_mpi_init( &ctx->z );
|
mbedtls_mpi_init( &ctx->z );
|
||||||
|
|
||||||
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
#if defined(MBEDTLS_ECP_RESTARTABLE)
|
||||||
|
mbedtls_ecp_restart_free( &ctx->rs );
|
||||||
mbedtls_ecp_restart_init( &ctx->rs );
|
mbedtls_ecp_restart_init( &ctx->rs );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user