Go to the source code of this file.
◆ PSA_KEY_ID_VOLATILE_MAX
The maximum value for a volatile key identifier.
◆ PSA_KEY_ID_VOLATILE_MIN
Range of volatile key identifiers.
The first MBEDTLS_PSA_KEY_SLOT_COUNT identifiers of the implementation range of key identifiers are reserved for volatile key identifiers.
If id is a a volatile key identifier, PSA_KEY_ID_VOLATILE_MIN - id indicates the key slot containing the volatile key definition. See psa_crypto_slot_management.c for details. The minimum value for a volatile key identifier.
◆ psa_get_and_lock_key_slot()
Get the description of a key given its identifier and lock it.
The descriptions of volatile keys and loaded persistent keys are stored in key slots. This function returns a pointer to the key slot containing the description of a key given its identifier.
In case of a persistent key, the function loads the description of the key into a key slot if not already done.
On success, the returned key slot has been registered for reading. It is the responsibility of the caller to call psa_unregister_read(slot) when they have finished reading the contents of the slot.
On failure, *p_slot is set to NULL. This ensures that it is always valid to call psa_unregister_read on the returned slot.
- Parameters
-
| key | Key identifier to query. |
| [out] | p_slot | On success, *p_slot contains a pointer to the key slot containing the description of the key identified by key. |
- Return values
-
◆ psa_initialize_key_slots()
Initialize the key slot structures.
- Return values
-
◆ psa_is_valid_key_id()
Validate a key identifier.
- Parameters
-
| [in] | key | The key identifier. |
| [in] | vendor_ok | Non-zero to indicate that key identifiers in the vendor range are allowed, volatile key identifiers excepted 0 otherwise. |
- Return values
-
| <> | 0 if the key identifier is valid, 0 otherwise. |
◆ psa_reserve_free_key_slot()
Find a free key slot and reserve it to be filled with a key.
This function finds a key slot that is free, sets its state to PSA_SLOT_FILLING and then returns the slot.
On success, the key slot's state is PSA_SLOT_FILLING. It is the responsibility of the caller to change the slot's state to PSA_SLOT_EMPTY/FULL once key creation has finished.
If multi-threading is enabled, the caller must hold the global key slot mutex.
- Parameters
-
| [out] | volatile_key_id | - If null, reserve a cache slot for a persistent or built-in key.
- If non-null, allocate a slot for a volatile key. On success,
*volatile_key_id is the identifier corresponding to the returned slot. It is the caller's responsibility to set this key identifier in the attributes.
|
| [out] | p_slot | On success, a pointer to the slot. |
- Return values
-
◆ psa_unregister_read()
Unregister from reading a key slot.
This function decrements the key slot registered reader counter by one. If the state of the slot is PSA_SLOT_PENDING_DELETION, and there is only one registered reader (the caller), this function will call psa_wipe_key_slot(). If multi-threading is enabled, the caller must hold the global key slot mutex.
- Note
- To ease the handling of errors in retrieving a key slot a NULL input pointer is valid, and the function returns successfully without doing anything in that case.
- Parameters
-
- Return values
-
| PSA_SUCCESS | slot is NULL or the key slot reader counter has been decremented (and potentially wiped) successfully. |
| PSA_ERROR_CORRUPTION_DETECTED | The slot's state was neither PSA_SLOT_FULL nor PSA_SLOT_PENDING_DELETION. Or a wipe was attempted and the slot's state was not PSA_SLOT_PENDING_DELETION. Or registered_readers was equal to 0. |
◆ psa_unregister_read_under_mutex()
Wrap a call to psa_unregister_read in the global key slot mutex.
If threading is disabled, this simply calls psa_unregister_read.
- Note
- To ease the handling of errors in retrieving a key slot a NULL input pointer is valid, and the function returns successfully without doing anything in that case.
- Parameters
-
- Return values
-
| PSA_SUCCESS | slot is NULL or the key slot reader counter has been decremented (and potentially wiped) successfully. |
| PSA_ERROR_CORRUPTION_DETECTED | The slot's state was neither PSA_SLOT_FULL nor PSA_SLOT_PENDING_DELETION. Or a wipe was attempted and the slot's state was not PSA_SLOT_PENDING_DELETION. Or registered_readers was equal to 0. |
◆ psa_validate_key_location()
Validate a key's location.
This function checks whether the key's attributes point to a location that is known to the PSA Core, and returns the driver function table if the key is to be found in an external location.
- Parameters
-
| [in] | lifetime | The key lifetime attribute. |
| [out] | p_drv | On success, when a key is located in external storage, returns a pointer to the driver table associated with the key's storage location. |
- Return values
-
◆ psa_validate_key_persistence()
Validate the persistence of a key.
- Parameters
-
| [in] | lifetime | The key lifetime attribute. |
- Return values
-
◆ psa_wipe_all_key_slots()
| void psa_wipe_all_key_slots |
( |
void |
| ) |
|
Delete all data from key slots in memory. This function is not thread safe, it wipes every key slot regardless of state and reader count. It should only be called when no slot is in use.
This does not affect persistent storage.