tests: Fix error codes when using "invalid" handles
As handles are now key identifiers, a handle may be valid now even if it does not refer to any key known to the library. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
2d52eb2f78
commit
432e19c7b2
3 changed files with 9 additions and 9 deletions
|
@ -1188,7 +1188,7 @@ static int test_operations_on_invalid_handle( psa_key_handle_t handle )
|
|||
psa_set_key_algorithm( &attributes, PSA_ALG_CTR );
|
||||
psa_set_key_type( &attributes, PSA_KEY_TYPE_AES );
|
||||
TEST_EQUAL( psa_get_key_attributes( handle, &attributes ),
|
||||
PSA_ERROR_INVALID_HANDLE );
|
||||
PSA_ERROR_DOES_NOT_EXIST );
|
||||
TEST_EQUAL(
|
||||
MBEDTLS_SVC_KEY_ID_GET_KEY_ID( psa_get_key_id( &attributes ) ), 0 );
|
||||
TEST_EQUAL(
|
||||
|
@ -1201,10 +1201,10 @@ static int test_operations_on_invalid_handle( psa_key_handle_t handle )
|
|||
|
||||
TEST_EQUAL( psa_export_key( handle,
|
||||
buffer, sizeof( buffer ), &length ),
|
||||
PSA_ERROR_INVALID_HANDLE );
|
||||
PSA_ERROR_DOES_NOT_EXIST );
|
||||
TEST_EQUAL( psa_export_public_key( handle,
|
||||
buffer, sizeof( buffer ), &length ),
|
||||
PSA_ERROR_INVALID_HANDLE );
|
||||
PSA_ERROR_DOES_NOT_EXIST );
|
||||
|
||||
ok = 1;
|
||||
|
||||
|
|
|
@ -156,10 +156,10 @@ invalid handle: 0
|
|||
invalid_handle:INVALID_HANDLE_0:PSA_SUCCESS:PSA_ERROR_INVALID_HANDLE
|
||||
|
||||
invalid handle: never opened
|
||||
invalid_handle:INVALID_HANDLE_UNOPENED:PSA_ERROR_INVALID_HANDLE:PSA_ERROR_INVALID_HANDLE
|
||||
invalid_handle:INVALID_HANDLE_UNOPENED:PSA_ERROR_DOES_NOT_EXIST:PSA_ERROR_DOES_NOT_EXIST
|
||||
|
||||
invalid handle: already closed
|
||||
invalid_handle:INVALID_HANDLE_CLOSED:PSA_ERROR_INVALID_HANDLE:PSA_ERROR_INVALID_HANDLE
|
||||
invalid_handle:INVALID_HANDLE_CLOSED:PSA_ERROR_DOES_NOT_EXIST:PSA_ERROR_DOES_NOT_EXIST
|
||||
|
||||
invalid handle: huge
|
||||
invalid_handle:INVALID_HANDLE_HUGE:PSA_ERROR_INVALID_HANDLE:PSA_ERROR_INVALID_HANDLE
|
||||
|
|
|
@ -165,8 +165,8 @@ void transient_slot_lifecycle( int usage_arg, int alg_arg,
|
|||
|
||||
/* Test that the handle is now invalid. */
|
||||
TEST_EQUAL( psa_get_key_attributes( handle, &attributes ),
|
||||
PSA_ERROR_INVALID_HANDLE );
|
||||
TEST_EQUAL( psa_close_key( handle ), PSA_ERROR_INVALID_HANDLE );
|
||||
PSA_ERROR_DOES_NOT_EXIST );
|
||||
TEST_EQUAL( psa_close_key( handle ), PSA_ERROR_DOES_NOT_EXIST );
|
||||
|
||||
exit:
|
||||
PSA_DONE( );
|
||||
|
@ -253,9 +253,9 @@ void persistent_slot_lifecycle( int lifetime_arg, int owner_id_arg, int id_arg,
|
|||
|
||||
/* Test that the handle is now invalid. */
|
||||
TEST_EQUAL( psa_get_key_attributes( handle, &read_attributes ),
|
||||
PSA_ERROR_INVALID_HANDLE );
|
||||
PSA_ERROR_DOES_NOT_EXIST );
|
||||
psa_reset_key_attributes( &read_attributes );
|
||||
TEST_EQUAL( psa_close_key( handle ), PSA_ERROR_INVALID_HANDLE );
|
||||
TEST_EQUAL( psa_close_key( handle ), PSA_ERROR_DOES_NOT_EXIST );
|
||||
|
||||
/* Try to reopen the key. If we destroyed it, check that it doesn't
|
||||
* exist. Otherwise check that it still exists and has the expected
|
||||
|
|
Loading…
Reference in a new issue