mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-27 02:04:21 +01:00
Update tests for other invalid key operations.
Update expected return values of psa_get_key_attributes(), psa_export_key() and other key api(s) to PSA_ERROR_INVALID_HANDLE for invalid key. Signed-off-by: Maulik Patel <Maulik.Patel@arm.com>
This commit is contained in:
parent
02a1750098
commit
3240c9d2ec
@ -205,7 +205,7 @@ static int test_operations_on_invalid_key( mbedtls_svc_key_id_t key )
|
||||
psa_set_key_algorithm( &attributes, PSA_ALG_CTR );
|
||||
psa_set_key_type( &attributes, PSA_KEY_TYPE_AES );
|
||||
TEST_EQUAL( psa_get_key_attributes( key, &attributes ),
|
||||
PSA_ERROR_DOES_NOT_EXIST );
|
||||
PSA_ERROR_INVALID_HANDLE );
|
||||
TEST_EQUAL(
|
||||
MBEDTLS_SVC_KEY_ID_GET_KEY_ID( psa_get_key_id( &attributes ) ), 0 );
|
||||
TEST_EQUAL(
|
||||
@ -217,10 +217,10 @@ static int test_operations_on_invalid_key( mbedtls_svc_key_id_t key )
|
||||
TEST_EQUAL( psa_get_key_bits( &attributes ), 0 );
|
||||
|
||||
TEST_EQUAL( psa_export_key( key, buffer, sizeof( buffer ), &length ),
|
||||
PSA_ERROR_DOES_NOT_EXIST );
|
||||
PSA_ERROR_INVALID_HANDLE );
|
||||
TEST_EQUAL( psa_export_public_key( key,
|
||||
buffer, sizeof( buffer ), &length ),
|
||||
PSA_ERROR_DOES_NOT_EXIST );
|
||||
PSA_ERROR_INVALID_HANDLE );
|
||||
|
||||
ok = 1;
|
||||
|
||||
|
@ -178,16 +178,16 @@ depends_on:MBEDTLS_PSA_CRYPTO_STORAGE_C
|
||||
copy_to_occupied:PSA_KEY_LIFETIME_PERSISTENT:1:PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_COPY:PSA_ALG_CTR:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f":PSA_KEY_LIFETIME_PERSISTENT:1:PSA_KEY_USAGE_EXPORT:PSA_ALG_CTR:PSA_KEY_TYPE_AES:"404142434445464748494a4b4c4d4e4f"
|
||||
|
||||
invalid handle: 0
|
||||
invalid_handle:INVALID_HANDLE_0:PSA_SUCCESS:PSA_ERROR_INVALID_HANDLE
|
||||
invalid_handle:INVALID_HANDLE_0:PSA_SUCCESS
|
||||
|
||||
invalid handle: never opened
|
||||
invalid_handle:INVALID_HANDLE_UNOPENED:PSA_ERROR_DOES_NOT_EXIST:PSA_ERROR_DOES_NOT_EXIST
|
||||
invalid_handle:INVALID_HANDLE_UNOPENED:PSA_ERROR_INVALID_HANDLE
|
||||
|
||||
invalid handle: already closed
|
||||
invalid_handle:INVALID_HANDLE_CLOSED:PSA_ERROR_DOES_NOT_EXIST:PSA_ERROR_DOES_NOT_EXIST
|
||||
invalid_handle:INVALID_HANDLE_CLOSED:PSA_ERROR_INVALID_HANDLE
|
||||
|
||||
invalid handle: huge
|
||||
invalid_handle:INVALID_HANDLE_HUGE:PSA_ERROR_INVALID_HANDLE:PSA_ERROR_INVALID_HANDLE
|
||||
invalid_handle:INVALID_HANDLE_HUGE:PSA_ERROR_INVALID_HANDLE
|
||||
|
||||
Open many transient keys
|
||||
many_transient_keys:42
|
||||
|
@ -178,7 +178,7 @@ void transient_slot_lifecycle( int owner_id_arg,
|
||||
|
||||
/* Test that the key is now invalid. */
|
||||
TEST_EQUAL( psa_get_key_attributes( key, &attributes ),
|
||||
PSA_ERROR_DOES_NOT_EXIST );
|
||||
PSA_ERROR_INVALID_HANDLE );
|
||||
TEST_EQUAL( psa_close_key( key ), PSA_ERROR_INVALID_HANDLE );
|
||||
|
||||
exit:
|
||||
@ -326,10 +326,10 @@ void persistent_slot_lifecycle( int lifetime_arg, int owner_id_arg, int id_arg,
|
||||
* existing key.
|
||||
*/
|
||||
TEST_EQUAL( psa_get_key_attributes( handle, &read_attributes ),
|
||||
PSA_ERROR_DOES_NOT_EXIST );
|
||||
PSA_ERROR_INVALID_HANDLE );
|
||||
TEST_EQUAL( psa_close_key( handle ), PSA_ERROR_INVALID_HANDLE );
|
||||
TEST_EQUAL( psa_get_key_attributes( id, &read_attributes ),
|
||||
PSA_ERROR_DOES_NOT_EXIST );
|
||||
PSA_ERROR_INVALID_HANDLE );
|
||||
break;
|
||||
}
|
||||
|
||||
@ -728,13 +728,12 @@ exit:
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void invalid_handle( int handle_construction,
|
||||
int close_status_arg, int usage_status_arg )
|
||||
int close_status_arg )
|
||||
{
|
||||
psa_key_handle_t valid_handle = PSA_KEY_HANDLE_INIT;
|
||||
psa_key_handle_t invalid_handle = PSA_KEY_HANDLE_INIT;
|
||||
psa_key_id_t key_id;
|
||||
psa_status_t close_status = close_status_arg;
|
||||
psa_status_t usage_status = usage_status_arg;
|
||||
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||
uint8_t material[1] = "a";
|
||||
|
||||
@ -793,7 +792,7 @@ void invalid_handle( int handle_construction,
|
||||
|
||||
/* Attempt to use the invalid handle. */
|
||||
TEST_EQUAL( psa_get_key_attributes( invalid_handle, &attributes ),
|
||||
usage_status );
|
||||
PSA_ERROR_INVALID_HANDLE );
|
||||
TEST_EQUAL( psa_close_key( invalid_handle ), close_status );
|
||||
TEST_EQUAL( psa_destroy_key( invalid_handle ), close_status );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user