From 7bcfc0a9aeced4d4f011ba7865682d961e932c71 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 18 Jun 2018 21:49:39 +0200 Subject: [PATCH] Be more consistent about blank lines --- library/psa_crypto.c | 17 ++++++++------ tests/suites/test_suite_psa_crypto.function | 26 --------------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 190341fbd..e5ac7bd81 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -305,6 +305,8 @@ static psa_status_t mbedtls_to_psa_error( int ret ) } } + + /****************************************************************/ /* Key management */ /****************************************************************/ @@ -556,7 +558,6 @@ psa_status_t psa_export_key( psa_key_slot_t key, data_length, 0 ) ); } - psa_status_t psa_export_public_key( psa_key_slot_t key, uint8_t *data, size_t data_size, @@ -566,6 +567,8 @@ psa_status_t psa_export_public_key( psa_key_slot_t key, data_length, 1 ) ); } + + /****************************************************************/ /* Message digests */ /****************************************************************/ @@ -909,7 +912,6 @@ psa_status_t psa_hash_verify( psa_hash_operation_t *operation, - /****************************************************************/ /* MAC */ /****************************************************************/ @@ -1395,7 +1397,6 @@ psa_status_t psa_mac_verify( psa_mac_operation_t *operation, - /****************************************************************/ /* Asymmetric cryptography */ /****************************************************************/ @@ -1679,7 +1680,6 @@ psa_status_t psa_asymmetric_encrypt( psa_key_slot_t key, { return( PSA_ERROR_NOT_SUPPORTED ); } - } psa_status_t psa_asymmetric_decrypt( psa_key_slot_t key, @@ -1748,9 +1748,10 @@ psa_status_t psa_asymmetric_decrypt( psa_key_slot_t key, { return( PSA_ERROR_NOT_SUPPORTED ); } - } + + /****************************************************************/ /* Symmetric cryptography */ /****************************************************************/ @@ -2015,6 +2016,7 @@ psa_status_t psa_cipher_abort( psa_cipher_operation_t *operation ) } + /****************************************************************/ /* Key Policy */ /****************************************************************/ @@ -2128,9 +2130,11 @@ psa_status_t psa_set_key_lifetime( psa_key_slot_t key, } + /****************************************************************/ /* AEAD */ /****************************************************************/ + psa_status_t psa_aead_encrypt( psa_key_slot_t key, psa_algorithm_t alg, const uint8_t *nonce, @@ -2223,8 +2227,6 @@ psa_status_t psa_aead_encrypt( psa_key_slot_t key, //update the tag pointer to point to the end of the ciphertext_length tag = ciphertext + plaintext_length; - - mbedtls_ccm_init( &ccm ); ret = mbedtls_ccm_setkey( &ccm, cipher_id, slot->data.raw.data, key_bits ); @@ -2393,6 +2395,7 @@ psa_status_t psa_aead_decrypt( psa_key_slot_t key, } + /****************************************************************/ /* Module setup */ /****************************************************************/ diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 5e66986ae..3de4745bf 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -145,7 +145,6 @@ exit: } /* END_CASE */ - /* BEGIN_CASE */ void import_export_public_key( data_t *data, int type_arg, @@ -317,7 +316,6 @@ exit: } /* END_CASE */ - /* BEGIN_CASE */ void cipher_encrypt( int alg_arg, int key_type_arg, data_t *key, @@ -524,7 +522,6 @@ exit: } /* END_CASE */ - /* BEGIN_CASE */ void cipher_decrypt( int alg_arg, int key_type_arg, data_t *key, @@ -585,7 +582,6 @@ void cipher_decrypt( int alg_arg, int key_type_arg, (size_t) expected_output->len ) == 0 ); } - exit: mbedtls_free( output ); psa_destroy_key( key_slot ); @@ -593,7 +589,6 @@ exit: } /* END_CASE */ - /* BEGIN_CASE */ void cipher_verify_output( int alg_arg, int key_type_arg, data_t *key, @@ -853,12 +848,10 @@ void aead_encrypt_decrypt( int key_type_arg, &output_length2 ) == expected_result ); - TEST_ASSERT( memcmp( input_data->x, output_data2, (size_t) input_data->len ) == 0 ); } - exit: psa_destroy_key( slot ); mbedtls_free( output_data ); @@ -917,11 +910,9 @@ void aead_encrypt( int key_type_arg, data_t * key_data, output_data, output_size, &output_length ) == PSA_SUCCESS ); - TEST_ASSERT( memcmp( output_data, expected_result->x, output_length ) == 0 ); - exit: psa_destroy_key( slot ); mbedtls_free( output_data ); @@ -945,7 +936,6 @@ void aead_decrypt( int key_type_arg, data_t * key_data, psa_key_policy_t policy = {0}; psa_status_t expected_result = (psa_status_t) expected_result_arg; - TEST_ASSERT( key_data != NULL ); TEST_ASSERT( input_data != NULL ); TEST_ASSERT( additional_data != NULL ); @@ -982,15 +972,12 @@ void aead_decrypt( int key_type_arg, data_t * key_data, output_size, &output_length ) == expected_result ); - if( expected_result == PSA_SUCCESS ) { TEST_ASSERT( memcmp( output_data, expected_data->x, output_length ) == 0 ); } - - exit: psa_destroy_key( slot ); mbedtls_free( output_data ); @@ -1239,7 +1226,6 @@ exit: } /* END_CASE */ - /* BEGIN_CASE */ void key_lifetime_set_fail( int key_slot_arg, int lifetime_arg, @@ -1312,7 +1298,6 @@ void asymmetric_verify_fail( int key_type_arg, data_t *key_data, data_t *signature_data, int expected_status_arg ) { - int slot = 1; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; @@ -1345,7 +1330,6 @@ void asymmetric_verify_fail( int key_type_arg, data_t *key_data, signature_data->x, (size_t) signature_data->len ); - TEST_ASSERT( actual_status == expected_status ); exit: @@ -1354,7 +1338,6 @@ exit: } /* END_CASE */ - /* BEGIN_CASE */ void asymmetric_encrypt_decrypt( int key_type_arg, data_t *key_data, int alg_arg, data_t *input_data ) @@ -1420,18 +1403,14 @@ exit: mbedtls_free( output ); mbedtls_free( output2 ); mbedtls_psa_crypto_free( ); - } /* END_CASE */ - /* BEGIN_CASE */ void asymmetric_encrypt_fail( int key_type_arg, data_t *key_data, int alg_arg, data_t *input_data, int expected_status_arg ) { - - int slot = 1; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg; @@ -1474,7 +1453,6 @@ exit: psa_destroy_key( slot ); mbedtls_free( output ); mbedtls_psa_crypto_free( ); - } /* END_CASE */ @@ -1526,18 +1504,14 @@ exit: psa_destroy_key( slot ); mbedtls_free( output ); mbedtls_psa_crypto_free( ); - - } /* END_CASE */ - /* BEGIN_CASE */ void asymmetric_decrypt_fail( int key_type_arg, data_t *key_data, int alg_arg, data_t *input_data, int expected_status_arg ) { - int slot = 1; psa_key_type_t key_type = key_type_arg; psa_algorithm_t alg = alg_arg;