Test restarting after creating a key in a specific slot

This commit is contained in:
Gilles Peskine 2019-08-05 14:59:15 +02:00
parent 46d9439a5e
commit 0a1104474b
2 changed files with 28 additions and 12 deletions

View file

@ -40,13 +40,19 @@ SE key import-export, check after restart (slot 3)
key_creation_import_export:3:1
Key creation in a specific slot (0)
key_creation_in_chosen_slot:0:PSA_SUCCESS
key_creation_in_chosen_slot:0:0:PSA_SUCCESS
Key creation in a specific slot (max)
key_creation_in_chosen_slot:ARRAY_LENGTH( ram_slots ) - 1:PSA_SUCCESS
key_creation_in_chosen_slot:ARRAY_LENGTH( ram_slots ) - 1:0:PSA_SUCCESS
Key creation in a specific slot (0, restart)
key_creation_in_chosen_slot:0:1:PSA_SUCCESS
Key creation in a specific slot (max, restart)
key_creation_in_chosen_slot:ARRAY_LENGTH( ram_slots ) - 1:1:PSA_SUCCESS
Key creation in a specific slot (too large)
key_creation_in_chosen_slot:ARRAY_LENGTH( ram_slots ):PSA_ERROR_INVALID_ARGUMENT
key_creation_in_chosen_slot:ARRAY_LENGTH( ram_slots ):0:PSA_ERROR_INVALID_ARGUMENT
Key creation smoke test: AES-CTR
key_creation_smoke:PSA_KEY_TYPE_AES:PSA_ALG_CTR:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

View file

@ -550,6 +550,7 @@ exit:
/* BEGIN_CASE */
void key_creation_in_chosen_slot( int slot_arg,
int restart,
int expected_status_arg )
{
psa_key_slot_number_t wanted_slot = slot_arg;
@ -587,18 +588,27 @@ void key_creation_in_chosen_slot( int slot_arg,
&handle );
TEST_EQUAL( status, expected_status );
if( status == PSA_SUCCESS )
if( status != PSA_SUCCESS )
goto exit;
/* Maybe restart, to check that the information is saved correctly. */
if( restart )
{
/* Test that the key was created in the expected slot. */
TEST_EQUAL( ram_slots[wanted_slot].type, PSA_KEY_TYPE_RAW_DATA );
/* Test that the key is reported with the correct attributes,
* including the expected slot. */
PSA_ASSERT( psa_get_key_attributes( handle, &attributes ) );
PSA_ASSERT( psa_destroy_key( handle ) );
mbedtls_psa_crypto_free( );
PSA_ASSERT( psa_register_se_driver( lifetime, &driver ) );
PSA_ASSERT( psa_crypto_init( ) );
PSA_ASSERT( psa_open_key( id, &handle ) );
}
/* Test that the key was created in the expected slot. */
TEST_EQUAL( ram_slots[wanted_slot].type, PSA_KEY_TYPE_RAW_DATA );
/* Test that the key is reported with the correct attributes,
* including the expected slot. */
PSA_ASSERT( psa_get_key_attributes( handle, &attributes ) );
PSA_ASSERT( psa_destroy_key( handle ) );
exit:
PSA_DONE( );
ram_slots_reset( );