mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-09-07 01:26:39 +03:00
Ensure that key gets unlocked in case of error
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
@@ -3280,14 +3280,12 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation,
|
|||||||
|
|
||||||
operation->key_type = psa_get_key_type( &attributes );
|
operation->key_type = psa_get_key_type( &attributes );
|
||||||
|
|
||||||
|
exit:
|
||||||
|
|
||||||
unlock_status = psa_unlock_key_slot( slot );
|
unlock_status = psa_unlock_key_slot( slot );
|
||||||
|
|
||||||
if( unlock_status != PSA_SUCCESS )
|
if( unlock_status != PSA_SUCCESS )
|
||||||
{
|
|
||||||
status = unlock_status;
|
status = unlock_status;
|
||||||
}
|
|
||||||
|
|
||||||
exit:
|
|
||||||
|
|
||||||
if( status == PSA_SUCCESS )
|
if( status == PSA_SUCCESS )
|
||||||
operation->alg = psa_aead_get_base_algorithm( alg );
|
operation->alg = psa_aead_get_base_algorithm( alg );
|
||||||
@@ -3339,15 +3337,18 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation,
|
|||||||
&attributes, slot->key.data,
|
&attributes, slot->key.data,
|
||||||
slot->key.bytes, alg );
|
slot->key.bytes, alg );
|
||||||
|
|
||||||
|
if( status != PSA_SUCCESS )
|
||||||
|
goto exit;
|
||||||
|
|
||||||
operation->key_type = psa_get_key_type( &attributes );
|
operation->key_type = psa_get_key_type( &attributes );
|
||||||
|
|
||||||
|
exit:
|
||||||
|
|
||||||
unlock_status = psa_unlock_key_slot( slot );
|
unlock_status = psa_unlock_key_slot( slot );
|
||||||
|
|
||||||
if( unlock_status != PSA_SUCCESS )
|
if( unlock_status != PSA_SUCCESS )
|
||||||
status = unlock_status;
|
status = unlock_status;
|
||||||
|
|
||||||
exit:
|
|
||||||
|
|
||||||
if( status == PSA_SUCCESS )
|
if( status == PSA_SUCCESS )
|
||||||
operation->alg = psa_aead_get_base_algorithm( alg );
|
operation->alg = psa_aead_get_base_algorithm( alg );
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user