XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
psa_crypto_se.h File Reference
#include "psa/build_info.h"
#include "psa/crypto.h"
#include "psa/crypto_se_driver.h"
Include dependency graph for psa_crypto_se.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  psa_se_key_data_storage_t
 

Macros

#define PSA_MAX_SE_LOCATION   255
 
#define PSA_CRYPTO_SE_DRIVER_ITS_UID_BASE   ((psa_key_id_t) 0xfffffe00)
 
#define PSA_MAX_SE_DRIVERS   4
 

Typedefs

typedef struct psa_se_drv_table_entry_s psa_se_drv_table_entry_t
 

Functions

void psa_unregister_all_se_drivers (void)
 
psa_status_t psa_init_all_se_drivers (void)
 
int psa_get_se_driver (psa_key_lifetime_t lifetime, const psa_drv_se_t **p_methods, psa_drv_se_context_t **p_drv_context)
 
psa_se_drv_table_entry_t * psa_get_se_driver_entry (psa_key_lifetime_t lifetime)
 
const psa_drv_se_t * psa_get_se_driver_methods (const psa_se_drv_table_entry_t *driver)
 
psa_drv_se_context_t * psa_get_se_driver_context (psa_se_drv_table_entry_t *driver)
 
psa_status_t psa_find_se_slot_for_key (const psa_key_attributes_t *attributes, psa_key_creation_method_t method, psa_se_drv_table_entry_t *driver, psa_key_slot_number_t *slot_number)
 
psa_status_t psa_destroy_se_key (psa_se_drv_table_entry_t *driver, psa_key_slot_number_t slot_number)
 
psa_status_t psa_load_se_persistent_data (const psa_se_drv_table_entry_t *driver)
 
psa_status_t psa_save_se_persistent_data (const psa_se_drv_table_entry_t *driver)
 
psa_status_t psa_destroy_se_persistent_data (psa_key_location_t location)
 

Macro Definition Documentation

◆ PSA_CRYPTO_SE_DRIVER_ITS_UID_BASE

#define PSA_CRYPTO_SE_DRIVER_ITS_UID_BASE   ((psa_key_id_t) 0xfffffe00)

The base of the range of ITS file identifiers for secure element driver persistent data.

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.

◆ PSA_MAX_SE_DRIVERS

#define PSA_MAX_SE_DRIVERS   4

The maximum number of registered secure element driver locations.

◆ PSA_MAX_SE_LOCATION

#define PSA_MAX_SE_LOCATION   255

The maximum location value that this implementation supports for a secure element.

This is not a characteristic that each PSA implementation has, but a limitation of the current implementation due to the constraints imposed by storage. See PSA_CRYPTO_SE_DRIVER_ITS_UID_BASE.

The minimum location value for a secure element is 1, like on any PSA implementation (0 means a transparent key).

Typedef Documentation

◆ psa_se_drv_table_entry_t

typedef struct psa_se_drv_table_entry_s psa_se_drv_table_entry_t

A structure that describes a registered secure element driver.

A secure element driver table entry contains a pointer to the driver's method table as well as the driver context structure.

Function Documentation

◆ psa_destroy_se_key()

psa_status_t psa_destroy_se_key ( psa_se_drv_table_entry_t *  driver,
psa_key_slot_number_t  slot_number 
)

Destroy a key in a secure element.

This function calls the relevant driver method to destroy a key and updates the driver's persistent data.

◆ psa_destroy_se_persistent_data()

psa_status_t psa_destroy_se_persistent_data ( psa_key_location_t  location)

Destroy the persistent data of a secure element driver.

This is currently only used for testing.

Parameters
[in]locationThe location identifier for the driver whose persistent data is to be erased.

◆ psa_find_se_slot_for_key()

psa_status_t psa_find_se_slot_for_key ( const psa_key_attributes_t *  attributes,
psa_key_creation_method_t  method,
psa_se_drv_table_entry_t *  driver,
psa_key_slot_number_t *  slot_number 
)

Find a free slot for a key that is to be created.

This function calls the relevant method in the driver to find a suitable slot for a key with the given attributes.

Parameters
[in]attributesMetadata about the key that is about to be created.
[in]driverThe driver table entry to query.
[out]slot_numberOn success, a slot number that is free in this secure element.

◆ psa_get_se_driver()

int psa_get_se_driver ( psa_key_lifetime_t  lifetime,
const psa_drv_se_t **  p_methods,
psa_drv_se_context_t **  p_drv_context 
)

Return the secure element driver information for a lifetime value.

Parameters
lifetimeThe lifetime value to query.
[out]p_methodsOn output, if there is a driver, *methods points to its method table. Otherwise *methods is NULL.
[out]p_drv_contextOn output, if there is a driver, *drv_context points to its context structure. Otherwise *drv_context is NULL.
Return values
1lifetime corresponds to a registered driver.
0lifetime does not correspond to a registered driver.

◆ psa_get_se_driver_context()

psa_drv_se_context_t * psa_get_se_driver_context ( psa_se_drv_table_entry_t *  driver)

Return the context of a secure element driver.

Parameters
[in]driverThe driver table entry to access, or NULL.
Returns
A pointer to the driver context. NULL if driver is NULL.

◆ psa_get_se_driver_entry()

psa_se_drv_table_entry_t * psa_get_se_driver_entry ( psa_key_lifetime_t  lifetime)

Return the secure element driver table entry for a lifetime value.

Parameters
lifetimeThe lifetime value to query.
Returns
The driver table entry for lifetime, or NULL if lifetime does not correspond to a registered driver.

◆ psa_get_se_driver_methods()

const psa_drv_se_t * psa_get_se_driver_methods ( const psa_se_drv_table_entry_t *  driver)

Return the method table for a secure element driver.

Parameters
[in]driverThe driver table entry to access, or NULL.
Returns
The driver's method table. NULL if driver is NULL.

◆ psa_init_all_se_drivers()

psa_status_t psa_init_all_se_drivers ( void  )

Initialize all secure element drivers.

Called from psa_crypto_init().

◆ psa_load_se_persistent_data()

psa_status_t psa_load_se_persistent_data ( const psa_se_drv_table_entry_t *  driver)

Load the persistent data of a secure element driver.

Parameters
driverThe driver table entry containing the persistent data to load from storage.
Returns
PSA_SUCCESS
PSA_ERROR_NOT_SUPPORTED
PSA_ERROR_DOES_NOT_EXIST
PSA_ERROR_STORAGE_FAILURE
PSA_ERROR_DATA_CORRUPT
PSA_ERROR_INVALID_ARGUMENT

◆ psa_save_se_persistent_data()

psa_status_t psa_save_se_persistent_data ( const psa_se_drv_table_entry_t *  driver)

Save the persistent data of a secure element driver.

Parameters
[in]driverThe driver table entry containing the persistent data to save to storage.
Returns
PSA_SUCCESS
PSA_ERROR_NOT_SUPPORTED
PSA_ERROR_NOT_PERMITTED
PSA_ERROR_NOT_SUPPORTED
PSA_ERROR_INSUFFICIENT_STORAGE
PSA_ERROR_STORAGE_FAILURE
PSA_ERROR_INVALID_ARGUMENT

◆ psa_unregister_all_se_drivers()

void psa_unregister_all_se_drivers ( void  )

Unregister all secure element drivers.

Warning
Do not call this function while the library is in the initialized state. This function is only intended to be called at the end of mbedtls_psa_crypto_free().