From 6158e283cc5a171b46bdbef88f5b01f66c4ec2f8 Mon Sep 17 00:00:00 2001 From: gabor-mezei-arm Date: Tue, 29 Jun 2021 16:42:13 +0200 Subject: [PATCH] Check the return status of the functions first Signed-off-by: gabor-mezei-arm --- library/psa_crypto_cipher.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/psa_crypto_cipher.c b/library/psa_crypto_cipher.c index 3701f72da..62062375b 100644 --- a/library/psa_crypto_cipher.c +++ b/library/psa_crypto_cipher.c @@ -482,16 +482,17 @@ static psa_status_t cipher_encrypt( const psa_key_attributes_t *attributes, output + operation.iv_length, output_size - operation.iv_length, &olength ); - accumulated_length += olength; if( status != PSA_SUCCESS ) goto exit; + accumulated_length += olength; + status = cipher_finish( &operation, output + accumulated_length, output_size - accumulated_length, &olength ); - accumulated_length += olength; if( status != PSA_SUCCESS ) goto exit; + accumulated_length += olength; *output_length = accumulated_length; exit: @@ -531,17 +532,17 @@ static psa_status_t cipher_decrypt( const psa_key_attributes_t *attributes, status = cipher_update( &operation, input + operation.iv_length, input_length - operation.iv_length, output, output_size, &olength ); - accumulated_length = olength; if( status != PSA_SUCCESS ) goto exit; + accumulated_length = olength; status = cipher_finish( &operation, output + accumulated_length, output_size - accumulated_length, &olength ); - accumulated_length += olength; if( status != PSA_SUCCESS ) goto exit; + accumulated_length += olength; *output_length = accumulated_length; exit: