From 89870eb1238159abaaec84bc8a01f06a463a6639 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 24 Jul 2019 13:44:03 +0200 Subject: [PATCH] Cosmetic improvements in SE driver tests --- .../test_suite_psa_crypto_se_driver_hal.data | 8 ++-- ...st_suite_psa_crypto_se_driver_hal.function | 44 +++++++++++++------ 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto_se_driver_hal.data b/tests/suites/test_suite_psa_crypto_se_driver_hal.data index cb21ab549..e9c069477 100644 --- a/tests/suites/test_suite_psa_crypto_se_driver_hal.data +++ b/tests/suites/test_suite_psa_crypto_se_driver_hal.data @@ -27,14 +27,14 @@ register_twice:3 Register SE driver: maximum number of drivers register_max: -Key creation smoke test (p_allocate allows all slots) +SE key import-export (p_allocate allows all slots) key_creation_import_export:0:0 -Key creation smoke test (p_allocate allows 1 slot) +SE key import-export (p_allocate allows 1 slot) key_creation_import_export:ARRAY_LENGTH( ram_slots ) - 1:0 -Key creation smoke test, check after restart (slot 0) +SE key import-export, check after restart (slot 0) key_creation_import_export:0:1 -Key creation smoke test, check after restart (slot 3) +SE key import-export, check after restart (slot 3) key_creation_import_export:3:1 diff --git a/tests/suites/test_suite_psa_crypto_se_driver_hal.function b/tests/suites/test_suite_psa_crypto_se_driver_hal.function index 010f69684..661fb054f 100644 --- a/tests/suites/test_suite_psa_crypto_se_driver_hal.function +++ b/tests/suites/test_suite_psa_crypto_se_driver_hal.function @@ -5,6 +5,12 @@ #include "psa_crypto_se.h" #include "psa_crypto_storage.h" + + +/****************************************************************/ +/* Test driver helpers */ +/****************************************************************/ + /** The minimum valid lifetime value for a secure element driver. */ #define MIN_DRIVER_LIFETIME 2 @@ -25,6 +31,12 @@ } \ } while( 0 ) + + +/****************************************************************/ +/* RAM-based test driver */ +/****************************************************************/ + #define RAM_MAX_KEY_SIZE 64 typedef struct { @@ -69,11 +81,11 @@ static psa_status_t ram_import( psa_drv_se_context_t *context, return( PSA_SUCCESS ); } -psa_status_t ram_export( psa_drv_se_context_t *context, - psa_key_slot_number_t slot_number, - uint8_t *p_data, - size_t data_size, - size_t *p_data_length ) +static psa_status_t ram_export( psa_drv_se_context_t *context, + psa_key_slot_number_t slot_number, + uint8_t *p_data, + size_t data_size, + size_t *p_data_length ) { size_t actual_size; (void) context; @@ -86,9 +98,9 @@ psa_status_t ram_export( psa_drv_se_context_t *context, return( PSA_SUCCESS ); } -psa_status_t ram_destroy( psa_drv_se_context_t *context, - void *persistent_data, - psa_key_slot_number_t slot_number ) +static psa_status_t ram_destroy( psa_drv_se_context_t *context, + void *persistent_data, + psa_key_slot_number_t slot_number ) { ram_slot_usage_t *slot_usage = persistent_data; DRIVER_ASSERT( context->persistent_data_size == sizeof( ram_slot_usage_t ) ); @@ -98,10 +110,10 @@ psa_status_t ram_destroy( psa_drv_se_context_t *context, return( PSA_SUCCESS ); } -psa_status_t ram_allocate( psa_drv_se_context_t *context, - void *persistent_data, - const psa_key_attributes_t *attributes, - psa_key_slot_number_t *slot_number ) +static psa_status_t ram_allocate( psa_drv_se_context_t *context, + void *persistent_data, + const psa_key_attributes_t *attributes, + psa_key_slot_number_t *slot_number ) { ram_slot_usage_t *slot_usage = persistent_data; (void) attributes; @@ -116,8 +128,14 @@ psa_status_t ram_allocate( psa_drv_se_context_t *context, return( PSA_ERROR_INSUFFICIENT_STORAGE ); } + + +/****************************************************************/ +/* Other test helper functions */ +/****************************************************************/ + #define MAX_KEY_ID_FOR_TEST 10 -void psa_purge_storage( void ) +static void psa_purge_storage( void ) { psa_key_id_t id; psa_key_lifetime_t lifetime;