From 6ab50762e0c3a13c8ae9198b66ae895e5739d3b7 Mon Sep 17 00:00:00 2001 From: Przemek Stekiel Date: Sat, 8 Oct 2022 17:54:30 +0200 Subject: [PATCH] psa_aead_setup: validate tag length before calling driver setup Signed-off-by: Przemek Stekiel --- library/psa_crypto.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 7bce3916be..2ff168d3f7 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3787,6 +3787,9 @@ static psa_status_t psa_aead_setup( psa_aead_operation_t *operation, .core = slot->attr }; + if( ( status = psa_validate_tag_length( alg ) ) != PSA_SUCCESS ) + goto exit; + if( is_encrypt ) status = psa_driver_wrapper_aead_encrypt_setup( operation, &attributes, @@ -3802,9 +3805,6 @@ static psa_status_t psa_aead_setup( psa_aead_operation_t *operation, if( status != PSA_SUCCESS ) goto exit; - if( ( status = psa_validate_tag_length( alg ) ) != PSA_SUCCESS ) - goto exit; - operation->key_type = psa_get_key_type( &attributes ); exit: