Fix key slot being used uninitialised on error
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
3dc1c242b4
commit
e715f88d9d
1 changed files with 14 additions and 8 deletions
|
@ -3240,7 +3240,7 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation,
|
||||||
{
|
{
|
||||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED;
|
psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
psa_key_slot_t *slot;
|
psa_key_slot_t *slot = NULL;
|
||||||
|
|
||||||
if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) )
|
if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) )
|
||||||
{
|
{
|
||||||
|
@ -3282,10 +3282,13 @@ psa_status_t psa_aead_encrypt_setup( psa_aead_operation_t *operation,
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
|
if( slot )
|
||||||
|
{
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
if( status == PSA_SUCCESS )
|
if( status == PSA_SUCCESS )
|
||||||
operation->alg = psa_aead_get_base_algorithm( alg );
|
operation->alg = psa_aead_get_base_algorithm( alg );
|
||||||
|
@ -3302,7 +3305,7 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation,
|
||||||
{
|
{
|
||||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED;
|
psa_status_t unlock_status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
psa_key_slot_t *slot;
|
psa_key_slot_t *slot = NULL;
|
||||||
|
|
||||||
if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) )
|
if( !PSA_ALG_IS_AEAD( alg ) || PSA_ALG_IS_WILDCARD( alg ) )
|
||||||
{
|
{
|
||||||
|
@ -3344,10 +3347,13 @@ psa_status_t psa_aead_decrypt_setup( psa_aead_operation_t *operation,
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
|
if( slot )
|
||||||
|
{
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
if( status == PSA_SUCCESS )
|
if( status == PSA_SUCCESS )
|
||||||
operation->alg = psa_aead_get_base_algorithm( alg );
|
operation->alg = psa_aead_get_base_algorithm( alg );
|
||||||
|
|
Loading…
Reference in a new issue