@@ -1506,6 +1506,16 @@ static psa_status_t psa_validate_key_attributes(
1506
1506
return ( PSA_SUCCESS );
1507
1507
}
1508
1508
1509
+ /** An enumeration indicating how a key is created.
1510
+ */
1511
+ typedef enum
1512
+ {
1513
+ PSA_KEY_CREATION_IMPORT ,
1514
+ PSA_KEY_CREATION_GENERATE ,
1515
+ PSA_KEY_CREATION_DERIVE ,
1516
+ PSA_KEY_CREATION_COPY ,
1517
+ } psa_key_creation_method_t ;
1518
+
1509
1519
/** Prepare a key slot to receive key material.
1510
1520
*
1511
1521
* This function allocates a key slot and sets its metadata.
@@ -1520,6 +1530,7 @@ static psa_status_t psa_validate_key_attributes(
1520
1530
* In case of failure at any step, stop the sequence and call
1521
1531
* psa_fail_key_creation().
1522
1532
*
1533
+ * \param method An identification of the calling function.
1523
1534
* \param[in] attributes Key attributes for the new key.
1524
1535
* \param[out] handle On success, a handle for the allocated slot.
1525
1536
* \param[out] p_slot On success, a pointer to the prepared slot.
@@ -1532,6 +1543,7 @@ static psa_status_t psa_validate_key_attributes(
1532
1543
* You must call psa_fail_key_creation() to wipe and free the slot.
1533
1544
*/
1534
1545
static psa_status_t psa_start_key_creation (
1546
+ psa_key_creation_method_t method ,
1535
1547
const psa_key_attributes_t * attributes ,
1536
1548
psa_key_handle_t * handle ,
1537
1549
psa_key_slot_t * * p_slot ,
@@ -1540,6 +1552,7 @@ static psa_status_t psa_start_key_creation(
1540
1552
psa_status_t status ;
1541
1553
psa_key_slot_t * slot ;
1542
1554
1555
+ (void ) method ;
1543
1556
* p_drv = NULL ;
1544
1557
1545
1558
status = psa_validate_key_attributes ( attributes , p_drv );
@@ -1796,7 +1809,8 @@ psa_status_t psa_import_key( const psa_key_attributes_t *attributes,
1796
1809
psa_key_slot_t * slot = NULL ;
1797
1810
psa_se_drv_table_entry_t * driver = NULL ;
1798
1811
1799
- status = psa_start_key_creation ( attributes , handle , & slot , & driver );
1812
+ status = psa_start_key_creation ( PSA_KEY_CREATION_IMPORT , attributes ,
1813
+ handle , & slot , & driver );
1800
1814
if ( status != PSA_SUCCESS )
1801
1815
goto exit ;
1802
1816
@@ -1899,7 +1913,8 @@ psa_status_t psa_copy_key( psa_key_handle_t source_handle,
1899
1913
if ( status != PSA_SUCCESS )
1900
1914
goto exit ;
1901
1915
1902
- status = psa_start_key_creation ( & actual_attributes ,
1916
+ status = psa_start_key_creation ( PSA_KEY_CREATION_COPY ,
1917
+ & actual_attributes ,
1903
1918
target_handle , & target_slot , & driver );
1904
1919
if ( status != PSA_SUCCESS )
1905
1920
goto exit ;
@@ -4817,7 +4832,8 @@ psa_status_t psa_key_derivation_output_key( const psa_key_attributes_t *attribut
4817
4832
psa_status_t status ;
4818
4833
psa_key_slot_t * slot = NULL ;
4819
4834
psa_se_drv_table_entry_t * driver = NULL ;
4820
- status = psa_start_key_creation ( attributes , handle , & slot , & driver );
4835
+ status = psa_start_key_creation ( PSA_KEY_CREATION_DERIVE ,
4836
+ attributes , handle , & slot , & driver );
4821
4837
#if defined(MBEDTLS_PSA_CRYPTO_SE_C )
4822
4838
if ( driver != NULL )
4823
4839
{
@@ -5863,7 +5879,8 @@ psa_status_t psa_generate_key( const psa_key_attributes_t *attributes,
5863
5879
psa_status_t status ;
5864
5880
psa_key_slot_t * slot = NULL ;
5865
5881
psa_se_drv_table_entry_t * driver = NULL ;
5866
- status = psa_start_key_creation ( attributes , handle , & slot , & driver );
5882
+ status = psa_start_key_creation ( PSA_KEY_CREATION_GENERATE ,
5883
+ attributes , handle , & slot , & driver );
5867
5884
#if defined(MBEDTLS_PSA_CRYPTO_SE_C )
5868
5885
if ( driver != NULL )
5869
5886
{
0 commit comments