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>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index 5d55e45..14ef6e5 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -3282,13 +3282,10 @@
exit:
- if( slot )
- {
- unlock_status = psa_unlock_key_slot( slot );
+ unlock_status = psa_unlock_key_slot( slot );
- if( unlock_status != PSA_SUCCESS )
- status = unlock_status;
- }
+ if( status == PSA_SUCCESS )
+ status = unlock_status;
if( status == PSA_SUCCESS )
operation->alg = psa_aead_get_base_algorithm( alg );
@@ -3320,6 +3317,7 @@
}
if( operation->nonce_set || operation->ad_started ||
+
operation->body_started )
{
status = PSA_ERROR_BAD_STATE;
@@ -3347,13 +3345,10 @@
exit:
- if( slot )
- {
- unlock_status = psa_unlock_key_slot( slot );
+ unlock_status = psa_unlock_key_slot( slot );
- if( unlock_status != PSA_SUCCESS )
- status = unlock_status;
- }
+ if( status == PSA_SUCCESS )
+ status = unlock_status;
if( status == PSA_SUCCESS )
operation->alg = psa_aead_get_base_algorithm( alg );