@@ -956,15 +956,21 @@ typedef psa_status_t (*psa_drv_se_validate_slot_number_t)(
956956 * documentation of psa_export_key() for the format for each key type.
957957 *
958958 * \param[in,out] drv_context The driver context structure.
959- * \param[in] key_slot Slot where the key will be stored
959+ * \param key_slot Slot where the key will be stored.
960960 * This must be a valid slot for a key of the
961961 * chosen type. It must be unoccupied.
962- * \param[in] lifetime The required lifetime of the key storage
963- * \param[in] type Key type (a \c PSA_KEY_TYPE_XXX value)
964- * \param[in] algorithm Key algorithm (a \c PSA_ALG_XXX value)
965- * \param[in] usage The allowed uses of the key
966- * \param[in] p_data Buffer containing the key data
967- * \param[in] data_length Size of the `data` buffer in bytes
962+ * \param[in] attributes The key attributes, including the lifetime,
963+ * the key type and the usage policy.
964+ * Drivers should not access the key size stored
965+ * in the attributes: it may not match the
966+ * data passed in \p data.
967+ * Drivers can call psa_get_key_lifetime(),
968+ * psa_get_key_type(),
969+ * psa_get_key_usage_flags() and
970+ * psa_get_key_algorithm() to access this
971+ * information.
972+ * \param[in] data Buffer containing the key data.
973+ * \param[in] data_length Size of the \p data buffer in bytes.
968974 * \param[out] bits On success, the key size in bits. The driver
969975 * must determine this value after parsing the
970976 * key according to the key type.
@@ -973,15 +979,13 @@ typedef psa_status_t (*psa_drv_se_validate_slot_number_t)(
973979 * \retval #PSA_SUCCESS
974980 * Success.
975981 */
976- typedef psa_status_t (* psa_drv_se_import_key_t )(psa_drv_se_context_t * drv_context ,
977- psa_key_slot_number_t key_slot ,
978- psa_key_lifetime_t lifetime ,
979- psa_key_type_t type ,
980- psa_algorithm_t algorithm ,
981- psa_key_usage_t usage ,
982- const uint8_t * p_data ,
983- size_t data_length ,
984- size_t * bits );
982+ typedef psa_status_t (* psa_drv_se_import_key_t )(
983+ psa_drv_se_context_t * drv_context ,
984+ psa_key_slot_number_t key_slot ,
985+ const psa_key_attributes_t * attributes ,
986+ const uint8_t * data ,
987+ size_t data_length ,
988+ size_t * bits );
985989
986990/**
987991 * \brief A function that destroys a secure element key and restore the slot to
@@ -1048,41 +1052,51 @@ typedef psa_status_t (*psa_drv_se_export_key_t)(psa_drv_se_context_t *drv_contex
10481052 * element
10491053 *
10501054 * If \p type is asymmetric (#PSA_KEY_TYPE_IS_ASYMMETRIC(\p type) = 1),
1051- * the public component of the generated key will be placed in `p_pubkey_out`.
1052- * The format of the public key information will match the format specified for
1053- * the psa_export_key() function for the key type.
1055+ * the driver may export the public key at the time of generation,
1056+ * in the format documented for psa_export_public_key() by writing it
1057+ * to the \p pubkey buffer.
1058+ * This is optional, intended for secure elements that output the
1059+ * public key at generation time and that cannot export the public key
1060+ * later. Drivers that do not need this feature should leave
1061+ * \p *pubkey_length set to 0 and should
1062+ * implement the psa_drv_key_management_t::p_export_public function.
1063+ * Some implementations do not support this feature, in which case
1064+ * \p pubkey is \c NULL and \p pubkey_size is 0.
10541065 *
10551066 * \param[in,out] drv_context The driver context structure.
1056- * \param[in] key_slot Slot where the generated key will be placed
1057- * \param[in] type The type of the key to be generated
1058- * \param[in] usage The prescribed usage of the generated key
1059- * Note: Not all Secure Elements support the same
1060- * restrictions that PSA Crypto does (and vice
1061- * versa).
1062- * Driver developers should endeavor to match the
1063- * usages as close as possible.
1064- * \param[in] bits The size in bits of the key to be generated.
1065- * \param[in] extra Extra parameters for key generation. The
1066- * interpretation of this parameter should match
1067- * the interpretation in the `extra` parameter is
1068- * the `psa_generate_key` function
1069- * \param[in] extra_size The size in bytes of the \p extra buffer
1070- * \param[out] p_pubkey_out The buffer where the public key information will
1071- * be placed
1072- * \param[in] pubkey_out_size The size in bytes of the `p_pubkey_out` buffer
1073- * \param[out] p_pubkey_length Upon successful completion, will contain the
1074- * size of the data placed in `p_pubkey_out`.
1067+ * \param key_slot Slot where the key will be stored.
1068+ * This must be a valid slot for a key of the
1069+ * chosen type. It must be unoccupied.
1070+ * \param[in] attributes The key attributes, including the lifetime,
1071+ * the key type and size, and the usage policy.
1072+ * Drivers can call psa_get_key_lifetime(),
1073+ * psa_get_key_type(), psa_get_key_bits(),
1074+ * psa_get_key_usage_flags() and
1075+ * psa_get_key_algorithm() to access this
1076+ * information.
1077+ * \param[out] pubkey A buffer where the driver can write the
1078+ * public key, when generating an asymmetric
1079+ * key pair.
1080+ * This is \c NULL when generating a symmetric
1081+ * key or if the core does not support
1082+ * exporting the public key at generation time.
1083+ * \param pubkey_size The size of the `pubkey` buffer in bytes.
1084+ * This is 0 when generating a symmetric
1085+ * key or if the core does not support
1086+ * exporting the public key at generation time.
1087+ * \param[out] pubkey_length On entry, this is always 0.
1088+ * On success, the number of bytes written to
1089+ * \p pubkey. If this is 0 or unchanged on return,
1090+ * the core will not read the \p pubkey buffer,
1091+ * and will instead call the driver's
1092+ * psa_drv_key_management_t::p_export_public
1093+ * function to export the public key when needed.
10751094 */
1076- typedef psa_status_t (* psa_drv_se_generate_key_t )(psa_drv_se_context_t * drv_context ,
1077- psa_key_slot_number_t key_slot ,
1078- psa_key_type_t type ,
1079- psa_key_usage_t usage ,
1080- size_t bits ,
1081- const void * extra ,
1082- size_t extra_size ,
1083- uint8_t * p_pubkey_out ,
1084- size_t pubkey_out_size ,
1085- size_t * p_pubkey_length );
1095+ typedef psa_status_t (* psa_drv_se_generate_key_t )(
1096+ psa_drv_se_context_t * drv_context ,
1097+ psa_key_slot_number_t key_slot ,
1098+ const psa_key_attributes_t * attributes ,
1099+ uint8_t * pubkey , size_t pubkey_size , size_t * pubkey_length );
10861100
10871101/**
10881102 * \brief A struct containing all of the function pointers needed to for secure
0 commit comments