psa: Use psa_key_file_id_t as the key id type
The purpose of this commit and the following is for
psa_key_id_t to always be as defined by the PSA
Cryptography API specification.
Currently psa_key_id_t departs from its specification
definition when MBEDTLS_PSA_CRYPTO_KEY_FILE_ID_ENCODES_OWNER
configuration flag is set. In that configuration, it is set
to be equal to psa_key_file_id_t which in that configuration
encodes an owner identifier along the key identifier.
Type psa_key_file_id_t was meant to be the key identifier type
used throughout the library code. If
MBEDTLS_PSA_CRYPTO_KEY_FILE_ID_ENCODES_OWNER is set it
includes both a key and owner identifier, otherwise it is
equal to psa_key_id_t.
It has not been the key identifier type throughout the
library so far because when the PSA Cryptography
specification was developped the library Doxygen
documentation was used to generate the PSA Cryptography API
specification thus the need to use psa_key_id_t and not
psa_key_file_id_t.
As this constraint does not hold anymore, move
to psa_key_file_id_t as the key identifier type throughout
the library code.
By the way, this commit updates the key identifier
initialization in the tests to be compatible with a
composit key identifier. A psa_key_id_make()
inline function is introduced to initialize key
identifiers (composit ot not) at runtime.
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/include/psa/crypto.h b/include/psa/crypto.h
index a316166..c8eb08b 100644
--- a/include/psa/crypto.h
+++ b/include/psa/crypto.h
@@ -146,11 +146,11 @@
* linkage). This function may be provided as a function-like macro,
* but in this case it must evaluate each of its arguments exactly once.
*
- * \param[out] attributes The attribute structure to write to.
- * \param id The persistent identifier for the key.
+ * \param[out] attributes The attribute structure to write to.
+ * \param key The persistent identifier for the key.
*/
static void psa_set_key_id(psa_key_attributes_t *attributes,
- psa_key_id_t id);
+ psa_key_file_id_t key);
/** Set the location of a persistent key.
*
@@ -192,7 +192,7 @@
* This value is unspecified if the attribute structure declares
* the key as volatile.
*/
-static psa_key_id_t psa_get_key_id(const psa_key_attributes_t *attributes);
+static psa_key_file_id_t psa_get_key_id(const psa_key_attributes_t *attributes);
/** Retrieve the lifetime from key attributes.
*
@@ -392,8 +392,9 @@
* with a lifetime other than #PSA_KEY_LIFETIME_VOLATILE. A persistent key
* always has a nonzero key identifier, set with psa_set_key_id() when
* creating the key. Implementations may provide additional pre-provisioned
- * keys that can be opened with psa_open_key(). Such keys have a key identifier
- * in the vendor range, as documented in the description of #psa_key_id_t.
+ * keys that can be opened with psa_open_key(). Such keys have an application
+ * key identifier in the vendor range, as documented in the description of
+ * #psa_key_id_t.
*
* The application must eventually close the handle with psa_close_key() or
* psa_destroy_key() to release associated resources. If the application dies
@@ -408,7 +409,7 @@
* portable to implementations that only permit a single key handle to be
* opened. See also :ref:\`key-handles\`.
*
- * \param id The persistent identifier of the key.
+ * \param key The persistent identifier of the key.
* \param[out] handle On success, a handle to the key.
*
* \retval #PSA_SUCCESS
@@ -436,8 +437,7 @@
* It is implementation-dependent whether a failure to initialize
* results in this error code.
*/
-psa_status_t psa_open_key(psa_key_id_t id,
- psa_key_handle_t *handle);
+psa_status_t psa_open_key(psa_key_file_id_t key, psa_key_handle_t *handle);
/** Close a key handle.
diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h
index 67c53db..267b050 100644
--- a/include/psa/crypto_struct.h
+++ b/include/psa/crypto_struct.h
@@ -330,7 +330,7 @@
psa_key_type_t type;
psa_key_bits_t bits;
psa_key_lifetime_t lifetime;
- psa_key_id_t id;
+ psa_key_file_id_t id;
psa_key_policy_t policy;
psa_key_attributes_flag_t flags;
} psa_core_key_attributes_t;
@@ -360,14 +360,14 @@
}
static inline void psa_set_key_id(psa_key_attributes_t *attributes,
- psa_key_id_t id)
+ psa_key_file_id_t key)
{
- attributes->core.id = id;
+ attributes->core.id = key;
if( attributes->core.lifetime == PSA_KEY_LIFETIME_VOLATILE )
attributes->core.lifetime = PSA_KEY_LIFETIME_PERSISTENT;
}
-static inline psa_key_id_t psa_get_key_id(
+static inline psa_key_file_id_t psa_get_key_id(
const psa_key_attributes_t *attributes)
{
return( attributes->core.id );
diff --git a/include/psa/crypto_types.h b/include/psa/crypto_types.h
index f8811ad..4603a1d 100644
--- a/include/psa/crypto_types.h
+++ b/include/psa/crypto_types.h
@@ -37,6 +37,11 @@
#include <stdint.h>
+#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
+ !defined(inline) && !defined(__cplusplus)
+#define inline __inline
+#endif
+
/** \defgroup error Error codes
* @{
*/
@@ -125,7 +130,7 @@
* implementation-specific device management event occurs (for example,
* a factory reset).
*
- * Persistent keys have a key identifier of type #psa_key_id_t.
+ * Persistent keys have a key identifier of type #psa_key_file_id_t.
* This identifier remains valid throughout the lifetime of the key,
* even if the application instance that created the key terminates.
* The application can call psa_open_key() to open a persistent key that
@@ -239,6 +244,19 @@
#define PSA_KEY_ID_INIT 0
#define PSA_KEY_FILE_GET_KEY_ID( id ) ( id )
+/** Utility to initialize a key file identifier at runtime.
+ *
+ * \param unused Unused parameter.
+ * \param key_id Identifier of the key.
+ */
+static inline psa_key_file_id_t psa_key_file_id_make(
+ unsigned int unused, psa_key_id_t key_id )
+{
+ (void)unused;
+
+ return( key_id );
+}
+
#else /* MBEDTLS_PSA_CRYPTO_KEY_FILE_ID_ENCODES_OWNER */
typedef struct
{
@@ -246,16 +264,21 @@
psa_key_owner_id_t owner;
} psa_key_file_id_t;
-/* Since crypto.h is used as part of the PSA Cryptography API specification,
- * it must use standard types for things like the argument of psa_open_key().
- * If it wasn't for that constraint, psa_open_key() would take a
- * `psa_key_file_id_t` argument. As a workaround, make `psa_key_id_t` an
- * alias for `psa_key_file_id_t` when building for a multi-client service. */
-typedef psa_key_file_id_t psa_key_id_t;
-
#define PSA_KEY_ID_INIT {0, 0}
#define PSA_KEY_FILE_GET_KEY_ID( file_id ) ( ( file_id ).key_id )
+/** Utility to initialize a key file identifier at runtime.
+ *
+ * \param owner_id Identifier of the key owner.
+ * \param key_id Identifier of the key.
+ */
+static inline psa_key_file_id_t psa_key_file_id_make(
+ psa_key_owner_id_t owner_id, uint32_t key_id )
+{
+ return( (psa_key_file_id_t){ .key_id = key_id,
+ .owner = owner_id } );
+}
+
#endif /* !MBEDTLS_PSA_CRYPTO_KEY_FILE_ID_ENCODES_OWNER */
/**@}*/
diff --git a/library/psa_crypto_se.h b/library/psa_crypto_se.h
index a464232..258c211 100644
--- a/library/psa_crypto_se.h
+++ b/library/psa_crypto_se.h
@@ -45,13 +45,13 @@
/** The base of the range of ITS file identifiers for secure element
* driver persistent data.
*
- * We use a slice of the implemenation reserved range 0xffff0000..0xffffffff,
+ * We use a slice of the implementation reserved range 0xffff0000..0xffffffff,
* specifically the range 0xfffffe00..0xfffffeff. The length of this range
* drives the value of #PSA_MAX_SE_LOCATION. The identifier 0xfffffe00 is
* actually not used since it corresponds to #PSA_KEY_LOCATION_LOCAL_STORAGE
* which doesn't have a driver.
*/
-#define PSA_CRYPTO_SE_DRIVER_ITS_UID_BASE ( (psa_key_id_t) 0xfffffe00 )
+#define PSA_CRYPTO_SE_DRIVER_ITS_UID_BASE ( (psa_app_key_id_t) 0xfffffe00 )
/** The maximum number of registered secure element driver locations. */
#define PSA_MAX_SE_DRIVERS 4
diff --git a/library/psa_crypto_slot_management.c b/library/psa_crypto_slot_management.c
index a32a027..3600e1a 100644
--- a/library/psa_crypto_slot_management.c
+++ b/library/psa_crypto_slot_management.c
@@ -204,7 +204,7 @@
}
psa_status_t psa_validate_key_persistence( psa_key_lifetime_t lifetime,
- psa_key_id_t key_id )
+ psa_key_file_id_t key )
{
if ( PSA_KEY_LIFETIME_IS_VOLATILE( lifetime ) )
{
@@ -215,19 +215,19 @@
{
/* Persistent keys require storage support */
#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C)
- if( psa_is_key_id_valid( key_id,
+ if( psa_is_key_id_valid( key,
psa_key_lifetime_is_external( lifetime ) ) )
return( PSA_SUCCESS );
else
return( PSA_ERROR_INVALID_ARGUMENT );
#else /* MBEDTLS_PSA_CRYPTO_STORAGE_C */
- (void) key_id;
+ (void) key;
return( PSA_ERROR_NOT_SUPPORTED );
#endif /* !MBEDTLS_PSA_CRYPTO_STORAGE_C */
}
}
-psa_status_t psa_open_key( psa_key_file_id_t id, psa_key_handle_t *handle )
+psa_status_t psa_open_key( psa_key_file_id_t key, psa_key_handle_t *handle )
{
#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C)
psa_status_t status;
@@ -235,7 +235,7 @@
*handle = 0;
- if( ! psa_is_key_id_valid( id, 1 ) )
+ if( ! psa_is_key_id_valid( key, 1 ) )
return( PSA_ERROR_INVALID_ARGUMENT );
status = psa_get_empty_key_slot( handle, &slot );
@@ -243,7 +243,7 @@
return( status );
slot->attr.lifetime = PSA_KEY_LIFETIME_PERSISTENT;
- slot->attr.id = id;
+ slot->attr.id = key;
status = psa_load_persistent_key_into_slot( slot );
if( status != PSA_SUCCESS )
@@ -254,7 +254,7 @@
return( status );
#else /* defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) */
- (void) id;
+ (void) key;
*handle = 0;
return( PSA_ERROR_NOT_SUPPORTED );
#endif /* !defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) */
diff --git a/library/psa_crypto_slot_management.h b/library/psa_crypto_slot_management.h
index 676a77e..58e7f7c 100644
--- a/library/psa_crypto_slot_management.h
+++ b/library/psa_crypto_slot_management.h
@@ -113,14 +113,14 @@
* This function checks whether a key's declared persistence level and key ID
* attributes are valid and known to the PSA Core in its actual configuration.
*
- * \param[in] lifetime The key lifetime attribute.
- * \param[in] key_id The key ID attribute
+ * \param[in] lifetime The key lifetime attribute.
+ * \param[in] key The key identifier.
*
* \retval #PSA_SUCCESS
* \retval #PSA_ERROR_INVALID_ARGUMENT
*/
psa_status_t psa_validate_key_persistence( psa_key_lifetime_t lifetime,
- psa_key_id_t key_id );
+ psa_key_file_id_t key );
#endif /* PSA_CRYPTO_SLOT_MANAGEMENT_H */
diff --git a/library/psa_crypto_storage.c b/library/psa_crypto_storage.c
index 103c9bb..18889a1 100644
--- a/library/psa_crypto_storage.c
+++ b/library/psa_crypto_storage.c
@@ -394,7 +394,7 @@
psa_status_t status = PSA_SUCCESS;
uint8_t *loaded_data;
size_t storage_data_length = 0;
- psa_key_id_t key = attr->id;
+ psa_key_file_id_t key = attr->id;
status = psa_crypto_storage_get_data_length( key, &storage_data_length );
if( status != PSA_SUCCESS )
diff --git a/library/psa_crypto_storage.h b/library/psa_crypto_storage.h
index debc742..6fcae27 100644
--- a/library/psa_crypto_storage.h
+++ b/library/psa_crypto_storage.h
@@ -292,7 +292,7 @@
uint16_t unused1;
psa_key_lifetime_t lifetime;
psa_key_slot_number_t slot;
- psa_key_id_t id;
+ psa_key_file_id_t id;
} key;
} psa_crypto_transaction_t;
@@ -361,7 +361,7 @@
*
* 0xffffffNN = special file; 0x74 = 't' for transaction.
*/
-#define PSA_CRYPTO_ITS_TRANSACTION_UID ( (psa_key_id_t) 0xffffff74 )
+#define PSA_CRYPTO_ITS_TRANSACTION_UID ( (psa_app_key_id_t) 0xffffff74 )
#endif /* PSA_CRYPTO_STORAGE_HAS_TRANSACTIONS */
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index 665580b..af7a221 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -233,7 +233,7 @@
int ok = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_lifetime_t lifetime;
- psa_key_id_t id;
+ psa_key_file_id_t id;
psa_key_type_t type;
psa_key_type_t bits;
@@ -1326,7 +1326,7 @@
int type_arg, int bits_arg )
{
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
- psa_key_id_t id = id_arg;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, id_arg );
psa_key_lifetime_t lifetime = lifetime_arg;
psa_key_usage_t usage_flags = usage_flags_arg;
psa_algorithm_t alg = alg_arg;
@@ -1370,10 +1370,10 @@
int expected_id_arg, int expected_lifetime_arg )
{
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
- psa_key_id_t id1 = id1_arg;
+ psa_key_file_id_t id1 = psa_key_file_id_make( 1, id1_arg );
psa_key_lifetime_t lifetime = lifetime_arg;
- psa_key_id_t id2 = id2_arg;
- psa_key_id_t expected_id = expected_id_arg;
+ psa_key_file_id_t id2 = psa_key_file_id_make( 1, id2_arg );
+ psa_key_file_id_t expected_id = psa_key_file_id_make( 1, expected_id_arg );
psa_key_lifetime_t expected_lifetime = expected_lifetime_arg;
if( id1_arg != -1 )
@@ -5584,7 +5584,7 @@
int usage_flags_arg, int alg_arg,
int generation_method )
{
- psa_key_id_t key_id = 1;
+ psa_key_file_id_t key_id = psa_key_file_id_make( 1, 1 );
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_handle_t handle = 0;
psa_key_handle_t base_key = 0;
diff --git a/tests/suites/test_suite_psa_crypto_persistent_key.function b/tests/suites/test_suite_psa_crypto_persistent_key.function
index 49ce964..43cc5df 100644
--- a/tests/suites/test_suite_psa_crypto_persistent_key.function
+++ b/tests/suites/test_suite_psa_crypto_persistent_key.function
@@ -112,7 +112,7 @@
/* BEGIN_CASE */
void save_large_persistent_key( int data_length_arg, int expected_status )
{
- psa_key_id_t key_id = 42;
+ psa_key_file_id_t key_id = psa_key_file_id_make( 1, 42 );
psa_key_handle_t handle = 0;
uint8_t *data = NULL;
size_t data_length = data_length_arg;
@@ -143,7 +143,7 @@
int first_type_arg, data_t *first_data,
int second_type_arg, data_t *second_data )
{
- psa_key_id_t key_id = key_id_arg;
+ psa_key_file_id_t key_id = psa_key_file_id_make( 1, key_id_arg );
psa_key_handle_t handle = 0;
psa_key_type_t first_type = (psa_key_type_t) first_type_arg;
psa_key_type_t second_type = (psa_key_type_t) second_type_arg;
@@ -196,7 +196,7 @@
void persistent_key_import( int key_id_arg, int type_arg, data_t *data,
int restart, int expected_status )
{
- psa_key_id_t key_id = (psa_key_id_t) key_id_arg;
+ psa_key_file_id_t key_id = psa_key_file_id_make( 1, key_id_arg );
psa_key_type_t type = (psa_key_type_t) type_arg;
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -245,7 +245,7 @@
int expected_bits,
int restart, int key_not_exist )
{
- psa_key_id_t key_id = 42;
+ psa_key_file_id_t key_id = psa_key_file_id_make( 1, 42 );
psa_key_type_t type = (psa_key_type_t) type_arg;
psa_key_handle_t handle = 0;
unsigned char *exported = NULL;
diff --git a/tests/suites/test_suite_psa_crypto_se_driver_hal.function b/tests/suites/test_suite_psa_crypto_se_driver_hal.function
index c9ce866..e7c26d2 100644
--- a/tests/suites/test_suite_psa_crypto_se_driver_hal.function
+++ b/tests/suites/test_suite_psa_crypto_se_driver_hal.function
@@ -760,13 +760,13 @@
#define MAX_KEY_ID_FOR_TEST 10
static void psa_purge_storage( void )
{
- psa_key_id_t id;
+ psa_app_key_id_t id;
psa_key_location_t location;
/* The tests may have potentially created key ids from 1 to
* MAX_KEY_ID_FOR_TEST. In addition, run the destroy function on key id
* 0, which file-based storage uses as a temporary file. */
for( id = 0; id <= MAX_KEY_ID_FOR_TEST; id++ )
- psa_destroy_persistent_key( id );
+ psa_destroy_persistent_key( psa_key_file_id_make( 1, id ) );
/* Purge the transaction file. */
psa_crypto_stop_transaction( );
/* Purge driver persistent data. */
@@ -853,7 +853,7 @@
psa_drv_se_key_management_t key_management;
psa_key_lifetime_t lifetime = (psa_key_lifetime_t) lifetime_arg;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
- psa_key_id_t id = 1;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, 1 );
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
@@ -985,7 +985,7 @@
psa_drv_se_key_management_t key_management;
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
- psa_key_id_t id = 1;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, 1 );
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
@@ -1067,7 +1067,7 @@
psa_drv_se_key_management_t key_management;
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
- psa_key_id_t id = 1;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, 1 );
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -1139,7 +1139,7 @@
psa_drv_se_key_management_t key_management;
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
- psa_key_id_t id = 1;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, 1 );
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -1178,7 +1178,7 @@
psa_drv_se_key_management_t key_management;
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
- psa_key_id_t id = 1;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, 1 );
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -1258,7 +1258,7 @@
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
- psa_key_id_t id = 1;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, 1 );
psa_key_handle_t drv_handle = 0; /* key managed by the driver */
psa_key_handle_t sw_handle = 0; /* transparent key */
psa_key_attributes_t sw_attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -1420,7 +1420,7 @@
psa_drv_se_t driver;
psa_drv_se_key_management_t key_management;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
- psa_key_id_t id = id_arg;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, id_arg );
size_t bit_size = 48;
psa_key_slot_number_t wanted_slot = 0x123456789;
psa_key_handle_t handle = 0;
diff --git a/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function b/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function
index ef50a68..618bd15 100644
--- a/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function
+++ b/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function
@@ -89,13 +89,13 @@
#define MAX_KEY_ID_FOR_TEST 10
static void psa_purge_storage( void )
{
- psa_key_id_t id;
+ psa_app_key_id_t id;
psa_key_location_t location;
/* The tests may have potentially created key ids from 1 to
* MAX_KEY_ID_FOR_TEST. In addition, run the destroy function on key id
* 0, which file-based storage uses as a temporary file. */
for( id = 0; id <= MAX_KEY_ID_FOR_TEST; id++ )
- psa_destroy_persistent_key( id );
+ psa_destroy_persistent_key( psa_key_file_id_make( 1, id ) );
/* Purge the transaction file. */
psa_crypto_stop_transaction( );
/* Purge driver persistent data. */
@@ -330,7 +330,7 @@
psa_drv_se_key_management_t key_management;
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
- psa_key_id_t id = 1;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, 1 );
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
@@ -387,7 +387,7 @@
psa_drv_se_key_management_t key_management;
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
- psa_key_id_t id = 1;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, 1 );
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
@@ -441,7 +441,7 @@
psa_drv_se_key_management_t key_management;
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
- psa_key_id_t id = 1;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, 1 );
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
@@ -496,7 +496,7 @@
psa_drv_se_key_management_t key_management;
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
- psa_key_id_t id = 1;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, 1 );
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
@@ -546,7 +546,7 @@
psa_drv_se_asymmetric_t asymmetric;
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
- psa_key_id_t id = 1;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, 1 );
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
@@ -607,7 +607,7 @@
psa_drv_se_asymmetric_t asymmetric;
psa_key_lifetime_t lifetime = TEST_SE_PERSISTENT_LIFETIME;
psa_key_location_t location = PSA_KEY_LIFETIME_GET_LOCATION( lifetime );
- psa_key_id_t id = 1;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, 1 );
psa_key_handle_t handle = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
const uint8_t key_material[3] = {0xfa, 0xca, 0xde};
diff --git a/tests/suites/test_suite_psa_crypto_slot_management.function b/tests/suites/test_suite_psa_crypto_slot_management.function
index 3a14b12..bd15865 100644
--- a/tests/suites/test_suite_psa_crypto_slot_management.function
+++ b/tests/suites/test_suite_psa_crypto_slot_management.function
@@ -34,11 +34,11 @@
* code. */
#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C)
-static psa_key_id_t key_ids_used_in_test[9];
+static psa_key_file_id_t key_ids_used_in_test[9];
static size_t num_key_ids_used;
/* Record a key id as potentially used in a test case. */
-static int test_uses_key_id( psa_key_id_t key_id )
+static int test_uses_key_id( psa_key_file_id_t key_id )
{
size_t i;
if( key_id > PSA_MAX_PERSISTENT_KEY_IDENTIFIER )
@@ -178,7 +178,7 @@
int close_method_arg )
{
psa_key_lifetime_t lifetime = lifetime_arg;
- psa_key_id_t id = id_arg;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, id_arg );
psa_algorithm_t alg = alg_arg;
psa_algorithm_t alg2 = alg2_arg;
psa_key_usage_t usage_flags = usage_arg;
@@ -296,7 +296,7 @@
int reopen_policy_arg )
{
psa_key_lifetime_t lifetime = lifetime_arg;
- psa_key_id_t id = id_arg;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, id_arg );
psa_key_handle_t handle1 = 0, handle2 = 0;
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_type_t type1 = PSA_KEY_TYPE_RAW_DATA;
@@ -363,7 +363,7 @@
void open_fail( int id_arg,
int expected_status_arg )
{
- psa_key_id_t id = id_arg;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, id_arg );
psa_status_t expected_status = expected_status_arg;
psa_key_handle_t handle = 0xdead;
@@ -382,7 +382,7 @@
int expected_status_arg )
{
psa_key_lifetime_t lifetime = lifetime_arg;
- psa_key_id_t id = id_arg;
+ psa_key_file_id_t id = psa_key_file_id_make( 1, id_arg );
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_status_t expected_status = expected_status_arg;
psa_key_handle_t handle = 0xdead;
@@ -420,14 +420,14 @@
int expected_alg_arg, int expected_alg2_arg )
{
psa_key_lifetime_t source_lifetime = source_lifetime_arg;
- psa_key_id_t source_id = source_id_arg;
+ psa_key_file_id_t source_id = psa_key_file_id_make( 1, source_id_arg );
psa_key_usage_t source_usage = source_usage_arg;
psa_algorithm_t source_alg = source_alg_arg;
psa_key_handle_t source_handle = 0;
psa_key_attributes_t source_attributes = PSA_KEY_ATTRIBUTES_INIT;
psa_key_type_t source_type = type_arg;
psa_key_lifetime_t target_lifetime = target_lifetime_arg;
- psa_key_id_t target_id = target_id_arg;
+ psa_key_file_id_t target_id = psa_key_file_id_make( 1, target_id_arg );
psa_key_usage_t target_usage = target_usage_arg;
psa_algorithm_t target_alg = target_alg_arg;
psa_key_handle_t target_handle = 0;
@@ -534,13 +534,13 @@
int target_type_arg, data_t *target_material )
{
psa_key_lifetime_t source_lifetime = source_lifetime_arg;
- psa_key_id_t source_id = source_id_arg;
+ psa_key_file_id_t source_id = psa_key_file_id_make( 1, source_id_arg );
psa_key_usage_t source_usage = source_usage_arg;
psa_algorithm_t source_alg = source_alg_arg;
psa_key_handle_t source_handle = 0;
psa_key_type_t source_type = source_type_arg;
psa_key_lifetime_t target_lifetime = target_lifetime_arg;
- psa_key_id_t target_id = target_id_arg;
+ psa_key_file_id_t target_id = psa_key_file_id_make( 1, target_id_arg );
psa_key_usage_t target_usage = target_usage_arg;
psa_algorithm_t target_alg = target_alg_arg;
psa_key_handle_t target_handle = 0;