Skip to content

Commit 33efd26

Browse files
committed
Add mechanism to symmetric keys
F-2034
1 parent 148e1d6 commit 33efd26

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
@@ -6895,7 +6895,8 @@ CK_RV C_GenerateKey(CK_SESSION_HANDLE hSession,
68956895
&key);
68966896
if (rv == CKR_OK) {
68976897
int ret = WP11_GenerateRandomKey(key,
6898-
WP11_Session_GetSlot(session));
6898+
WP11_Session_GetSlot(session),
6899+
pMechanism->mechanism);
68996900
if (ret != 0) {
69006901
WP11_Object_Free(key);
69016902
rv = CKR_FUNCTION_FAILED;

src/internal.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12340,12 +12340,14 @@ int WP11_Mldsa_Verify(unsigned char* sig, word32 sigLen, unsigned char* data,
1234012340
/**
1234112341
* Generate a secret key.
1234212342
*
12343-
* @param secret [in] Secret object.
12344-
* @param slot [in] Slot operation is performed on.
12343+
* @param secret [in] Secret object.
12344+
* @param slot [in] Slot operation is performed on.
12345+
* @param mechanism [in] Key generation mechanism.
1234512346
* @return -ve on random number generation failure.
1234612347
* 0 on success.
1234712348
*/
12348-
int WP11_GenerateRandomKey(WP11_Object* secret, WP11_Slot* slot)
12349+
int WP11_GenerateRandomKey(WP11_Object* secret, WP11_Slot* slot,
12350+
CK_MECHANISM_TYPE mechanism)
1234912351
{
1235012352
int ret;
1235112353
WP11_Data* key = secret->data.symmKey;
@@ -12356,6 +12358,7 @@ int WP11_GenerateRandomKey(WP11_Object* secret, WP11_Slot* slot)
1235612358

1235712359
if (ret == 0) {
1235812360
secret->local = 1;
12361+
secret->keyGenMech = mechanism;
1235912362
}
1236012363

1236112364
return ret;

0 commit comments

Comments
 (0)