From 7f429b747b8086781d32eb3db4d48e46a58e8ec7 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 24 Jun 2021 18:08:54 +0100 Subject: [PATCH] Remove code duplication and fix formatting Signed-off-by: Paul Elliott --- library/psa_crypto.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 9fb3a2094..64c05ea6e 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -3549,7 +3549,7 @@ psa_status_t psa_aead_generate_nonce( psa_aead_operation_t *operation, } if( operation->nonce_set || operation->ad_started || - operation->body_started || operation->is_encrypt == 0 ) + operation->body_started || !operation->is_encrypt ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3635,7 +3635,7 @@ psa_status_t psa_aead_set_lengths( psa_aead_operation_t *operation, } if( operation->lengths_set || operation->ad_started || - operation->body_started) + operation->body_started ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3761,7 +3761,7 @@ exit: static psa_status_t psa_aead_final_checks( psa_aead_operation_t *operation ) { - if( operation->id == 0 || operation->nonce_set == 0 ) + if( operation->id == 0 || !operation->nonce_set ) return( PSA_ERROR_BAD_STATE ); if( operation->lengths_set && (operation->ad_remaining != 0 || @@ -3790,7 +3790,7 @@ psa_status_t psa_aead_finish( psa_aead_operation_t *operation, if( status != PSA_SUCCESS ) goto exit; - if( operation->is_encrypt == 0 ) + if( !operation->is_encrypt ) { status = PSA_ERROR_BAD_STATE; goto exit; @@ -3831,17 +3831,12 @@ psa_status_t psa_aead_verify( psa_aead_operation_t *operation, if( status != PSA_SUCCESS ) goto exit; - if( operation->is_encrypt == 1 ) + if( operation->is_encrypt ) { status = PSA_ERROR_BAD_STATE; goto exit; } - status = psa_aead_final_checks( operation ); - - if( status != PSA_SUCCESS ) - goto exit; - status = psa_driver_wrapper_aead_verify( operation, plaintext, plaintext_size, plaintext_length,