@@ -5768,22 +5768,38 @@ psa_status_t psa_generate_key( const psa_key_attributes_t *attributes,
5768
5768
psa_status_t status ;
5769
5769
psa_key_slot_t * slot = NULL ;
5770
5770
psa_se_drv_table_entry_t * driver = NULL ;
5771
+ #if defined(MBEDTLS_PSA_CRYPTO_SE_C )
5772
+ const psa_drv_se_t * drv ;
5773
+ psa_drv_se_context_t * drv_context ;
5774
+ #endif /* MBEDTLS_PSA_CRYPTO_SE_C */
5775
+
5771
5776
status = psa_start_key_creation ( attributes , handle , & slot , & driver );
5777
+ if ( status != PSA_SUCCESS )
5778
+ goto exit ;
5772
5779
#if defined(MBEDTLS_PSA_CRYPTO_SE_C )
5773
- if ( driver != NULL )
5780
+ if ( psa_get_se_driver ( slot -> lifetime , & drv , & drv_context ) )
5774
5781
{
5775
- /* Generating a key in a secure element is not implemented yet. */
5776
- status = PSA_ERROR_NOT_SUPPORTED ;
5782
+ if ( drv -> key_management == NULL ||
5783
+ drv -> key_management -> p_generate == NULL )
5784
+ {
5785
+ status = PSA_ERROR_NOT_SUPPORTED ;
5786
+ goto exit ;
5787
+ }
5788
+ status = drv -> key_management -> p_generate (
5789
+ drv_context ,
5790
+ slot -> data .se .slot_number , slot -> type , slot -> policy .usage ,
5791
+ attributes -> bits , NULL , 0 , NULL );
5777
5792
}
5793
+ else
5778
5794
#endif /* MBEDTLS_PSA_CRYPTO_SE_C */
5779
- if ( status == PSA_SUCCESS )
5780
5795
{
5781
5796
status = psa_generate_key_internal (
5782
5797
slot , attributes -> bits ,
5783
5798
attributes -> domain_parameters , attributes -> domain_parameters_size );
5784
5799
}
5785
5800
if ( status == PSA_SUCCESS )
5786
5801
status = psa_finish_key_creation ( slot , driver );
5802
+ exit :
5787
5803
if ( status != PSA_SUCCESS )
5788
5804
{
5789
5805
psa_fail_key_creation ( slot , driver );
0 commit comments