Don't require a type and size when creating a key slot

Remove the type and bits arguments to psa_allocate_key() and
psa_create_key(). They can be useful if the implementation wants to
know exactly how much space to allocate for the slot, but many
implementations (including ours) don't care, and it's possible to work
around their lack by deferring size-dependent actions to the time when
the key material is created. They are a burden to applications and
make the API more complex, and the benefits aren't worth it.

Change the API and adapt the implementation, the units test and the
sample code accordingly.
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index 6916bf4..4891064 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -876,8 +876,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     status = psa_import_key( handle, type, data->x, data->len );
     TEST_EQUAL( status, expected_status );
     if( status == PSA_SUCCESS )
@@ -907,10 +906,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( type1,
-                                  MAX( KEY_BITS_FROM_DATA( type1, data1 ),
-                                       KEY_BITS_FROM_DATA( type2, data2 ) ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, usage, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -954,7 +950,7 @@
     length = ret;
 
     /* Try importing the key */
-    PSA_ASSERT( psa_allocate_key( type, bits, &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     status = psa_import_key( handle, type, p, length );
     TEST_EQUAL( status, expected_status );
     if( status == PSA_SUCCESS )
@@ -996,7 +992,7 @@
         ASSERT_ALLOC( reexported, export_size );
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( type, expected_bits, &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, usage_arg, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -1042,7 +1038,7 @@
     else
     {
         psa_key_handle_t handle2;
-        PSA_ASSERT( psa_allocate_key( type, expected_bits, &handle2 ) );
+        PSA_ASSERT( psa_allocate_key( &handle2 ) );
         PSA_ASSERT( psa_set_key_policy( handle2, &policy ) );
 
         PSA_ASSERT( psa_import_key( handle2, type,
@@ -1080,8 +1076,7 @@
     const uint8_t data[] = { 0x1, 0x2, 0x3, 0x4, 0x5 };
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( type, PSA_BYTES_TO_BITS( sizeof( data ) ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
 
     /* Import the key */
     PSA_ASSERT( psa_import_key( handle, type,
@@ -1131,8 +1126,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_RAW_DATA, 0,
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_EXPORT, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -1158,8 +1152,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_RAW_DATA, 0,
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT, exercise_alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -1186,8 +1179,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
 
     /* Import the key - expect failure */
     status = psa_import_key( handle, type,
@@ -1218,8 +1210,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
 
     /* Import the key - expect failure */
     status = psa_import_key( handle, type,
@@ -1249,8 +1240,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_EXPORT, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
     export_size = (ptrdiff_t) data->len;
@@ -1297,8 +1287,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_EXPORT, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -1348,8 +1337,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( type, KEY_BITS_FROM_DATA( type, data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, usage, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -1389,8 +1377,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( sizeof( key ) ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy_set, usage, alg );
 
     TEST_EQUAL( psa_key_policy_get_usage( &policy_set ), usage );
@@ -1451,9 +1438,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -1497,9 +1482,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -1551,9 +1534,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -1608,9 +1589,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -1672,9 +1651,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -1721,9 +1698,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -1763,9 +1738,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, policy_usage, policy_alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -1965,8 +1938,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy,
                               PSA_KEY_USAGE_SIGN | PSA_KEY_USAGE_VERIFY,
                               alg );
@@ -2011,8 +1983,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
-                                  &handle ) );
+    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 ) );
 
@@ -2059,8 +2030,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_VERIFY, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -2123,8 +2093,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
-                                  &handle ) );
+    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 ) );
 
@@ -2166,8 +2135,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
-                                  &handle ) );
+    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 ) );
 
@@ -2233,8 +2201,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
-                                  &handle ) );
+    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 ) );
 
@@ -2303,8 +2270,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -2375,8 +2341,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -2443,8 +2408,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -2528,8 +2492,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key->len ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -2631,8 +2594,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key_data->len ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy,
                               PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT,
                               alg );
@@ -2697,8 +2659,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key_data->len ),
-                                  &handle ) );
+    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 ) );
 
@@ -2747,8 +2708,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key_data->len ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT , alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -2807,9 +2767,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    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 ) );
 
@@ -2863,9 +2821,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    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 ) );
 
@@ -2906,9 +2862,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy,
                               PSA_KEY_USAGE_SIGN | PSA_KEY_USAGE_VERIFY,
                               alg );
@@ -2977,9 +2931,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_VERIFY, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -3012,9 +2964,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_VERIFY, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -3059,9 +3009,7 @@
     PSA_ASSERT( psa_crypto_init( ) );
 
     /* Import the key */
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    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,
@@ -3128,9 +3076,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy,
                               PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT,
                               alg );
@@ -3198,9 +3144,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -3264,9 +3208,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  KEY_BITS_FROM_DATA( key_type, key_data ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DECRYPT, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -3349,8 +3291,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type, PSA_BYTES_TO_BITS( key_data->len ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -3387,9 +3328,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( key_type,
-                                  PSA_BYTES_TO_BITS( sizeof( key_data ) ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -3484,9 +3423,7 @@
     ASSERT_ALLOC( output_buffer, output_buffer_size );
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
-                                  PSA_BYTES_TO_BITS( key_data->len ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -3564,9 +3501,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
-                                  PSA_BYTES_TO_BITS( key_data->len ),
-                                  &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, PSA_KEY_USAGE_DERIVE, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -3636,9 +3571,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
-                                  PSA_BYTES_TO_BITS( key_data->len ),
-                                  &base_handle ) );
+    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,
@@ -3650,8 +3583,7 @@
                                     salt->x, salt->len,
                                     label->x, label->len,
                                     capacity ) );
-    PSA_ASSERT( psa_allocate_key( derived_type, derived_bits,
-                                  &derived_handle ) );
+    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,
@@ -3703,9 +3635,7 @@
     ASSERT_ALLOC( export_buffer, capacity );
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
-                                  PSA_BYTES_TO_BITS( key_data->len ),
-                                  &base_handle ) );
+    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,
@@ -3727,8 +3657,7 @@
                                     salt->x, salt->len,
                                     label->x, label->len,
                                     capacity ) );
-    PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_RAW_DATA, derived_bits,
-                                  &derived_handle ) );
+    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,
@@ -3740,9 +3669,7 @@
                                 &length ) );
     TEST_EQUAL( length, bytes1 );
     PSA_ASSERT( psa_destroy_key( derived_handle ) );
-    PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_RAW_DATA,
-                                  PSA_BYTES_TO_BITS( bytes2 ),
-                                  &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_KEY_TYPE_RAW_DATA,
@@ -3781,10 +3708,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( our_key_type,
-                                  KEY_BITS_FROM_DATA( our_key_type,
-                                                      our_key_data ),
-                                  &our_key ) );
+    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,
@@ -3820,10 +3744,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( our_key_type,
-                                  KEY_BITS_FROM_DATA( our_key_type,
-                                                      our_key_data ),
-                                  &our_key ) );
+    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,
@@ -3877,10 +3798,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( our_key_type,
-                                  KEY_BITS_FROM_DATA( our_key_type,
-                                                      our_key_data ),
-                                  &our_key ) );
+    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,
@@ -3986,7 +3904,7 @@
 
     PSA_ASSERT( psa_crypto_init( ) );
 
-    PSA_ASSERT( psa_allocate_key( type, bits, &handle ) );
+    PSA_ASSERT( psa_allocate_key( &handle ) );
     psa_key_policy_set_usage( &policy, usage, alg );
     PSA_ASSERT( psa_set_key_policy( handle, &policy ) );
 
@@ -4042,7 +3960,6 @@
     PSA_ASSERT( psa_crypto_init() );
 
     PSA_ASSERT( psa_create_key( PSA_KEY_LIFETIME_PERSISTENT, 1,
-                                type, bits,
                                 &handle ) );
     psa_key_policy_set_usage( &policy_set, policy_usage,
                               policy_alg );
@@ -4064,9 +3981,7 @@
 
         case DERIVE_KEY:
             /* Create base key */
-            PSA_ASSERT( psa_allocate_key( PSA_KEY_TYPE_DERIVE,
-                                          PSA_BYTES_TO_BITS( data->len ),
-                                          &base_key ) );
+            PSA_ASSERT( psa_allocate_key( &base_key ) );
             psa_key_policy_set_usage( &base_policy_set, PSA_KEY_USAGE_DERIVE,
                                       base_policy_alg );
             PSA_ASSERT( psa_set_key_policy(