@@ -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.
@@ -1519,6 +1529,7 @@ static psa_status_t psa_validate_key_attributes(
1519
1529
* In case of failure at any step, stop the sequence and call
1520
1530
* psa_fail_key_creation().
1521
1531
*
1532
+ * \param method An identification of the calling function.
1522
1533
* \param[in] attributes Key attributes for the new key.
1523
1534
* \param[out] handle On success, a handle for the allocated slot.
1524
1535
* \param[out] p_slot On success, a pointer to the prepared slot.
@@ -1531,6 +1542,7 @@ static psa_status_t psa_validate_key_attributes(
1531
1542
* You must call psa_fail_key_creation() to wipe and free the slot.
1532
1543
*/
1533
1544
static psa_status_t psa_start_key_creation (
1545
+ psa_key_creation_method_t method ,
1534
1546
const psa_key_attributes_t * attributes ,
1535
1547
psa_key_handle_t * handle ,
1536
1548
psa_key_slot_t * * p_slot ,
@@ -1539,6 +1551,7 @@ static psa_status_t psa_start_key_creation(
1539
1551
psa_status_t status ;
1540
1552
psa_key_slot_t * slot ;
1541
1553
1554
+ (void ) method ;
1542
1555
* p_drv = NULL ;
1543
1556
1544
1557
status = psa_validate_key_attributes ( attributes , p_drv );
@@ -1792,7 +1805,8 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes,
1792
1805
psa_key_slot_t * slot = NULL ;
1793
1806
psa_se_drv_table_entry_t * driver = NULL ;
1794
1807
1795
- status = psa_start_key_creation ( attributes , handle , & slot , & driver );
1808
+ status = psa_start_key_creation ( PSA_KEY_CREATION_IMPORT , attributes ,
1809
+ handle , & slot , & driver );
1796
1810
if ( status != PSA_SUCCESS )
1797
1811
goto exit ;
1798
1812
@@ -1895,7 +1909,8 @@ psa_status_t psa_copy_key( psa_key_handle_t source_handle,
1895
1909
if ( status != PSA_SUCCESS )
1896
1910
goto exit ;
1897
1911
1898
- status = psa_start_key_creation ( & actual_attributes ,
1912
+ status = psa_start_key_creation ( PSA_KEY_CREATION_COPY ,
1913
+ & actual_attributes ,
1899
1914
target_handle , & target_slot , & driver );
1900
1915
if ( status != PSA_SUCCESS )
1901
1916
goto exit ;
@@ -4813,7 +4828,8 @@ psa_status_t psa_key_derivation_output_key( const psa_key_attributes_t *attribut
4813
4828
psa_status_t status ;
4814
4829
psa_key_slot_t * slot = NULL ;
4815
4830
psa_se_drv_table_entry_t * driver = NULL ;
4816
- status = psa_start_key_creation ( attributes , handle , & slot , & driver );
4831
+ status = psa_start_key_creation ( PSA_KEY_CREATION_DERIVE ,
4832
+ attributes , handle , & slot , & driver );
4817
4833
#if defined(MBEDTLS_PSA_CRYPTO_SE_C )
4818
4834
if ( driver != NULL )
4819
4835
{
@@ -5851,7 +5867,8 @@ psa_status_t psa_generate_key( const psa_key_attributes_t *attributes,
5851
5867
psa_status_t status ;
5852
5868
psa_key_slot_t * slot = NULL ;
5853
5869
psa_se_drv_table_entry_t * driver = NULL ;
5854
- status = psa_start_key_creation ( attributes , handle , & slot , & driver );
5870
+ status = psa_start_key_creation ( PSA_KEY_CREATION_GENERATE ,
5871
+ attributes , handle , & slot , & driver );
5855
5872
#if defined(MBEDTLS_PSA_CRYPTO_SE_C )
5856
5873
if ( driver != NULL )
5857
5874
{
0 commit comments