Look up the SE driver when creating a key
When creating a key with a lifetime that places it in a secure
element, retrieve the appropriate driver table entry.
This commit doesn't yet achieve behavior: so far the code only
retrieves the driver, it doesn't call the driver.
diff --git a/library/psa_crypto_slot_management.c b/library/psa_crypto_slot_management.c
index 900aa41..eb24b6b 100644
--- a/library/psa_crypto_slot_management.c
+++ b/library/psa_crypto_slot_management.c
@@ -168,8 +168,20 @@
psa_status_t psa_validate_persistent_key_parameters(
psa_key_lifetime_t lifetime,
psa_key_file_id_t id,
+ const psa_se_drv_table_entry_t **p_drv,
int creating )
{
+ if( p_drv != NULL )
+ *p_drv = NULL;
+#if defined(MBEDTLS_PSA_CRYPTO_SE_C)
+ if( psa_key_lifetime_is_external( lifetime ) )
+ {
+ *p_drv = psa_get_se_driver_entry( lifetime );
+ if( *p_drv == NULL )
+ return( PSA_ERROR_INVALID_ARGUMENT );
+ }
+ else
+#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
if( lifetime != PSA_KEY_LIFETIME_PERSISTENT )
return( PSA_ERROR_INVALID_ARGUMENT );
@@ -194,7 +206,7 @@
*handle = 0;
status = psa_validate_persistent_key_parameters(
- PSA_KEY_LIFETIME_PERSISTENT, id, 0 );
+ PSA_KEY_LIFETIME_PERSISTENT, id, NULL, 0 );
if( status != PSA_SUCCESS )
return( status );