mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
ssl_client2/ssl_server2: Move is_psa_leaking() before mbedtls_psa_crypto_free() (and rng_free())
Signed-off-by: Przemyslaw Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
@ -3050,6 +3050,23 @@ exit:
|
|||||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED &&
|
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED &&
|
||||||
MBEDTLS_USE_PSA_CRYPTO */
|
MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
|
const char* message = mbedtls_test_helper_is_psa_leaking();
|
||||||
|
if( message )
|
||||||
|
{
|
||||||
|
if( ret == 0 )
|
||||||
|
ret = 1;
|
||||||
|
mbedtls_printf( "PSA memory leak detected: %s\n", message);
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
|
/* For builds with MBEDTLS_TEST_USE_PSA_CRYPTO_RNG psa crypto
|
||||||
|
* resources are freed by rng_free(). */
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO) && \
|
||||||
|
!defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
|
||||||
|
mbedtls_psa_crypto_free( );
|
||||||
|
#endif
|
||||||
|
|
||||||
mbedtls_ssl_session_free( &saved_session );
|
mbedtls_ssl_session_free( &saved_session );
|
||||||
mbedtls_ssl_free( &ssl );
|
mbedtls_ssl_free( &ssl );
|
||||||
mbedtls_ssl_config_free( &conf );
|
mbedtls_ssl_config_free( &conf );
|
||||||
@ -3063,18 +3080,6 @@ exit:
|
|||||||
mbedtls_free( context_buf );
|
mbedtls_free( context_buf );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
|
||||||
|
|
||||||
mbedtls_psa_crypto_free( );
|
|
||||||
const char* message = mbedtls_test_helper_is_psa_leaking();
|
|
||||||
if( message )
|
|
||||||
{
|
|
||||||
if( ret == 0 )
|
|
||||||
ret = 1;
|
|
||||||
mbedtls_printf( "PSA memory leak detected: %s\n", message);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_TEST_HOOKS)
|
#if defined(MBEDTLS_TEST_HOOKS)
|
||||||
if( test_hooks_failure_detected( ) )
|
if( test_hooks_failure_detected( ) )
|
||||||
{
|
{
|
||||||
|
@ -4008,10 +4008,6 @@ exit:
|
|||||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED &&
|
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED &&
|
||||||
MBEDTLS_USE_PSA_CRYPTO */
|
MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
mbedtls_ssl_free( &ssl );
|
|
||||||
mbedtls_ssl_config_free( &conf );
|
|
||||||
rng_free( &rng );
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_CACHE_C)
|
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||||
mbedtls_ssl_cache_free( &cache );
|
mbedtls_ssl_cache_free( &cache );
|
||||||
#endif
|
#endif
|
||||||
@ -4022,16 +4018,7 @@ exit:
|
|||||||
mbedtls_ssl_cookie_free( &cookie_ctx );
|
mbedtls_ssl_cookie_free( &cookie_ctx );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mbedtls_free( buf );
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
|
|
||||||
if( context_buf != NULL )
|
|
||||||
mbedtls_platform_zeroize( context_buf, context_buf_len );
|
|
||||||
mbedtls_free( context_buf );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
mbedtls_psa_crypto_free( );
|
|
||||||
const char* message = mbedtls_test_helper_is_psa_leaking();
|
const char* message = mbedtls_test_helper_is_psa_leaking();
|
||||||
if( message )
|
if( message )
|
||||||
{
|
{
|
||||||
@ -4041,6 +4028,25 @@ exit:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* For builds with MBEDTLS_TEST_USE_PSA_CRYPTO_RNG psa crypto
|
||||||
|
* resources are freed by rng_free(). */
|
||||||
|
#if defined(MBEDTLS_USE_PSA_CRYPTO) && \
|
||||||
|
!defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
|
||||||
|
mbedtls_psa_crypto_free( );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mbedtls_ssl_free( &ssl );
|
||||||
|
mbedtls_ssl_config_free( &conf );
|
||||||
|
rng_free( &rng );
|
||||||
|
|
||||||
|
mbedtls_free( buf );
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
|
||||||
|
if( context_buf != NULL )
|
||||||
|
mbedtls_platform_zeroize( context_buf, context_buf_len );
|
||||||
|
mbedtls_free( context_buf );
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_TEST_HOOKS)
|
#if defined(MBEDTLS_TEST_HOOKS)
|
||||||
/* Let test hooks detect errors such as resource leaks.
|
/* Let test hooks detect errors such as resource leaks.
|
||||||
* Don't do it in query_config mode, because some test code prints
|
* Don't do it in query_config mode, because some test code prints
|
||||||
|
Reference in New Issue
Block a user