@@ -1505,6 +1505,16 @@ static psa_status_t psa_validate_key_attributes(
1505
1505
return ( PSA_SUCCESS );
1506
1506
}
1507
1507
1508
+ /** An enumeration indicating how a key is created.
1509
+ */
1510
+ typedef enum
1511
+ {
1512
+ PSA_KEY_CREATION_IMPORT ,
1513
+ PSA_KEY_CREATION_GENERATE ,
1514
+ PSA_KEY_CREATION_DERIVE ,
1515
+ PSA_KEY_CREATION_COPY ,
1516
+ } psa_key_creation_method_t ;
1517
+
1508
1518
/** Prepare a key slot to receive key material.
1509
1519
*
1510
1520
* This function allocates a key slot and sets its metadata.
@@ -1531,6 +1541,7 @@ static psa_status_t psa_validate_key_attributes(
1531
1541
* You must call psa_fail_key_creation() to wipe and free the slot.
1532
1542
*/
1533
1543
static psa_status_t psa_start_key_creation (
1544
+ psa_key_creation_method_t method ,
1534
1545
const psa_key_attributes_t * attributes ,
1535
1546
psa_key_handle_t * handle ,
1536
1547
psa_key_slot_t * * p_slot ,
@@ -1539,6 +1550,7 @@ static psa_status_t psa_start_key_creation(
1539
1550
psa_status_t status ;
1540
1551
psa_key_slot_t * slot ;
1541
1552
1553
+ (void ) method ;
1542
1554
* p_drv = NULL ;
1543
1555
1544
1556
status = psa_validate_key_attributes ( attributes , p_drv );
@@ -1792,7 +1804,8 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes,
1792
1804
psa_key_slot_t * slot = NULL ;
1793
1805
psa_se_drv_table_entry_t * driver = NULL ;
1794
1806
1795
- status = psa_start_key_creation ( attributes , handle , & slot , & driver );
1807
+ status = psa_start_key_creation ( PSA_KEY_CREATION_IMPORT , attributes ,
1808
+ handle , & slot , & driver );
1796
1809
if ( status != PSA_SUCCESS )
1797
1810
goto exit ;
1798
1811
@@ -1895,7 +1908,8 @@ psa_status_t psa_copy_key( psa_key_handle_t source_handle,
1895
1908
if ( status != PSA_SUCCESS )
1896
1909
goto exit ;
1897
1910
1898
- status = psa_start_key_creation ( & actual_attributes ,
1911
+ status = psa_start_key_creation ( PSA_KEY_CREATION_COPY ,
1912
+ & actual_attributes ,
1899
1913
target_handle , & target_slot , & driver );
1900
1914
if ( status != PSA_SUCCESS )
1901
1915
goto exit ;
@@ -4813,7 +4827,8 @@ psa_status_t psa_key_derivation_output_key( const psa_key_attributes_t *attribut
4813
4827
psa_status_t status ;
4814
4828
psa_key_slot_t * slot = NULL ;
4815
4829
psa_se_drv_table_entry_t * driver = NULL ;
4816
- status = psa_start_key_creation ( attributes , handle , & slot , & driver );
4830
+ status = psa_start_key_creation ( PSA_KEY_CREATION_DERIVE ,
4831
+ attributes , handle , & slot , & driver );
4817
4832
#if defined(MBEDTLS_PSA_CRYPTO_SE_C )
4818
4833
if ( driver != NULL )
4819
4834
{
@@ -5851,7 +5866,8 @@ psa_status_t psa_generate_key( const psa_key_attributes_t *attributes,
5851
5866
psa_status_t status ;
5852
5867
psa_key_slot_t * slot = NULL ;
5853
5868
psa_se_drv_table_entry_t * driver = NULL ;
5854
- status = psa_start_key_creation ( attributes , handle , & slot , & driver );
5869
+ status = psa_start_key_creation ( PSA_KEY_CREATION_GENERATE ,
5870
+ attributes , handle , & slot , & driver );
5855
5871
#if defined(MBEDTLS_PSA_CRYPTO_SE_C )
5856
5872
if ( driver != NULL )
5857
5873
{
0 commit comments