From b06e1c0d68b1acd130cd1abc3056fdf589aadbb9 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 13 May 2021 18:33:43 +0100 Subject: [PATCH] Remove unnecessary code Calls to abort that are now being done by the psa_crypto layer, freeing of tempory allocations (done by abort) and a couple of checks that had already been done prior to that point Signed-off-by: Paul Elliott --- library/psa_crypto_aead.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/library/psa_crypto_aead.c b/library/psa_crypto_aead.c index 0a84888b1..848889af8 100644 --- a/library/psa_crypto_aead.c +++ b/library/psa_crypto_aead.c @@ -658,11 +658,6 @@ psa_status_t mbedtls_psa_aead_update( mbedtls_psa_aead_operation_t *operation, operation->tag_buffer, operation->tag_length ) ); - /* Even if the above operation fails, we no longer need the - additional data.*/ - mbedtls_free( operation->ad_buffer ); - operation->ad_buffer = NULL; - operation->ad_length = 0; } else { @@ -784,9 +779,6 @@ psa_status_t mbedtls_psa_aead_finish( mbedtls_psa_aead_operation_t *operation, /* Copy the previously generated tag into place */ memcpy( tag, operation->tag_buffer, operation->tag_length ); - mbedtls_free(operation->tag_buffer); - operation->tag_buffer = NULL; - status = PSA_SUCCESS; } else @@ -815,8 +807,6 @@ psa_status_t mbedtls_psa_aead_finish( mbedtls_psa_aead_operation_t *operation, *tag_length = operation->tag_length; } - mbedtls_psa_aead_abort(operation); - return ( status ); } @@ -858,9 +848,6 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, #if defined(MBEDTLS_PSA_BUILTIN_ALG_CCM) if( operation->alg == PSA_ALG_CCM ) { - if( !operation->ad_buffer || !operation->body_buffer ) - return( PSA_ERROR_BAD_STATE ); - /* Perform oneshot CCM decryption *again*, as its the * only way to get the tag, but this time throw away the results, as verify cannot write that much data. */ @@ -895,13 +882,6 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, /* Even if the above operation fails, we no longer need the data */ mbedtls_free(temp_buffer); - - mbedtls_free(operation->body_buffer); - operation->body_buffer = NULL; - operation->body_length = 0; - - mbedtls_free(operation->tag_buffer); - operation->tag_buffer = NULL; } else #endif /* MBEDTLS_PSA_BUILTIN_ALG_CCM */ @@ -933,8 +913,6 @@ psa_status_t mbedtls_psa_aead_verify( mbedtls_psa_aead_operation_t *operation, status = PSA_ERROR_INVALID_SIGNATURE; } - mbedtls_psa_aead_abort(operation); - return ( status ); }