diff --git a/tests/include/test/drivers/mac.h b/tests/include/test/drivers/mac.h index e4c750bd6..7733dd341 100644 --- a/tests/include/test/drivers/mac.h +++ b/tests/include/test/drivers/mac.h @@ -37,16 +37,17 @@ typedef struct { unsigned long hits; /* Status returned by the last MAC driver function call. */ psa_status_t driver_status; -} test_driver_mac_hooks_t; +} mbedtls_test_driver_mac_hooks_t; #define MBEDTLS_TEST_DRIVER_MAC_INIT { 0, 0, 0 } -static inline test_driver_mac_hooks_t test_driver_mac_hooks_init( void ) +static inline mbedtls_test_driver_mac_hooks_t + mbedtls_test_driver_mac_hooks_init( void ) { - const test_driver_mac_hooks_t v = MBEDTLS_TEST_DRIVER_MAC_INIT; + const mbedtls_test_driver_mac_hooks_t v = MBEDTLS_TEST_DRIVER_MAC_INIT; return( v ); } -extern test_driver_mac_hooks_t test_driver_mac_hooks; +extern mbedtls_test_driver_mac_hooks_t mbedtls_test_driver_mac_hooks; psa_status_t mbedtls_test_transparent_mac_compute( const psa_key_attributes_t *attributes, diff --git a/tests/src/drivers/test_driver_mac.c b/tests/src/drivers/test_driver_mac.c index 4e26e9f21..69af10780 100644 --- a/tests/src/drivers/test_driver_mac.c +++ b/tests/src/drivers/test_driver_mac.c @@ -28,7 +28,8 @@ #include "test/drivers/mac.h" -test_driver_mac_hooks_t test_driver_mac_hooks = MBEDTLS_TEST_DRIVER_MAC_INIT; +mbedtls_test_driver_mac_hooks_t mbedtls_test_driver_mac_hooks = + MBEDTLS_TEST_DRIVER_MAC_INIT; psa_status_t mbedtls_test_transparent_mac_compute( const psa_key_attributes_t *attributes, @@ -41,23 +42,23 @@ psa_status_t mbedtls_test_transparent_mac_compute( size_t mac_size, size_t *mac_length ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_transparent_test_driver_mac_compute( attributes, key_buffer, key_buffer_size, alg, input, input_length, mac, mac_size, mac_length ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } psa_status_t mbedtls_test_transparent_mac_sign_setup( @@ -67,21 +68,21 @@ psa_status_t mbedtls_test_transparent_mac_sign_setup( size_t key_buffer_size, psa_algorithm_t alg ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_transparent_test_driver_mac_sign_setup( operation, attributes, key_buffer, key_buffer_size, alg ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } psa_status_t mbedtls_test_transparent_mac_verify_setup( @@ -91,21 +92,21 @@ psa_status_t mbedtls_test_transparent_mac_verify_setup( size_t key_buffer_size, psa_algorithm_t alg ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_transparent_test_driver_mac_verify_setup( operation, attributes, key_buffer, key_buffer_size, alg ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } psa_status_t mbedtls_test_transparent_mac_update( @@ -113,21 +114,21 @@ psa_status_t mbedtls_test_transparent_mac_update( const uint8_t *input, size_t input_length ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_transparent_test_driver_mac_update( operation, input, input_length ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } psa_status_t mbedtls_test_transparent_mac_sign_finish( @@ -136,21 +137,21 @@ psa_status_t mbedtls_test_transparent_mac_sign_finish( size_t mac_size, size_t *mac_length ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_transparent_test_driver_mac_sign_finish( operation, mac, mac_size, mac_length ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } psa_status_t mbedtls_test_transparent_mac_verify_finish( @@ -158,40 +159,40 @@ psa_status_t mbedtls_test_transparent_mac_verify_finish( const uint8_t *mac, size_t mac_length ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_transparent_test_driver_mac_verify_finish( operation, mac, mac_length ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } psa_status_t mbedtls_test_transparent_mac_abort( mbedtls_transparent_test_driver_mac_operation_t *operation ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_transparent_test_driver_mac_abort( operation ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } psa_status_t mbedtls_test_opaque_mac_compute( @@ -205,23 +206,23 @@ psa_status_t mbedtls_test_opaque_mac_compute( size_t mac_size, size_t *mac_length ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_opaque_test_driver_mac_compute( attributes, key_buffer, key_buffer_size, alg, input, input_length, mac, mac_size, mac_length ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } psa_status_t mbedtls_test_opaque_mac_sign_setup( @@ -231,21 +232,21 @@ psa_status_t mbedtls_test_opaque_mac_sign_setup( size_t key_buffer_size, psa_algorithm_t alg ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_opaque_test_driver_mac_sign_setup( operation, attributes, key_buffer, key_buffer_size, alg ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } psa_status_t mbedtls_test_opaque_mac_verify_setup( @@ -255,21 +256,21 @@ psa_status_t mbedtls_test_opaque_mac_verify_setup( size_t key_buffer_size, psa_algorithm_t alg ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_opaque_test_driver_mac_verify_setup( operation, attributes, key_buffer, key_buffer_size, alg ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } psa_status_t mbedtls_test_opaque_mac_update( @@ -277,21 +278,21 @@ psa_status_t mbedtls_test_opaque_mac_update( const uint8_t *input, size_t input_length ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_opaque_test_driver_mac_update( operation, input, input_length ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } psa_status_t mbedtls_test_opaque_mac_sign_finish( @@ -300,21 +301,21 @@ psa_status_t mbedtls_test_opaque_mac_sign_finish( size_t mac_size, size_t *mac_length ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_opaque_test_driver_mac_sign_finish( operation, mac, mac_size, mac_length ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } psa_status_t mbedtls_test_opaque_mac_verify_finish( @@ -322,40 +323,40 @@ psa_status_t mbedtls_test_opaque_mac_verify_finish( const uint8_t *mac, size_t mac_length ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_opaque_test_driver_mac_verify_finish( operation, mac, mac_length ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } psa_status_t mbedtls_test_opaque_mac_abort( mbedtls_opaque_test_driver_mac_operation_t *operation ) { - test_driver_mac_hooks.hits++; + mbedtls_test_driver_mac_hooks.hits++; - if( test_driver_mac_hooks.forced_status != PSA_SUCCESS ) + if( mbedtls_test_driver_mac_hooks.forced_status != PSA_SUCCESS ) { - test_driver_mac_hooks.driver_status = - test_driver_mac_hooks.forced_status; + mbedtls_test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.forced_status; } else { - test_driver_mac_hooks.driver_status = + mbedtls_test_driver_mac_hooks.driver_status = mbedtls_opaque_test_driver_mac_abort( operation ); } - return( test_driver_mac_hooks.driver_status ); + return( mbedtls_test_driver_mac_hooks.driver_status ); } #endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */ diff --git a/tests/suites/test_suite_psa_crypto_driver_wrappers.function b/tests/suites/test_suite_psa_crypto_driver_wrappers.function index f523d3c88..ac241f5ad 100644 --- a/tests/suites/test_suite_psa_crypto_driver_wrappers.function +++ b/tests/suites/test_suite_psa_crypto_driver_wrappers.function @@ -982,7 +982,7 @@ void mac_sign( int key_type_arg, size_t mac_length = 0; psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; psa_status_t forced_status = forced_status_arg; - test_driver_mac_hooks = test_driver_mac_hooks_init(); + mbedtls_test_driver_mac_hooks = mbedtls_test_driver_mac_hooks_init(); TEST_ASSERT( mac_buffer_size <= PSA_MAC_MAX_SIZE ); /* We expect PSA_MAC_LENGTH to be exact. */ @@ -998,11 +998,11 @@ void mac_sign( int key_type_arg, &key ) ); ASSERT_ALLOC( actual_mac, mac_buffer_size ); - test_driver_mac_hooks.forced_status = forced_status; + mbedtls_test_driver_mac_hooks.forced_status = forced_status; /* Calculate the MAC. */ status = psa_mac_sign_setup( &operation, key, alg ); - TEST_EQUAL( test_driver_mac_hooks.hits, 1 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 ); if( forced_status == PSA_SUCCESS || forced_status == PSA_ERROR_NOT_SUPPORTED ) @@ -1015,9 +1015,9 @@ void mac_sign( int key_type_arg, status = psa_mac_update( &operation, input->x, input->len ); if( forced_status == PSA_SUCCESS ) - TEST_EQUAL( test_driver_mac_hooks.hits, 2 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 2 ); else - TEST_EQUAL( test_driver_mac_hooks.hits, 1 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 ); if( forced_status == PSA_SUCCESS || forced_status == PSA_ERROR_NOT_SUPPORTED ) { @@ -1030,9 +1030,9 @@ void mac_sign( int key_type_arg, actual_mac, mac_buffer_size, &mac_length ); if( forced_status == PSA_SUCCESS ) - TEST_EQUAL( test_driver_mac_hooks.hits, 4 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 4 ); else - TEST_EQUAL( test_driver_mac_hooks.hits, 1 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 ); if( forced_status == PSA_SUCCESS || forced_status == PSA_ERROR_NOT_SUPPORTED ) @@ -1044,9 +1044,9 @@ void mac_sign( int key_type_arg, PSA_ASSERT( psa_mac_abort( &operation ) ); if( forced_status == PSA_SUCCESS ) - TEST_EQUAL( test_driver_mac_hooks.hits, 4 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 4 ); else - TEST_EQUAL( test_driver_mac_hooks.hits, 1 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 ); if( forced_status == PSA_SUCCESS ) { @@ -1062,7 +1062,7 @@ exit: psa_destroy_key( key ); PSA_DONE( ); mbedtls_free( actual_mac ); - test_driver_mac_hooks = test_driver_mac_hooks_init(); + mbedtls_test_driver_mac_hooks = mbedtls_test_driver_mac_hooks_init(); } /* END_CASE */ @@ -1081,7 +1081,7 @@ void mac_verify( int key_type_arg, psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; psa_status_t status = PSA_ERROR_GENERIC_ERROR; psa_status_t forced_status = forced_status_arg; - test_driver_mac_hooks = test_driver_mac_hooks_init(); + mbedtls_test_driver_mac_hooks = mbedtls_test_driver_mac_hooks_init(); TEST_ASSERT( expected_mac->len <= PSA_MAC_MAX_SIZE ); @@ -1094,11 +1094,11 @@ void mac_verify( int key_type_arg, PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len, &key ) ); - test_driver_mac_hooks.forced_status = forced_status; + mbedtls_test_driver_mac_hooks.forced_status = forced_status; /* Test the correct MAC. */ status = psa_mac_verify_setup( &operation, key, alg ); - TEST_EQUAL( test_driver_mac_hooks.hits, 1 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 ); if( forced_status == PSA_SUCCESS || forced_status == PSA_ERROR_NOT_SUPPORTED ) @@ -1111,9 +1111,9 @@ void mac_verify( int key_type_arg, status = psa_mac_update( &operation, input->x, input->len ); if( forced_status == PSA_SUCCESS ) - TEST_EQUAL( test_driver_mac_hooks.hits, 2 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 2 ); else - TEST_EQUAL( test_driver_mac_hooks.hits, 1 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 ); if( forced_status == PSA_SUCCESS || forced_status == PSA_ERROR_NOT_SUPPORTED ) @@ -1127,9 +1127,9 @@ void mac_verify( int key_type_arg, expected_mac->x, expected_mac->len ); if( forced_status == PSA_SUCCESS ) - TEST_EQUAL( test_driver_mac_hooks.hits, 4 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 4 ); else - TEST_EQUAL( test_driver_mac_hooks.hits, 1 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 ); if( forced_status == PSA_SUCCESS || forced_status == PSA_ERROR_NOT_SUPPORTED ) @@ -1142,15 +1142,15 @@ void mac_verify( int key_type_arg, PSA_ASSERT( psa_mac_abort( &operation ) ); if( forced_status == PSA_SUCCESS ) - TEST_EQUAL( test_driver_mac_hooks.hits, 4 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 4 ); else - TEST_EQUAL( test_driver_mac_hooks.hits, 1 ); + TEST_EQUAL( mbedtls_test_driver_mac_hooks.hits, 1 ); exit: psa_mac_abort( &operation ); psa_destroy_key( key ); PSA_DONE( ); - test_driver_mac_hooks = test_driver_mac_hooks_init(); + mbedtls_test_driver_mac_hooks = mbedtls_test_driver_mac_hooks_init(); } /* END_CASE */