Add negative tests for psa_destroy_key

Test a non-existent key identifier in a valid range. Test identifiers
outside the valid range.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2021-04-21 20:09:23 +02:00
parent 87bc91c13b
commit fbb914f6e6
2 changed files with 24 additions and 0 deletions

View file

@ -119,3 +119,12 @@ import_export_persistent_key:"3082025e02010002818100af057d396ee84fb75fdbb5c2b13c
import/export-persistent symmetric key with restart: 16 bytes
depends_on:PSA_WANT_KEY_TYPE_AES:MBEDTLS_PK_C:MBEDTLS_PK_PARSE_C
import_export_persistent_key:"2b7e151628aed2a6abf7158809cf4f3c":PSA_KEY_TYPE_AES:128:1:0
Destroy invalid id: 0
destroy_nonexistent:0:PSA_SUCCESS
Destroy non-existent key
destroy_nonexistent:1:PSA_ERROR_INVALID_HANDLE
Destroy invalid id: 0xffffffff
destroy_nonexistent:0xffffffff:PSA_ERROR_INVALID_HANDLE

View file

@ -323,3 +323,18 @@ exit:
psa_destroy_persistent_key( key_id );
}
/* END_CASE */
/* BEGIN_CASE */
void destroy_nonexistent( int id_arg, int expected_status_arg )
{
mbedtls_svc_key_id_t id = mbedtls_svc_key_id_make( 1, id_arg );
psa_status_t expected_status = expected_status_arg;
PSA_INIT( );
TEST_EQUAL( expected_status, psa_destroy_key( id ) );
exit:
PSA_DONE( );
}
/* END_CASE */