From 1a45c713f09415e51239a0af364b25e576433d59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 27 Jan 2022 12:17:20 +0100 Subject: [PATCH] Fix cleanup code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- programs/psa/aead_cipher_psa.c | 5 +++++ programs/psa/hmac_md_psa.c | 1 + 2 files changed, 6 insertions(+) diff --git a/programs/psa/aead_cipher_psa.c b/programs/psa/aead_cipher_psa.c index a2b47d13d..bac3ea27d 100644 --- a/programs/psa/aead_cipher_psa.c +++ b/programs/psa/aead_cipher_psa.c @@ -311,7 +311,10 @@ static int aead_encrypt( psa_key_id_t key, psa_algorithm_t alg, olen = p - out; print_out( "aead ", out, olen ); + exit: + /* required on errors, harmless on success */ + psa_aead_abort( &op ); return( status ); } @@ -336,6 +339,8 @@ static psa_status_t aead( const char *info ) msg2_part2, sizeof( msg2_part2 ) ) ); exit: + psa_destroy_key( key ); + return( status ); } diff --git a/programs/psa/hmac_md_psa.c b/programs/psa/hmac_md_psa.c index 003fb5c7d..49e1eced7 100644 --- a/programs/psa/hmac_md_psa.c +++ b/programs/psa/hmac_md_psa.c @@ -150,6 +150,7 @@ psa_status_t mac(void) exit: psa_mac_abort( &op ); + psa_destroy_key( key ); return( status ); }