From 72baf658193d97bca6e37eed1a195eec09b13bf3 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Wed, 28 Apr 2021 13:23:27 +0100 Subject: [PATCH] Ensure operation id gets set even if failure Although this deviates from the standard "auto-generated" code, the M-AEAD setup functions set the key and thus allocate memory. If the failure occurs after this (invalid tag size for example) then not having the id set to the internal drivers means that abort does not get called, and this causes the allocated data to leak. Signed-off-by: Paul Elliott --- library/psa_crypto_driver_wrappers.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/psa_crypto_driver_wrappers.c b/library/psa_crypto_driver_wrappers.c index ce49a226bf..1e17435015 100644 --- a/library/psa_crypto_driver_wrappers.c +++ b/library/psa_crypto_driver_wrappers.c @@ -1330,8 +1330,7 @@ psa_status_t psa_driver_wrapper_aead_encrypt_setup( key_buffer, key_buffer_size, alg ); - if( status == PSA_SUCCESS ) - operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; + operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; return( status ); @@ -1382,8 +1381,7 @@ psa_status_t psa_driver_wrapper_aead_decrypt_setup( key_buffer, key_buffer_size, alg ); - if( status == PSA_SUCCESS ) - operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; + operation->id = PSA_CRYPTO_MBED_TLS_DRIVER_ID; return( status );