Rename functions that inject key material to an allocated handle
This commit starts a migration to a new interface for key creation.
Today, the application allocates a handle, then fills its metadata,
and finally injects key material. The new interface fills metadata
into a temporary structure, and a handle is allocated at the same time
it gets filled with both metadata and key material.
This commit was obtained by moving the declaration of the old-style
functions to crypto_extra.h and renaming them with the to_handle
suffix, adding declarations for the new-style functions in crypto.h
under their new name, and running
perl -i -pe 's/\bpsa_(import|copy|generator_import|generate)_key\b/$&_to_handle/g' library/*.c tests/suites/*.function programs/psa/*.c
perl -i -pe 's/\bpsa_get_key_lifetime\b/$&_from_handle/g' library/*.c tests/suites/*.function programs/psa/*.c
Many functions that are specific to the old interface, and which will
not remain under the same name with the new interface, are still in
crypto.h for now.
All functional tests should still pass. The documentation may have
some broken links.
diff --git a/tests/suites/test_suite_pk.function b/tests/suites/test_suite_pk.function
index d85d9ed..7415b63 100644
--- a/tests/suites/test_suite_pk.function
+++ b/tests/suites/test_suite_pk.function
@@ -97,7 +97,7 @@
return( PK_PSA_INVALID_SLOT );
/* generate key */
- if( PSA_SUCCESS != psa_generate_key( key, type, bits, NULL, 0 ) )
+ if( PSA_SUCCESS != psa_generate_key_to_handle( key, type, bits, NULL, 0 ) )
return( PK_PSA_INVALID_SLOT );
return( key );
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index e017364..7972597 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -216,7 +216,7 @@
PSA_ASSERT( psa_allocate_key( &handle ) );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_SIGN, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type, key_bytes, key_length ) );
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type, key_bytes, key_length ) );
*status = psa_mac_sign_setup( operation, handle, alg );
/* Whether setup succeeded or failed, abort must succeed. */
@@ -250,7 +250,7 @@
PSA_ASSERT( psa_allocate_key( &handle ) );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type, key_bytes, key_length ) );
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type, key_bytes, key_length ) );
*status = psa_cipher_encrypt_setup( operation, handle, alg );
/* Whether setup succeeded or failed, abort must succeed. */
@@ -1118,7 +1118,7 @@
PSA_ASSERT( psa_crypto_init( ) );
PSA_ASSERT( psa_allocate_key( &handle ) );
- status = psa_import_key( handle, type, data->x, data->len );
+ status = psa_import_key_to_handle( handle, type, data->x, data->len );
TEST_EQUAL( status, expected_status );
if( status == PSA_SUCCESS )
PSA_ASSERT( psa_destroy_key( handle ) );
@@ -1151,9 +1151,9 @@
psa_key_policy_set_usage( &policy, usage, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- status = psa_import_key( handle, type1, data1->x, data1->len );
+ status = psa_import_key_to_handle( handle, type1, data1->x, data1->len );
TEST_EQUAL( status, expected_import1_status );
- status = psa_import_key( handle, type2, data2->x, data2->len );
+ status = psa_import_key_to_handle( handle, type2, data2->x, data2->len );
TEST_EQUAL( status, expected_import2_status );
if( expected_import1_status == PSA_SUCCESS ||
@@ -1193,7 +1193,7 @@
/* Try importing the key */
PSA_ASSERT( psa_allocate_key( &handle ) );
- status = psa_import_key( handle, type, p, length );
+ status = psa_import_key_to_handle( handle, type, p, length );
TEST_EQUAL( status, expected_status );
if( status == PSA_SUCCESS )
PSA_ASSERT( psa_destroy_key( handle ) );
@@ -1242,7 +1242,7 @@
PSA_ERROR_DOES_NOT_EXIST );
/* Import the key */
- PSA_ASSERT( psa_import_key( handle, type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, type,
data->x, data->len ) );
/* Test the key information */
@@ -1283,7 +1283,7 @@
PSA_ASSERT( psa_allocate_key( &handle2 ) );
PSA_ASSERT( psa_set_key_policy( handle2, &policy ) );
- PSA_ASSERT( psa_import_key( handle2, type,
+ PSA_ASSERT( psa_import_key_to_handle( handle2, type,
exported,
exported_length ) );
PSA_ASSERT( psa_export_key( handle2,
@@ -1321,11 +1321,11 @@
PSA_ASSERT( psa_allocate_key( &handle ) );
/* Import the key */
- PSA_ASSERT( psa_import_key( handle, type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, type,
data, sizeof( data ) ) );
/* Import the key again */
- status = psa_import_key( handle, type, data, sizeof( data ) );
+ status = psa_import_key_to_handle( handle, type, data, sizeof( data ) );
TEST_EQUAL( status, PSA_ERROR_ALREADY_EXISTS );
exit:
@@ -1424,7 +1424,7 @@
PSA_ASSERT( psa_allocate_key( &handle ) );
/* Import the key - expect failure */
- status = psa_import_key( handle, type,
+ status = psa_import_key_to_handle( handle, type,
data->x, data->len );
TEST_EQUAL( status, expected_import_status );
@@ -1455,7 +1455,7 @@
PSA_ASSERT( psa_allocate_key( &handle ) );
/* Import the key - expect failure */
- status = psa_import_key( handle, type,
+ status = psa_import_key_to_handle( handle, type,
data->x, data->len );
TEST_EQUAL( status, expected_import_status );
@@ -1489,7 +1489,7 @@
ASSERT_ALLOC( exported, export_size );
/* Import the key */
- PSA_ASSERT( psa_import_key( handle, type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, type,
data->x, data->len ) );
PSA_ASSERT( psa_export_key( handle, exported, export_size,
@@ -1534,7 +1534,7 @@
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
/* Import the key */
- PSA_ASSERT( psa_import_key( handle, type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, type,
data->x, data->len ) );
/* Export the public key */
@@ -1584,7 +1584,7 @@
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
/* Import the key */
- status = psa_import_key( handle, type, data->x, data->len );
+ status = psa_import_key_to_handle( handle, type, data->x, data->len );
PSA_ASSERT( status );
/* Test the key information */
@@ -1626,7 +1626,7 @@
TEST_EQUAL( psa_key_policy_get_algorithm( &policy_set ), alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy_set ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key, sizeof( key ) ) );
PSA_ASSERT( psa_get_key_policy( handle, &policy_get ) );
@@ -1684,7 +1684,7 @@
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x, key_data->len ) );
status = psa_mac_sign_setup( &operation, handle, exercise_alg );
@@ -1728,7 +1728,7 @@
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x, key_data->len ) );
status = psa_cipher_encrypt_setup( &operation, handle, exercise_alg );
@@ -1780,7 +1780,7 @@
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x, key_data->len ) );
status = psa_aead_encrypt( handle, exercise_alg,
@@ -1835,7 +1835,7 @@
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x, key_data->len ) );
PSA_ASSERT( psa_get_key_information( handle,
@@ -1903,7 +1903,7 @@
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x, key_data->len ) );
status = psa_asymmetric_sign( handle, exercise_alg,
@@ -1948,7 +1948,7 @@
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x, key_data->len ) );
status = psa_key_derivation( &generator, handle,
@@ -1988,7 +1988,7 @@
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x, key_data->len ) );
PSA_ASSERT( psa_key_derivation_setup( &generator, exercise_alg ) );
@@ -2026,7 +2026,7 @@
psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x, key_data->len ) );
status = raw_key_agreement_with_self( exercise_alg, handle );
@@ -2084,7 +2084,7 @@
PSA_ASSERT( psa_allocate_key( &source_handle ) );
psa_key_policy_set_usage( &source_policy, source_usage, source_alg );
PSA_ASSERT( psa_set_key_policy( source_handle, &source_policy ) );
- PSA_ASSERT( psa_import_key( source_handle, source_type,
+ PSA_ASSERT( psa_import_key_to_handle( source_handle, source_type,
material->x, material->len ) );
PSA_ASSERT( psa_get_key_information( source_handle, NULL, &source_bits ) );
@@ -2095,7 +2095,7 @@
target_policy = psa_key_policy_init();
/* Copy the key. */
- PSA_ASSERT( psa_copy_key( source_handle, target_handle, p_constraint ) );
+ PSA_ASSERT( psa_copy_key_to_handle( source_handle, target_handle, p_constraint ) );
/* Destroy the source to ensure that this doesn't affect the target. */
PSA_ASSERT( psa_destroy_key( source_handle ) );
@@ -2170,7 +2170,7 @@
PSA_ASSERT( psa_allocate_key( &source_handle ) );
psa_key_policy_set_usage( &source_policy, source_usage, source_alg );
PSA_ASSERT( psa_set_key_policy( source_handle, &source_policy ) );
- PSA_ASSERT( psa_import_key( source_handle, source_type,
+ PSA_ASSERT( psa_import_key_to_handle( source_handle, source_type,
material->x, material->len ) );
PSA_ASSERT( psa_get_key_information( source_handle, NULL, &source_bits ) );
@@ -2181,7 +2181,7 @@
target_policy = psa_key_policy_init();
/* Copy the key. */
- TEST_EQUAL( psa_copy_key( source_handle, target_handle, p_constraint ),
+ TEST_EQUAL( psa_copy_key_to_handle( source_handle, target_handle, p_constraint ),
expected_status );
/* Test that the target slot is unaffected. */
@@ -2588,7 +2588,7 @@
alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key, sizeof(key) ) );
/* Call update without calling setup beforehand. */
@@ -2715,7 +2715,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_SIGN, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key->x, key->len ) );
/* Calculate the MAC. */
@@ -2762,7 +2762,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_VERIFY, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key->x, key->len ) );
PSA_ASSERT( psa_mac_verify_setup( &operation,
@@ -2882,7 +2882,7 @@
PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT,
alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key, sizeof(key) ) );
@@ -3040,7 +3040,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key->x, key->len ) );
PSA_ASSERT( psa_cipher_encrypt_setup( &operation,
@@ -3110,7 +3110,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key->x, key->len ) );
PSA_ASSERT( psa_cipher_encrypt_setup( &operation,
@@ -3186,7 +3186,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key->x, key->len ) );
PSA_ASSERT( psa_cipher_decrypt_setup( &operation,
@@ -3260,7 +3260,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key->x, key->len ) );
PSA_ASSERT( psa_cipher_decrypt_setup( &operation,
@@ -3327,7 +3327,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key->x, key->len ) );
PSA_ASSERT( psa_cipher_encrypt_setup( &operation1,
@@ -3413,7 +3413,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key->x, key->len ) );
PSA_ASSERT( psa_cipher_encrypt_setup( &operation1,
@@ -3517,7 +3517,7 @@
alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x, key_data->len ) );
TEST_EQUAL( psa_aead_encrypt( handle, alg,
@@ -3580,7 +3580,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT , alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x,
key_data->len ) );
@@ -3629,7 +3629,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT , alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x,
key_data->len ) );
@@ -3688,7 +3688,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_SIGN, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x,
key_data->len ) );
PSA_ASSERT( psa_get_key_information( handle,
@@ -3742,7 +3742,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_SIGN, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x,
key_data->len ) );
@@ -3785,7 +3785,7 @@
alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x,
key_data->len ) );
PSA_ASSERT( psa_get_key_information( handle,
@@ -3852,7 +3852,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_VERIFY, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x,
key_data->len ) );
@@ -3885,7 +3885,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_VERIFY, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x,
key_data->len ) );
@@ -3929,7 +3929,7 @@
PSA_ASSERT( psa_allocate_key( &handle ) );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x,
key_data->len ) );
@@ -3999,7 +3999,7 @@
alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x,
key_data->len ) );
@@ -4065,7 +4065,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x,
key_data->len ) );
@@ -4129,7 +4129,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x,
key_data->len ) );
@@ -4216,7 +4216,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data->x,
key_data->len ) );
@@ -4253,7 +4253,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, key_type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, key_type,
key_data,
sizeof( key_data ) ) );
@@ -4348,7 +4348,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, PSA_KEY_TYPE_DERIVE,
+ PSA_ASSERT( psa_import_key_to_handle( handle, PSA_KEY_TYPE_DERIVE,
key_data->x,
key_data->len ) );
@@ -4445,7 +4445,7 @@
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, PSA_KEY_TYPE_DERIVE,
+ PSA_ASSERT( psa_import_key_to_handle( handle, PSA_KEY_TYPE_DERIVE,
key_data->x,
key_data->len ) );
@@ -4533,7 +4533,7 @@
PSA_ASSERT( psa_allocate_key( &base_handle ) );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
PSA_ASSERT( psa_set_key_policy( base_handle, &policy ) );
- PSA_ASSERT( psa_import_key( base_handle, PSA_KEY_TYPE_DERIVE,
+ PSA_ASSERT( psa_import_key_to_handle( base_handle, PSA_KEY_TYPE_DERIVE,
key_data->x,
key_data->len ) );
@@ -4545,7 +4545,7 @@
PSA_ASSERT( psa_allocate_key( &derived_handle ) );
psa_key_policy_set_usage( &policy, derived_usage, derived_alg );
PSA_ASSERT( psa_set_key_policy( derived_handle, &policy ) );
- PSA_ASSERT( psa_generator_import_key( derived_handle,
+ PSA_ASSERT( psa_generator_import_key_to_handle( derived_handle,
derived_type,
derived_bits,
&generator ) );
@@ -4597,7 +4597,7 @@
PSA_ASSERT( psa_allocate_key( &base_handle ) );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
PSA_ASSERT( psa_set_key_policy( base_handle, &policy ) );
- PSA_ASSERT( psa_import_key( base_handle, PSA_KEY_TYPE_DERIVE,
+ PSA_ASSERT( psa_import_key_to_handle( base_handle, PSA_KEY_TYPE_DERIVE,
key_data->x,
key_data->len ) );
@@ -4619,7 +4619,7 @@
PSA_ASSERT( psa_allocate_key( &derived_handle ) );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_EXPORT, 0 );
PSA_ASSERT( psa_set_key_policy( derived_handle, &policy ) );
- PSA_ASSERT( psa_generator_import_key( derived_handle,
+ PSA_ASSERT( psa_generator_import_key_to_handle( derived_handle,
PSA_KEY_TYPE_RAW_DATA,
derived_bits,
&generator ) );
@@ -4630,7 +4630,7 @@
PSA_ASSERT( psa_destroy_key( derived_handle ) );
PSA_ASSERT( psa_allocate_key( &derived_handle ) );
PSA_ASSERT( psa_set_key_policy( derived_handle, &policy ) );
- PSA_ASSERT( psa_generator_import_key( derived_handle,
+ PSA_ASSERT( psa_generator_import_key_to_handle( derived_handle,
PSA_KEY_TYPE_RAW_DATA,
PSA_BYTES_TO_BITS( bytes2 ),
&generator ) );
@@ -4672,7 +4672,7 @@
PSA_ASSERT( psa_allocate_key( &our_key ) );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
PSA_ASSERT( psa_set_key_policy( our_key, &policy ) );
- PSA_ASSERT( psa_import_key( our_key, our_key_type,
+ PSA_ASSERT( psa_import_key_to_handle( our_key, our_key_type,
our_key_data->x,
our_key_data->len ) );
@@ -4719,7 +4719,7 @@
PSA_ASSERT( psa_allocate_key( &our_key ) );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
PSA_ASSERT( psa_set_key_policy( our_key, &policy ) );
- PSA_ASSERT( psa_import_key( our_key, our_key_type,
+ PSA_ASSERT( psa_import_key_to_handle( our_key, our_key_type,
our_key_data->x,
our_key_data->len ) );
@@ -4756,7 +4756,7 @@
PSA_ASSERT( psa_allocate_key( &our_key ) );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
PSA_ASSERT( psa_set_key_policy( our_key, &policy ) );
- PSA_ASSERT( psa_import_key( our_key, our_key_type,
+ PSA_ASSERT( psa_import_key_to_handle( our_key, our_key_type,
our_key_data->x,
our_key_data->len ) );
@@ -4817,7 +4817,7 @@
PSA_ASSERT( psa_allocate_key( &our_key ) );
psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
PSA_ASSERT( psa_set_key_policy( our_key, &policy ) );
- PSA_ASSERT( psa_import_key( our_key, our_key_type,
+ PSA_ASSERT( psa_import_key_to_handle( our_key, our_key_type,
our_key_data->x,
our_key_data->len ) );
@@ -4932,7 +4932,7 @@
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
/* Generate a key */
- TEST_EQUAL( psa_generate_key( handle, type, bits, NULL, 0 ),
+ TEST_EQUAL( psa_generate_key_to_handle( handle, type, bits, NULL, 0 ),
expected_status );
/* Test the key information */
@@ -4992,13 +4992,13 @@
{
case IMPORT_KEY:
/* Import the key */
- PSA_ASSERT( psa_import_key( handle, type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, type,
data->x, data->len ) );
break;
case GENERATE_KEY:
/* Generate a key */
- PSA_ASSERT( psa_generate_key( handle, type, bits,
+ PSA_ASSERT( psa_generate_key_to_handle( handle, type, bits,
NULL, 0 ) );
break;
@@ -5009,14 +5009,14 @@
base_policy_alg );
PSA_ASSERT( psa_set_key_policy(
base_key, &base_policy_set ) );
- PSA_ASSERT( psa_import_key( base_key, PSA_KEY_TYPE_DERIVE,
+ PSA_ASSERT( psa_import_key_to_handle( base_key, PSA_KEY_TYPE_DERIVE,
data->x, data->len ) );
/* Derive a key. */
PSA_ASSERT( psa_key_derivation( &generator, base_key,
base_policy_alg,
NULL, 0, NULL, 0,
export_size ) );
- PSA_ASSERT( psa_generator_import_key(
+ PSA_ASSERT( psa_generator_import_key_to_handle(
handle, PSA_KEY_TYPE_RAW_DATA,
bits, &generator ) );
break;
diff --git a/tests/suites/test_suite_psa_crypto_init.function b/tests/suites/test_suite_psa_crypto_init.function
index c8f6e1b..9f464ac 100644
--- a/tests/suites/test_suite_psa_crypto_init.function
+++ b/tests/suites/test_suite_psa_crypto_init.function
@@ -189,7 +189,7 @@
PSA_ASSERT( status );
mbedtls_psa_crypto_free( );
}
- status = psa_import_key( 1, PSA_KEY_TYPE_RAW_DATA, data, sizeof( data ) );
+ status = psa_import_key_to_handle( 1, PSA_KEY_TYPE_RAW_DATA, data, sizeof( data ) );
TEST_EQUAL( status, PSA_ERROR_BAD_STATE );
}
/* END_CASE */
diff --git a/tests/suites/test_suite_psa_crypto_persistent_key.function b/tests/suites/test_suite_psa_crypto_persistent_key.function
index 90e10f6..245eeef 100644
--- a/tests/suites/test_suite_psa_crypto_persistent_key.function
+++ b/tests/suites/test_suite_psa_crypto_persistent_key.function
@@ -98,7 +98,7 @@
PSA_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
&handle ) );
- TEST_EQUAL( psa_import_key( handle, PSA_KEY_TYPE_RAW_DATA,
+ TEST_EQUAL( psa_import_key_to_handle( handle, PSA_KEY_TYPE_RAW_DATA,
data, data_length ),
expected_status );
@@ -126,7 +126,7 @@
if( should_store == 1 )
{
- PSA_ASSERT( psa_import_key(
+ PSA_ASSERT( psa_import_key_to_handle(
handle, first_type,
first_data->x, first_data->len ) );
}
@@ -147,7 +147,7 @@
/* Create another key in the same slot */
PSA_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
&handle ) );
- PSA_ASSERT( psa_import_key(
+ PSA_ASSERT( psa_import_key_to_handle(
handle, second_type,
second_data->x, second_data->len ) );
@@ -170,7 +170,7 @@
PSA_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, key_id,
&handle ) );
- TEST_EQUAL( psa_import_key( handle, type, data->x, data->len ),
+ TEST_EQUAL( psa_import_key_to_handle( handle, type, data->x, data->len ),
expected_status );
if( expected_status != PSA_SUCCESS )
@@ -179,7 +179,7 @@
goto exit;
}
- PSA_ASSERT( psa_get_key_lifetime( handle, &lifetime ) );
+ PSA_ASSERT( psa_get_key_lifetime_from_handle( handle, &lifetime ) );
TEST_EQUAL( lifetime, PSA_KEY_LIFETIME_PERSISTENT );
exit:
@@ -215,10 +215,10 @@
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
/* Import the key */
- PSA_ASSERT( psa_import_key( handle, type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, type,
data->x, data->len ) );
- PSA_ASSERT( psa_get_key_lifetime( handle, &lifetime_get ) );
+ PSA_ASSERT( psa_get_key_lifetime_from_handle( handle, &lifetime_get ) );
TEST_EQUAL( lifetime_get, PSA_KEY_LIFETIME_PERSISTENT );
/* Test the key information */
diff --git a/tests/suites/test_suite_psa_crypto_slot_management.function b/tests/suites/test_suite_psa_crypto_slot_management.function
index 0278b88..e393743 100644
--- a/tests/suites/test_suite_psa_crypto_slot_management.function
+++ b/tests/suites/test_suite_psa_crypto_slot_management.function
@@ -84,7 +84,7 @@
TEST_ASSERT( handle != 0 );
psa_key_policy_set_usage( &policy, usage_flags, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, type, key_data->x, key_data->len ) );
+ PSA_ASSERT( psa_import_key_to_handle( handle, type, key_data->x, key_data->len ) );
PSA_ASSERT( psa_get_key_information( handle, &read_type, NULL ) );
TEST_EQUAL( read_type, type );
@@ -137,7 +137,7 @@
TEST_ASSERT( handle != 0 );
psa_key_policy_set_usage( &policy, usage_flags, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, type, key_data->x, key_data->len ) );
+ PSA_ASSERT( psa_import_key_to_handle( handle, type, key_data->x, key_data->len ) );
PSA_ASSERT( psa_get_key_information( handle, &read_type, NULL ) );
TEST_EQUAL( read_type, type );
@@ -215,7 +215,7 @@
TEST_ASSERT( handle1 != 0 );
psa_key_policy_set_usage( &policy1, PSA_KEY_USAGE_EXPORT, 0 );
PSA_ASSERT( psa_set_key_policy( handle1, &policy1 ) );
- PSA_ASSERT( psa_import_key( handle1, type1,
+ PSA_ASSERT( psa_import_key_to_handle( handle1, type1,
material1, sizeof( material1 ) ) );
if( reopen_policy == CLOSE_BEFORE )
@@ -334,7 +334,7 @@
&source_handle ) );
psa_key_policy_set_usage( &source_policy, source_usage, source_alg );
PSA_ASSERT( psa_set_key_policy( source_handle, &source_policy ) );
- PSA_ASSERT( psa_import_key( source_handle, source_type,
+ PSA_ASSERT( psa_import_key_to_handle( source_handle, source_type,
material->x, material->len ) );
PSA_ASSERT( psa_get_key_information( source_handle, NULL, &source_bits ) );
@@ -349,7 +349,7 @@
target_policy = psa_key_policy_init();
/* Copy the key. */
- PSA_ASSERT( psa_copy_key( source_handle, target_handle, NULL ) );
+ PSA_ASSERT( psa_copy_key_to_handle( source_handle, target_handle, NULL ) );
/* Destroy the source to ensure that this doesn't affect the target. */
PSA_ASSERT( psa_destroy_key( source_handle ) );
@@ -435,7 +435,7 @@
PSA_ASSERT( psa_set_key_policy( target_handle, &target_policy ) );
/* Copy the key. */
- TEST_EQUAL( psa_copy_key( source_handle, target_handle, NULL ),
+ TEST_EQUAL( psa_copy_key_to_handle( source_handle, target_handle, NULL ),
PSA_ERROR_DOES_NOT_EXIST );
/* Test that the slots are unaffected. */
@@ -496,7 +496,7 @@
&source_handle ) );
psa_key_policy_set_usage( &source_policy, source_usage, source_alg );
PSA_ASSERT( psa_set_key_policy( source_handle, &source_policy ) );
- PSA_ASSERT( psa_import_key( source_handle, source_type,
+ PSA_ASSERT( psa_import_key_to_handle( source_handle, source_type,
source_material->x, source_material->len ) );
PSA_ASSERT( psa_get_key_information( source_handle, NULL, &source_bits ) );
@@ -508,12 +508,12 @@
&target_handle ) );
psa_key_policy_set_usage( &target_policy, target_usage, target_alg );
PSA_ASSERT( psa_set_key_policy( target_handle, &target_policy ) );
- PSA_ASSERT( psa_import_key( target_handle, target_type,
+ PSA_ASSERT( psa_import_key_to_handle( target_handle, target_type,
target_material->x, target_material->len ) );
PSA_ASSERT( psa_get_key_information( target_handle, NULL, &target_bits ) );
/* Copy the key. */
- TEST_EQUAL( psa_copy_key( source_handle, target_handle, NULL ),
+ TEST_EQUAL( psa_copy_key_to_handle( source_handle, target_handle, NULL ),
PSA_ERROR_ALREADY_EXISTS );
/* Test that the target slot is unaffected. */
@@ -573,12 +573,12 @@
&handle ) );
psa_key_policy_set_usage( &policy, usage, alg );
PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
- PSA_ASSERT( psa_import_key( handle, type,
+ PSA_ASSERT( psa_import_key_to_handle( handle, type,
material->x, material->len ) );
PSA_ASSERT( psa_get_key_information( handle, NULL, &bits ) );
/* Copy the key. */
- TEST_EQUAL( psa_copy_key( handle, handle, NULL ),
+ TEST_EQUAL( psa_copy_key_to_handle( handle, handle, NULL ),
PSA_ERROR_ALREADY_EXISTS );
/* Test that the slot is unaffected. */
@@ -624,7 +624,7 @@
TEST_ASSERT( handle1 != 0 );
psa_key_policy_set_usage( &policy, 0, 0 );
PSA_ASSERT( psa_set_key_policy( handle1, &policy ) );
- PSA_ASSERT( psa_import_key( handle1, PSA_KEY_TYPE_RAW_DATA,
+ PSA_ASSERT( psa_import_key_to_handle( handle1, PSA_KEY_TYPE_RAW_DATA,
material, sizeof( material ) ) );
/* Attempt to close and destroy some invalid handles. */
@@ -671,7 +671,7 @@
for( j = 0; j < i; j++ )
TEST_ASSERT( handles[i] != handles[j] );
PSA_ASSERT( psa_set_key_policy( handles[i], &policy ) );
- PSA_ASSERT( psa_import_key( handles[i], PSA_KEY_TYPE_RAW_DATA,
+ PSA_ASSERT( psa_import_key_to_handle( handles[i], PSA_KEY_TYPE_RAW_DATA,
(uint8_t *) &i, sizeof( i ) ) );
}
max_handles = i;