From b5dd7c794d9567cbc2a4fafee5083fa34d6fc252 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Thu, 24 Jun 2021 16:17:43 +0100 Subject: [PATCH] Correct coding style issues Signed-off-by: Dave Rodgman --- library/psa_crypto.c | 47 +++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 9ab7561f7..43787cf27 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -2083,12 +2083,14 @@ psa_status_t psa_hash_setup( psa_hash_operation_t *operation, psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; /* A context must be freshly initialized before it can be set up. */ - if( operation->id != 0 ) { + if( operation->id != 0 ) + { status = PSA_ERROR_BAD_STATE; goto exit; } - if( !PSA_ALG_IS_HASH( alg ) ) { + if( !PSA_ALG_IS_HASH( alg ) ) + { status = PSA_ERROR_INVALID_ARGUMENT; goto exit; } @@ -2101,7 +2103,7 @@ psa_status_t psa_hash_setup( psa_hash_operation_t *operation, exit: if( status != PSA_SUCCESS ) - psa_hash_abort(operation); + psa_hash_abort( operation ); return status; } @@ -2112,7 +2114,8 @@ psa_status_t psa_hash_update( psa_hash_operation_t *operation, { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if( operation->id == 0 ) { + if( operation->id == 0 ) + { status = PSA_ERROR_BAD_STATE; goto exit; } @@ -2160,7 +2163,8 @@ psa_status_t psa_hash_verify( psa_hash_operation_t *operation, if( status != PSA_SUCCESS ) goto exit; - if( actual_hash_length != hash_length ) { + if( actual_hash_length != hash_length ) + { status = PSA_ERROR_INVALID_SIGNATURE; goto exit; } @@ -2297,7 +2301,8 @@ static psa_status_t psa_mac_setup( psa_mac_operation_t *operation, psa_key_slot_t *slot = NULL; /* A context must be freshly initialized before it can be set up. */ - if( operation->id != 0 ) { + if( operation->id != 0 ) + { status = PSA_ERROR_BAD_STATE; goto exit; } @@ -2399,19 +2404,22 @@ psa_status_t psa_mac_sign_finish( psa_mac_operation_t *operation, goto cleanup; } - if( ! operation->is_sign ) { + if( ! operation->is_sign ) + { status = PSA_ERROR_BAD_STATE; goto cleanup; } /* Sanity check. This will guarantee that mac_size != 0 (and so mac != NULL) * once all the error checks are done. */ - if( operation->mac_size == 0 ) { + if( operation->mac_size == 0 ) + { status = PSA_ERROR_BAD_STATE; goto cleanup; } - if( mac_size < operation->mac_size ) { + if( mac_size < operation->mac_size ) + { status = PSA_ERROR_BUFFER_TOO_SMALL; goto cleanup; } @@ -2449,12 +2457,14 @@ psa_status_t psa_mac_verify_finish( psa_mac_operation_t *operation, psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; psa_status_t abort_status = PSA_ERROR_CORRUPTION_DETECTED; - if( operation->id == 0 ) { + if( operation->id == 0 ) + { status = PSA_ERROR_BAD_STATE; goto cleanup; } - if( operation->is_sign ) { + if( operation->is_sign ) + { status = PSA_ERROR_BAD_STATE; goto cleanup; } @@ -3224,13 +3234,15 @@ static psa_status_t psa_cipher_setup( psa_cipher_operation_t *operation, PSA_KEY_USAGE_DECRYPT ); /* A context must be freshly initialized before it can be set up. */ - if( operation->id != 0 ) { + if( operation->id != 0 ) + { status = PSA_ERROR_BAD_STATE; goto exit; } /* The requested algorithm must be one that can be processed by cipher. */ - if( ! PSA_ALG_IS_CIPHER( alg ) ) { + if( ! PSA_ALG_IS_CIPHER( alg ) ) + { status = PSA_ERROR_INVALID_ARGUMENT; goto exit; } @@ -3345,17 +3357,20 @@ psa_status_t psa_cipher_set_iv( psa_cipher_operation_t *operation, { psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; - if( operation->id == 0 ) { + if( operation->id == 0 ) + { status = PSA_ERROR_BAD_STATE; goto exit; } - if( operation->iv_set || ! operation->iv_required ) { + if( operation->iv_set || ! operation->iv_required ) + { status = PSA_ERROR_BAD_STATE; goto exit; } - if( iv_length > PSA_CIPHER_IV_MAX_SIZE ) { + if( iv_length > PSA_CIPHER_IV_MAX_SIZE ) + { status = PSA_ERROR_INVALID_ARGUMENT; goto exit; }