diff --git a/include/psa/crypto.h b/include/psa/crypto.h index a3161666d..c8eb08bd0 100644 --- a/include/psa/crypto.h +++ b/include/psa/crypto.h @@ -146,11 +146,11 @@ static psa_key_attributes_t psa_key_attributes_init(void); * 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 @@ static void psa_set_key_lifetime(psa_key_attributes_t *attributes, * 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 @@ void psa_reset_key_attributes(psa_key_attributes_t *attributes); * 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 @@ void psa_reset_key_attributes(psa_key_attributes_t *attributes); * 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 @@ void psa_reset_key_attributes(psa_key_attributes_t *attributes); * 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 67c53db92..267b0501a 100644 --- a/include/psa/crypto_struct.h +++ b/include/psa/crypto_struct.h @@ -330,7 +330,7 @@ typedef struct 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 struct psa_key_attributes_s psa_key_attributes_init( void ) } 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 f8811ad10..4603a1d1a 100644 --- a/include/psa/crypto_types.h +++ b/include/psa/crypto_types.h @@ -37,6 +37,11 @@ #include +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) +#define inline __inline +#endif + /** \defgroup error Error codes * @{ */ @@ -125,7 +130,7 @@ typedef uint32_t psa_algorithm_t; * 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 @@ typedef psa_key_id_t psa_key_file_id_t; #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 @@ typedef struct 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 a46423256..258c211af 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 a32a02798..3600e1a37 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_location( psa_key_lifetime_t lifetime, } 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 @@ psa_status_t psa_validate_key_persistence( psa_key_lifetime_t lifetime, { /* 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 @@ psa_status_t psa_open_key( psa_key_file_id_t id, psa_key_handle_t *handle ) *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 @@ psa_status_t psa_open_key( psa_key_file_id_t id, psa_key_handle_t *handle ) 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 @@ psa_status_t psa_open_key( psa_key_file_id_t id, psa_key_handle_t *handle ) 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 676a77e5a..58e7f7cb6 100644 --- a/library/psa_crypto_slot_management.h +++ b/library/psa_crypto_slot_management.h @@ -113,14 +113,14 @@ psa_status_t psa_validate_key_location( psa_key_lifetime_t lifetime, * 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 103c9bbb8..18889a17e 100644 --- a/library/psa_crypto_storage.c +++ b/library/psa_crypto_storage.c @@ -394,7 +394,7 @@ psa_status_t psa_load_persistent_key( psa_core_key_attributes_t *attr, 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 debc742bd..6fcae272e 100644 --- a/library/psa_crypto_storage.h +++ b/library/psa_crypto_storage.h @@ -292,7 +292,7 @@ typedef union 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 @@ psa_status_t psa_crypto_stop_transaction( void ); * * 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 665580bfe..af7a22133 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -233,7 +233,7 @@ int check_key_attributes_sanity( psa_key_handle_t key ) 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 @@ void attributes_set_get( int id_arg, int lifetime_arg, 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 @@ void persistence_attributes( int id1_arg, int lifetime_arg, int id2_arg, 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 @@ void persistent_key_load_key_from_storage( data_t *data, 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 49ce964fb..43cc5df5f 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 @@ exit: /* 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 @@ void persistent_key_destroy( int key_id_arg, int restart, 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 @@ exit: 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 @@ void import_export_persistent_key( data_t *data, int type_arg, 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 c9ce8667b..e7c26d22c 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 @@ exit: #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 @@ void key_creation_import_export( int lifetime_arg, int min_slot, int restart ) 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 @@ void key_creation_in_chosen_slot( int slot_arg, 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 @@ void import_key_smoke( int type_arg, int alg_arg, 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 @@ void generate_key_not_supported( int type_arg, int bits_arg ) 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 @@ void generate_key_smoke( int type_arg, int bits_arg, int alg_arg ) 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 @@ void sign_verify( int flow, 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 @@ void register_key_smoke_test( int lifetime_arg, 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 ef50a6814..618bd1546 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 @@ static struct #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 @@ void mock_import( int mock_alloc_return_value, 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 @@ void mock_export( int mock_export_return_value, int expected_result ) 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 @@ void mock_generate( int mock_alloc_return_value, 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 @@ void mock_export_public( int mock_export_public_return_value, 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 @@ void mock_sign( int mock_sign_return_value, int expected_result ) 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 @@ void mock_verify( int mock_verify_return_value, int expected_result ) 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 3a14b1211..bd15865cb 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 @@ typedef enum * 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 @@ void persistent_slot_lifecycle( int lifetime_arg, int id_arg, 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 @@ void create_existent( int lifetime_arg, int id_arg, 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 @@ exit: 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 @@ void create_fail( int lifetime_arg, int id_arg, 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 @@ void copy_across_lifetimes( int source_lifetime_arg, int source_id_arg, 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 @@ void copy_to_occupied( int source_lifetime_arg, int source_id_arg, 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;