From 414e7170361eba2e6546911128af364fce23596a Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 3 Feb 2021 00:04:08 +0100 Subject: [PATCH] Deinitialize the PSA subsystem The PSA subsystem may consume global resources. It currently doesn't consume any heap when no keys are registered, but it may do so in the future. It does consume mutexes, which are reported as leaks when mutex usage checking is enabled. Signed-off-by: Gilles Peskine --- programs/ssl/ssl_client2.c | 4 ++++ programs/ssl/ssl_server2.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 25f8ff422..ef804c964 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -3038,6 +3038,10 @@ exit: mbedtls_free( context_buf ); #endif +#if defined(MBEDTLS_USE_PSA_CRYPTO) + mbedtls_psa_crypto_free( ); +#endif + if( test_hooks_failure_detected( ) ) { if( ret == 0 ) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 293c30b10..1c68e7634 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -4000,6 +4000,10 @@ exit: mbedtls_free( context_buf ); #endif +#if defined(MBEDTLS_USE_PSA_CRYPTO) + mbedtls_psa_crypto_free( ); +#endif + /* Let test hooks detect errors such as resource leaks. * Don't do it in query_config mode, because some test code prints * information to stdout and this gets mixed with the regular output. */