From 0f915f1d2a53cd390224376b6365f73fe58868a6 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 17 Dec 2018 23:35:42 +0100 Subject: [PATCH] Indent PSA tests according to K&R rules with Mbed TLS tweaks Only whitespace changes in this commit. --- tests/suites/test_suite_psa_crypto.function | 30 +++++++++---------- .../test_suite_psa_crypto_hash.function | 4 +-- .../test_suite_psa_crypto_metadata.function | 2 +- ...t_suite_psa_crypto_persistent_key.function | 12 ++++---- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index 11e4dbb0b..d6b5e5154 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -617,7 +617,7 @@ static int exported_key_sanity_check( psa_key_type_t type, size_t bits, if( ! asn1_skip_integer( &p, end, 1, bits / 2 + 1, 0 ) ) goto exit; TEST_ASSERT( p == end ); - } + } else #endif /* MBEDTLS_RSA_C */ @@ -1210,7 +1210,7 @@ void export_after_import_failure( data_t *data, int type_arg, /* Import the key - expect failure */ status = psa_import_key( handle, type, - data->x, data->len ); + data->x, data->len ); TEST_ASSERT( status == expected_import_status ); /* Export the key */ @@ -1242,7 +1242,7 @@ void cipher_after_import_failure( data_t *data, int type_arg, /* Import the key - expect failure */ status = psa_import_key( handle, type, - data->x, data->len ); + data->x, data->len ); TEST_ASSERT( status == expected_import_status ); status = psa_cipher_encrypt_setup( &operation, handle, exercise_alg ); @@ -1832,19 +1832,19 @@ void hash_bad_order( ) memset( &operation, 0, sizeof( operation ) ); TEST_ASSERT( psa_hash_update( &operation, input, sizeof( input ) ) == - PSA_ERROR_INVALID_ARGUMENT ); + PSA_ERROR_INVALID_ARGUMENT ); /* psa_hash_verify without calling psa_hash_setup beforehand */ memset( &operation, 0, sizeof( operation ) ); TEST_ASSERT( psa_hash_verify( &operation, hash, sizeof( hash ) ) == - PSA_ERROR_INVALID_ARGUMENT ); + PSA_ERROR_INVALID_ARGUMENT ); /* psa_hash_finish without calling psa_hash_setup beforehand */ memset( &operation, 0, sizeof( operation ) ); TEST_ASSERT( psa_hash_finish( &operation, hash, sizeof( hash ), &hash_len ) == - PSA_ERROR_INVALID_ARGUMENT ); + PSA_ERROR_INVALID_ARGUMENT ); exit: mbedtls_psa_crypto_free( ); @@ -1870,19 +1870,19 @@ void hash_verify_bad_args( ) TEST_ASSERT( psa_hash_setup( &operation, alg ) == PSA_SUCCESS ); TEST_ASSERT( psa_hash_verify( &operation, hash, expected_size - 1 ) == - PSA_ERROR_INVALID_SIGNATURE ); + PSA_ERROR_INVALID_SIGNATURE ); /* psa_hash_verify with a non-matching hash */ TEST_ASSERT( psa_hash_setup( &operation, alg ) == PSA_SUCCESS ); TEST_ASSERT( psa_hash_verify( &operation, hash + 1, expected_size ) == - PSA_ERROR_INVALID_SIGNATURE ); + PSA_ERROR_INVALID_SIGNATURE ); /* psa_hash_verify with a hash longer than expected */ TEST_ASSERT( psa_hash_setup( &operation, alg ) == PSA_SUCCESS ); TEST_ASSERT( psa_hash_verify( &operation, hash, sizeof( hash ) ) == - PSA_ERROR_INVALID_SIGNATURE ); + PSA_ERROR_INVALID_SIGNATURE ); exit: mbedtls_psa_crypto_free( ); @@ -4143,7 +4143,7 @@ void persistent_key_load_key_from_storage( data_t *data, int type_arg, psa_key_policy_set_usage( &base_policy_set, PSA_KEY_USAGE_DERIVE, base_policy_alg ); TEST_ASSERT( psa_set_key_policy( - base_key, &base_policy_set ) == PSA_SUCCESS ); + base_key, &base_policy_set ) == PSA_SUCCESS ); TEST_ASSERT( psa_import_key( base_key, PSA_KEY_TYPE_DERIVE, data->x, data->len ) == PSA_SUCCESS ); /* Derive a key. */ @@ -4152,8 +4152,8 @@ void persistent_key_load_key_from_storage( data_t *data, int type_arg, NULL, 0, NULL, 0, export_size ) == PSA_SUCCESS ); TEST_ASSERT( psa_generator_import_key( - handle, PSA_KEY_TYPE_RAW_DATA, - bits, &generator ) == PSA_SUCCESS ); + handle, PSA_KEY_TYPE_RAW_DATA, + bits, &generator ) == PSA_SUCCESS ); break; } @@ -4169,15 +4169,15 @@ void persistent_key_load_key_from_storage( data_t *data, int type_arg, TEST_ASSERT( psa_open_key( PSA_KEY_LIFETIME_PERSISTENT, 1, &handle ) == PSA_SUCCESS ); TEST_ASSERT( psa_get_key_information( - handle, &type_get, &bits_get ) == PSA_SUCCESS ); + handle, &type_get, &bits_get ) == PSA_SUCCESS ); TEST_ASSERT( type_get == type ); TEST_ASSERT( bits_get == (size_t) bits ); TEST_ASSERT( psa_get_key_policy( handle, &policy_get ) == PSA_SUCCESS ); TEST_ASSERT( psa_key_policy_get_usage( - &policy_get ) == policy_usage ); + &policy_get ) == policy_usage ); TEST_ASSERT( psa_key_policy_get_algorithm( - &policy_get ) == policy_alg ); + &policy_get ) == policy_alg ); /* Export the key again */ TEST_ASSERT( psa_export_key( handle, second_export, export_size, diff --git a/tests/suites/test_suite_psa_crypto_hash.function b/tests/suites/test_suite_psa_crypto_hash.function index 14e6a9769..bed80e262 100644 --- a/tests/suites/test_suite_psa_crypto_hash.function +++ b/tests/suites/test_suite_psa_crypto_hash.function @@ -15,7 +15,7 @@ * END_DEPENDENCIES */ - /* BEGIN_CASE */ +/* BEGIN_CASE */ void hash_finish( int alg_arg, data_t *input, data_t *expected_hash ) { psa_algorithm_t alg = alg_arg; @@ -80,7 +80,7 @@ void hash_multi_part( int alg_arg, data_t *input, data_t *expected_hash ) input->x, len ) == PSA_SUCCESS ); TEST_ASSERT( psa_hash_update( &operation, input->x + len, input->len - len ) == - PSA_SUCCESS ); + PSA_SUCCESS ); TEST_ASSERT( psa_hash_finish( &operation, actual_hash, sizeof( actual_hash ), diff --git a/tests/suites/test_suite_psa_crypto_metadata.function b/tests/suites/test_suite_psa_crypto_metadata.function index a8316c40d..af11e7ae1 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.function +++ b/tests/suites/test_suite_psa_crypto_metadata.function @@ -46,7 +46,7 @@ #define KEY_TYPE_IS_DSA ( 1u << 5 ) #define KEY_TYPE_IS_ECC ( 1u << 6 ) -#define TEST_CLASSIFICATION_MACRO( flag, alg, flags ) \ +#define TEST_CLASSIFICATION_MACRO( flag, alg, flags ) \ TEST_ASSERT( PSA_##flag( alg ) == !! ( ( flags ) & flag ) ) void algorithm_classification( psa_algorithm_t alg, unsigned flags ) diff --git a/tests/suites/test_suite_psa_crypto_persistent_key.function b/tests/suites/test_suite_psa_crypto_persistent_key.function index 08c7ca017..aa8fddd3a 100644 --- a/tests/suites/test_suite_psa_crypto_persistent_key.function +++ b/tests/suites/test_suite_psa_crypto_persistent_key.function @@ -103,7 +103,7 @@ void save_large_persistent_key( int data_too_large, int expected_status ) &handle ) == PSA_SUCCESS ); TEST_ASSERT( psa_import_key( handle, PSA_KEY_TYPE_RAW_DATA, - data, data_length ) == expected_status ); + data, data_length ) == expected_status ); exit: mbedtls_free( data ); @@ -135,8 +135,8 @@ void persistent_key_destroy( int key_id_arg, int should_store, if( should_store == 1 ) { TEST_ASSERT( psa_import_key( - handle, first_type, - first_data->x, first_data->len ) == PSA_SUCCESS ); + handle, first_type, + first_data->x, first_data->len ) == PSA_SUCCESS ); } /* Destroy the key */ @@ -158,8 +158,8 @@ void persistent_key_destroy( int key_id_arg, int should_store, PSA_BYTES_TO_BITS( second_data->len ), &handle ) == PSA_SUCCESS ); TEST_ASSERT( psa_import_key( - handle, second_type, - second_data->x, second_data->len ) == PSA_SUCCESS ); + handle, second_type, + second_data->x, second_data->len ) == PSA_SUCCESS ); exit: mbedtls_psa_crypto_free(); @@ -240,7 +240,7 @@ void import_export_persistent_key( data_t *data, int type_arg, /* Test the key information */ TEST_ASSERT( psa_get_key_information( - handle, &got_type, &got_bits ) == PSA_SUCCESS ); + handle, &got_type, &got_bits ) == PSA_SUCCESS ); TEST_ASSERT( got_type == type ); TEST_ASSERT( got_bits == (size_t) expected_bits );