mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
test: pake: check psa key validity before destroying it
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
This commit is contained in:
@ -3331,7 +3331,16 @@ exit:
|
|||||||
defined(MBEDTLS_USE_PSA_CRYPTO)
|
defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
if( opt.ecjpake_pw_opaque != DFL_ECJPAKE_PW_OPAQUE )
|
if( opt.ecjpake_pw_opaque != DFL_ECJPAKE_PW_OPAQUE )
|
||||||
{
|
{
|
||||||
psa_destroy_key( ecjpake_pw_slot );
|
psa_key_attributes_t key_attr = PSA_KEY_ATTRIBUTES_INIT;
|
||||||
|
|
||||||
|
/* Ensure the key is still valid before destroying it */
|
||||||
|
status = psa_get_key_attributes( ecjpake_pw_slot, &key_attr );
|
||||||
|
if( status == PSA_SUCCESS &&
|
||||||
|
PSA_ALG_IS_PAKE( psa_get_key_algorithm( &key_attr ) ) )
|
||||||
|
{
|
||||||
|
psa_destroy_key( ecjpake_pw_slot );
|
||||||
|
}
|
||||||
|
psa_reset_key_attributes( &key_attr );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED && MBEDTLS_USE_PSA_CRYPTO */
|
#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED && MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
|
@ -4441,7 +4441,16 @@ exit:
|
|||||||
defined(MBEDTLS_USE_PSA_CRYPTO)
|
defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
if( opt.ecjpake_pw_opaque != DFL_ECJPAKE_PW_OPAQUE )
|
if( opt.ecjpake_pw_opaque != DFL_ECJPAKE_PW_OPAQUE )
|
||||||
{
|
{
|
||||||
psa_destroy_key( ecjpake_pw_slot );
|
psa_key_attributes_t key_attr = PSA_KEY_ATTRIBUTES_INIT;
|
||||||
|
|
||||||
|
/* Ensure the key is still valid before destroying it */
|
||||||
|
status = psa_get_key_attributes( ecjpake_pw_slot, &key_attr );
|
||||||
|
if( status == PSA_SUCCESS &&
|
||||||
|
PSA_ALG_IS_PAKE( psa_get_key_algorithm( &key_attr ) ) )
|
||||||
|
{
|
||||||
|
psa_destroy_key( ecjpake_pw_slot );
|
||||||
|
}
|
||||||
|
psa_reset_key_attributes( &key_attr );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED && MBEDTLS_USE_PSA_CRYPTO */
|
#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED && MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user