diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 9c7a380d5..adf3b2b7a 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -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