diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index f21958692..88f240e65 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -1647,9 +1647,6 @@ static int ssl_tls13_flush_buffers( mbedtls_ssl_context *ssl ) static int ssl_tls13_handshake_wrapup( mbedtls_ssl_context *ssl ) { - mbedtls_platform_zeroize( &ssl->handshake->tls13_hs_secrets, - sizeof(ssl->handshake->tls13_hs_secrets)); - MBEDTLS_SSL_DEBUG_MSG( 1, ( "Switch to application keys for inbound traffic" ) ); mbedtls_ssl_set_inbound_transform ( ssl, ssl->transform_application ); diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index 066147a5e..49256ec22 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -1060,10 +1060,14 @@ static int ssl_tls13_prepare_finished_message( mbedtls_ssl_context *ssl ) sizeof( ssl->handshake->state_local.finished_out.digest ), &ssl->handshake->state_local.finished_out.digest_len, ssl->conf->endpoint ); - + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) + { + mbedtls_platform_zeroize( &ssl->handshake->tls13_hs_secrets, + sizeof(ssl->handshake->tls13_hs_secrets)); + } if( ret != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "calculate_verify_data failed", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "calculate_verify_data failed", ret ); return( ret ); }