Skip to content

Commit d43355c

Browse files
committed
Add mechanism to symmetric keys
F-2034
1 parent 2eb7e7c commit d43355c

5 files changed

Lines changed: 404 additions & 5 deletions

File tree

src/crypto.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7051,7 +7051,8 @@ CK_RV C_GenerateKey(CK_SESSION_HANDLE hSession,
70517051
&key);
70527052
if (rv == CKR_OK) {
70537053
int ret = WP11_GenerateRandomKey(key,
7054-
WP11_Session_GetSlot(session));
7054+
WP11_Session_GetSlot(session),
7055+
pMechanism->mechanism);
70557056
if (ret != 0) {
70567057
WP11_Object_Free(key);
70577058
rv = CKR_FUNCTION_FAILED;

src/internal.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13148,12 +13148,14 @@ int WP11_Mldsa_Verify(unsigned char* sig, word32 sigLen, unsigned char* data,
1314813148
/**
1314913149
* Generate a secret key.
1315013150
*
13151-
* @param secret [in] Secret object.
13152-
* @param slot [in] Slot operation is performed on.
13151+
* @param secret [in] Secret object.
13152+
* @param slot [in] Slot operation is performed on.
13153+
* @param mechanism [in] Key generation mechanism.
1315313154
* @return -ve on random number generation failure.
1315413155
* 0 on success.
1315513156
*/
13156-
int WP11_GenerateRandomKey(WP11_Object* secret, WP11_Slot* slot)
13157+
int WP11_GenerateRandomKey(WP11_Object* secret, WP11_Slot* slot,
13158+
CK_MECHANISM_TYPE mechanism)
1315713159
{
1315813160
int ret;
1315913161
WP11_Data* key = secret->data.symmKey;
@@ -13164,6 +13166,7 @@ int WP11_GenerateRandomKey(WP11_Object* secret, WP11_Slot* slot)
1316413166

1316513167
if (ret == 0) {
1316613168
secret->local = 1;
13169+
secret->keyGenMech = mechanism;
1316713170
}
1316813171

1316913172
return ret;

0 commit comments

Comments
 (0)