Skip to content

Commit d59da21

Browse files
Add validate_slot_number method to SE drivers
Pave the way for allowing the application to choose the slot number in a secure element, rather than always letting the driver choose.
1 parent 747459a commit d59da21

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

include/psa/crypto_se_driver.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,30 @@ typedef psa_status_t (*psa_drv_se_allocate_key_t)(
833833
const psa_key_attributes_t *attributes,
834834
psa_key_slot_number_t *key_slot);
835835

836+
/** \brief A function that determines whether a slot number is valid
837+
* for a key.
838+
*
839+
* \param[in,out] drv_context The driver context structure.
840+
* \param[in] attributes Attributes of the key.
841+
* \param[in] key_slot Slot where the key is to be stored.
842+
*
843+
* \retval #PSA_SUCCESS
844+
* The given slot number is valid for a key with the given
845+
* attributes.
846+
* \retval #PSA_ERROR_INVALID_ARGUMENT
847+
* The given slot number is not valid for a key with the
848+
* given attributes. This includes the case where the slot
849+
* number is not valid at all.
850+
* \retval #PSA_ERROR_ALREADY_EXISTS
851+
* There is already a key with the specified slot number.
852+
* Drivers may choose to return this error from the key
853+
* creation function instead.
854+
*/
855+
typedef psa_status_t (*psa_drv_se_validate_slot_number_t)(
856+
psa_drv_se_context_t *drv_context,
857+
const psa_key_attributes_t *attributes,
858+
psa_key_slot_number_t key_slot);
859+
836860
/** \brief A function that imports a key into a secure element in binary format
837861
*
838862
* This function can support any output from psa_export_key(). Refer to the
@@ -993,6 +1017,16 @@ typedef struct {
9931017
* last call to this function had not taken place.
9941018
*/
9951019
psa_drv_se_allocate_key_t p_allocate;
1020+
/** Function that checks the validity of a slot for a key.
1021+
*
1022+
* The core calls this function instead of
1023+
* psa_drv_se_key_management_t::p_allocate to create
1024+
* a key in a specific slot. It then calls the actual creation function
1025+
* (such as psa_drv_se_key_management_t::p_import or
1026+
* psa_drv_se_key_management_t::p_generate) or
1027+
* psa_drv_se_key_management_t::p_destroy.
1028+
*/
1029+
psa_drv_se_validate_slot_number_t p_validate_slot_number;
9961030
/** Function that performs a key import operation */
9971031
psa_drv_se_import_key_t p_import;
9981032
/** Function that performs a generation */

0 commit comments

Comments
 (0)