Ensure that key gets unlocked in case of error

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
Paul Elliott 2021-05-20 14:33:13 +01:00
parent cee785cd72
commit ac1b3fd5b6

View file

@ -3280,14 +3280,12 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation,
operation->key_type = psa_get_key_type( &attributes );
exit:
unlock_status = psa_unlock_key_slot( slot );
if( unlock_status != PSA_SUCCESS )
{
status = unlock_status;
}
exit:
if( status == PSA_SUCCESS )
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,
slot->key.bytes, alg );
if( status != PSA_SUCCESS )
goto exit;
operation->key_type = psa_get_key_type( &attributes );
exit:
unlock_status = psa_unlock_key_slot( slot );
if( unlock_status != PSA_SUCCESS )
status = unlock_status;
exit:
if( status == PSA_SUCCESS )
operation->alg = psa_aead_get_base_algorithm( alg );
else