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 @@ -1914,6 +1914,21 @@ psa_status_t mbedtls_psa_register_se_key(
1914
1914
goto exit ;
1915
1915
}
1916
1916
1917
+ /* If the driver has a slot number validation method, call it.
1918
+ * If it doesn't, it means the secure element is unable to validate
1919
+ * anything and so we have to trust the application. */
1920
+ if ( drv -> key_management != NULL &&
1921
+ drv -> key_management -> p_validate_slot_number != NULL )
1922
+ {
1923
+ status = drv -> key_management -> p_validate_slot_number (
1924
+ psa_get_se_driver_context ( driver ),
1925
+ attributes ,
1926
+ PSA_KEY_CREATION_REGISTER ,
1927
+ slot -> data .se .slot_number );
1928
+ if ( status != PSA_SUCCESS )
1929
+ goto exit ;
1930
+ }
1931
+
1917
1932
status = psa_finish_key_creation ( slot , driver );
1918
1933
1919
1934
exit :
You can’t perform that action at this time.
0 commit comments