File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -818,6 +818,27 @@ typedef enum
818
818
PSA_KEY_CREATION_GENERATE , /**< During psa_generate_key() */
819
819
PSA_KEY_CREATION_DERIVE , /**< During psa_key_derivation_output_key() */
820
820
PSA_KEY_CREATION_COPY , /**< During psa_copy_key() */
821
+
822
+ #ifndef __DOXYGEN_ONLY__
823
+ /** A key is being registered with mbedtls_psa_register_se_key().
824
+ *
825
+ * The core only passes this value to
826
+ * psa_drv_se_key_management_t::p_validate_slot_number, not to
827
+ * psa_drv_se_key_management_t::p_allocate. The call to
828
+ * `p_validate_slot_number` is not followed by any other call to the
829
+ * driver: the key is considered successfully registered if the call to
830
+ * `p_validate_slot_number` succeeds, or if `p_validate_slot_number` is
831
+ * null.
832
+ *
833
+ * With this creation method, the driver must return #PSA_SUCCESS if
834
+ * the given attributes are compatible with the existing key in the slot,
835
+ * and #PSA_ERROR_DOES_NOT_EXIST if the driver can determine that there
836
+ * is no key with the specified slot number.
837
+ *
838
+ * This is an Mbed Crypto extension.
839
+ */
840
+ PSA_KEY_CREATION_REGISTER ,
841
+ #endif
821
842
} psa_key_creation_method_t ;
822
843
823
844
/** \brief A function that allocates a slot for a key.
Original file line number Diff line number Diff line change @@ -1898,6 +1898,21 @@ psa_status_t mbedtls_psa_register_se_key(
1898
1898
goto exit ;
1899
1899
}
1900
1900
1901
+ /* If the driver has a slot number validation method, call it.
1902
+ * If it doesn't, it means the secure element is unable to validate
1903
+ * anything and so we have to trust the application. */
1904
+ if ( drv -> key_management != NULL &&
1905
+ drv -> key_management -> p_validate_slot_number != NULL )
1906
+ {
1907
+ status = drv -> key_management -> p_validate_slot_number (
1908
+ psa_get_se_driver_context ( driver ),
1909
+ attributes ,
1910
+ PSA_KEY_CREATION_REGISTER ,
1911
+ slot -> data .se .slot_number );
1912
+ if ( status != PSA_SUCCESS )
1913
+ goto exit ;
1914
+ }
1915
+
1901
1916
status = psa_finish_key_creation ( slot , driver );
1902
1917
1903
1918
exit :
You can’t perform that action at this time.
0 commit comments