Cosmetic improvements in SE driver tests

This commit is contained in:
Gilles Peskine 2019-07-24 13:44:03 +02:00
parent 28f8f3068f
commit 89870eb123
2 changed files with 35 additions and 17 deletions

View File

@ -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

View File

@ -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;