From d0c6a84dca35f1d0765c75ca526899b8e5140a1a Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Fri, 4 Feb 2022 09:05:50 -0500 Subject: [PATCH] Test driver: keep variable declarations first Followed by hook calls, and sanity checks last. Signed-off-by: Andrzej Kurek --- tests/src/drivers/test_driver_key_management.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/src/drivers/test_driver_key_management.c b/tests/src/drivers/test_driver_key_management.c index 5b3bab616..89cb8b909 100644 --- a/tests/src/drivers/test_driver_key_management.c +++ b/tests/src/drivers/test_driver_key_management.c @@ -169,14 +169,14 @@ psa_status_t mbedtls_test_transparent_import_key( size_t *key_buffer_length, size_t *bits) { + psa_key_type_t type = psa_get_key_type( attributes ); + ++mbedtls_test_driver_key_management_hooks.hits; mbedtls_test_driver_key_management_hooks.location = PSA_KEY_LOCATION_LOCAL_STORAGE; if( mbedtls_test_driver_key_management_hooks.forced_status != PSA_SUCCESS ) return( mbedtls_test_driver_key_management_hooks.forced_status ); - psa_key_type_t type = psa_get_key_type( attributes ); - if( PSA_KEY_TYPE_IS_ECC( type ) ) { #if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \ @@ -232,15 +232,15 @@ psa_status_t mbedtls_test_opaque_export_key( const uint8_t *key, size_t key_length, uint8_t *data, size_t data_size, size_t *data_length ) { + /* Assume this is a builtin key based on the key material length. */ + psa_drv_slot_number_t slot_number = *( ( psa_drv_slot_number_t* ) key ); + if( key_length != sizeof( psa_drv_slot_number_t ) ) { /* Test driver does not support generic opaque key handling yet. */ return( PSA_ERROR_NOT_SUPPORTED ); } - /* Assume this is a builtin key based on the key material length. */ - psa_drv_slot_number_t slot_number = *( ( psa_drv_slot_number_t* ) key ); - switch( slot_number ) { case PSA_CRYPTO_TEST_DRIVER_BUILTIN_ECDSA_KEY_SLOT: