21#ifndef PSA_CRYPTO_SLOT_MANAGEMENT_H
22#define PSA_CRYPTO_SLOT_MANAGEMENT_H
35#define PSA_PROTECTED_KEY_COUNT (CONFIG_PSA_PROTECTED_KEY_COUNT)
40#define PSA_ASYMMETRIC_KEYPAIR_COUNT (CONFIG_PSA_ASYMMETRIC_KEYPAIR_COUNT)
45#define PSA_SINGLE_KEY_COUNT (CONFIG_PSA_SINGLE_KEY_COUNT)
50#define PSA_KEY_SLOT_COUNT (PSA_PROTECTED_KEY_COUNT + \
51 PSA_ASYMMETRIC_KEYPAIR_COUNT + \
59#define PSA_KEY_ID_VOLATILE_MIN (PSA_KEY_ID_VENDOR_MIN)
66#define PSA_KEY_ID_VOLATILE_MAX (PSA_KEY_ID_VENDOR_MAX)
81#if PSA_SINGLE_KEY_COUNT
89#if PSA_PROTECTED_KEY_COUNT
100 struct prot_key_data {
102#if IS_USED(MODULE_PSA_ASYMMETRIC)
104 size_t pubkey_data_len;
107} psa_prot_key_slot_t;
110#if PSA_ASYMMETRIC_KEYPAIR_COUNT
121 struct key_pair_data {
125 size_t privkey_data_len;
129 size_t pubkey_data_len;
131} psa_key_pair_slot_t;
309 uint8_t **pubkey_data,
310 size_t **pubkey_data_len);
Function declarations for PSA Crypto.
#define PSA_MAX_PRIV_KEY_SIZE
The maximum size of an asymmetric private key.
#define PSA_MAX_KEY_DATA_SIZE
The maximum size of the used key data.
#define PSA_EXPORT_PUBLIC_KEY_MAX_SIZE
Sufficient buffer size for exporting any asymmetric public key.
#define PSA_BITS_TO_BYTES(bits)
Functions to convert bits to bytes.
uint32_t psa_key_id_t
Key identifier.
uint32_t psa_key_lifetime_t
Encoding of key lifetimes.
#define PSA_KEY_LOCATION_LOCAL_STORAGE
The local storage area for persistent keys.
#define PSA_KEY_LIFETIME_GET_LOCATION(lifetime)
Extract the location indicator from a key lifetime.
uint64_t psa_key_slot_number_t
Encoding of a key slot number on a secure element.
int psa_is_valid_key_id(psa_key_id_t id, int vendor)
Check if provided key ID is either a valid user ID or vendor ID.
psa_status_t psa_lock_key_slot(psa_key_slot_t *slot)
Increase lock count.
#define PSA_KEY_ID_VOLATILE_MAX
Maximum key id for volatile keys.
void psa_init_key_slots(void)
Initializes the allocated key slots and prepares the internal key slot lists.
static int psa_is_key_slot_locked(psa_key_slot_t *slot)
Check whether a key slot is locked.
static int psa_key_lifetime_is_external(psa_key_lifetime_t lifetime)
Check whether a key is stored on an external device.
psa_key_slot_number_t * psa_key_slot_get_slot_number(const psa_key_slot_t *slot)
Get slot number in protected memory.
psa_status_t psa_validate_key_persistence(psa_key_lifetime_t lifetime)
Validate key persistence.
psa_status_t psa_get_and_lock_key_slot(psa_key_id_t id, psa_key_slot_t **slot)
Find a key slot in local memory and lock it.
psa_status_t psa_validate_key_location(psa_key_lifetime_t lifetime, psa_se_drv_data_t **driver)
Check if key location exists.
psa_status_t psa_wipe_key_slot(psa_key_slot_t *slot)
Wipe volatile key slot and its contents.
#define PSA_KEY_ID_VOLATILE_MIN
Minimum key id for volatile keys.
psa_status_t psa_persist_key_slot_in_storage(psa_key_slot_t *slot)
Store a key slot in persistent storage.
psa_status_t psa_allocate_empty_key_slot(psa_key_id_t *id, const psa_key_attributes_t *attr, psa_key_slot_t **p_slot)
Find a currently empty key slot that is appropriate for the key.
psa_status_t psa_unlock_key_slot(psa_key_slot_t *slot)
Decrease lock count.
void psa_get_public_key_data_from_key_slot(const psa_key_slot_t *slot, uint8_t **pubkey_data, size_t **pubkey_data_len)
Get public key data and size from key slot.
void psa_wipe_all_key_slots(void)
Wipe all existing volatile key slots.
static int psa_key_id_is_volatile(psa_key_id_t key_id)
Check whether a key identifier is a volatile key identifier.
size_t psa_get_key_data_from_key_slot(const psa_key_slot_t *slot, uint8_t **key_data, size_t **key_bytes)
Get key data and key size from key slot.
int32_t psa_status_t
Status code type used for all PSA Certified APIs.
PSA Secure Element management function declarations.
Structure storing key attributes.
Structure of a virtual key slot in local memory.
clist_node_t node
List node to link slot in global list.
psa_key_attributes_t attr
Attributes associated with the stored key.
size_t lock_count
Number of entities accessing the slot.
Structure containing secure element driver data and contexts.