Remove unneccessary guard for key unlock

Also make sure failure is not hidden by key unlock failure

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
Paul Elliott 2021-05-21 17:13:50 +01:00
parent e95259f833
commit 6981fbcf10

View file

@ -3282,13 +3282,10 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation,
exit:
if( slot )
{
unlock_status = psa_unlock_key_slot( slot );
if( unlock_status != PSA_SUCCESS )
if( status == PSA_SUCCESS )
status = unlock_status;
}
if( status == PSA_SUCCESS )
operation->alg = psa_aead_get_base_algorithm( alg );
@ -3320,6 +3317,7 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation,
}
if( operation->nonce_set || operation->ad_started ||
operation->body_started )
{
status = PSA_ERROR_BAD_STATE;
@ -3347,13 +3345,10 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation,
exit:
if( slot )
{
unlock_status = psa_unlock_key_slot( slot );
if( unlock_status != PSA_SUCCESS )
if( status == PSA_SUCCESS )
status = unlock_status;
}
if( status == PSA_SUCCESS )
operation->alg = psa_aead_get_base_algorithm( alg );