Skip to content

Commit 65f89f5

Browse files
committed
Add mechanism to NSS generated keys
F-2037
1 parent 9f069de commit 65f89f5

5 files changed

Lines changed: 436 additions & 0 deletions

File tree

src/crypto.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6915,6 +6915,7 @@ CK_RV C_GenerateKey(CK_SESSION_HANDLE hSession,
69156915

69166916
ret = WP11_Object_SetSecretKey(pbkdf2Key, secretKeyData, secretKeyLen);
69176917
if (ret == 0) {
6918+
WP11_Object_SetKeyGeneration(pbkdf2Key, pMechanism->mechanism);
69186919
rv = AddObject(session, pbkdf2Key, pTemplate, ulCount, phKey);
69196920
if (rv != CKR_OK) {
69206921
WP11_Object_Free(pbkdf2Key);
@@ -7012,6 +7013,7 @@ CK_RV C_GenerateKey(CK_SESSION_HANDLE hSession,
70127013

70137014
ret = WP11_Object_SetSecretKey(pbeKey, secretKeyData, secretKeyLen);
70147015
if (ret == 0) {
7016+
WP11_Object_SetKeyGeneration(pbeKey, pMechanism->mechanism);
70157017
rv = AddObject(session, pbeKey, pTemplate, ulCount, phKey);
70167018
if (rv != CKR_OK) {
70177019
WP11_Object_Free(pbeKey);

src/internal.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11439,6 +11439,19 @@ int WP11_Object_SetAttr(WP11_Object* object, CK_ATTRIBUTE_TYPE type, byte* data,
1143911439
return ret;
1144011440
}
1144111441

11442+
/**
11443+
* Mark an object as locally generated and record the mechanism used.
11444+
*
11445+
* @param object [in] Object to update.
11446+
* @param mechanism [in] Generation mechanism.
11447+
*/
11448+
void WP11_Object_SetKeyGeneration(WP11_Object* object,
11449+
CK_MECHANISM_TYPE mechanism)
11450+
{
11451+
object->local = 1;
11452+
object->keyGenMech = mechanism;
11453+
}
11454+
1144211455
/**
1144311456
* Check whether the attribute matches in the object.
1144411457
*

tests/include.am

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ noinst_PROGRAMS += tests/aes_keygen_attrs_test
6666
tests_aes_keygen_attrs_test_SOURCES = tests/aes_keygen_attrs_test.c
6767
tests_aes_keygen_attrs_test_LDADD =
6868

69+
check_PROGRAMS += tests/pbkdf2_keygen_attrs_test
70+
noinst_PROGRAMS += tests/pbkdf2_keygen_attrs_test
71+
tests_pbkdf2_keygen_attrs_test_SOURCES = tests/pbkdf2_keygen_attrs_test.c
72+
tests_pbkdf2_keygen_attrs_test_LDADD =
73+
6974
check_PROGRAMS += tests/pkcs11v3test
7075
noinst_PROGRAMS += tests/pkcs11v3test
7176
tests_pkcs11v3test_SOURCES = tests/pkcs11v3test.c
@@ -85,6 +90,7 @@ tests_aes_cbc_pad_padding_test_LDADD += src/libwolfpkcs11.la
8590
tests_ecb_check_value_error_test_LDADD += src/libwolfpkcs11.la
8691
tests_operation_active_test_LDADD += src/libwolfpkcs11.la
8792
tests_aes_keygen_attrs_test_LDADD += src/libwolfpkcs11.la
93+
tests_pbkdf2_keygen_attrs_test_LDADD += src/libwolfpkcs11.la
8894
tests_pkcs11v3test_LDADD += src/libwolfpkcs11.la
8995
else
9096
tests_object_id_uniqueness_test_LDADD += src/libwolfpkcs11.la
@@ -94,6 +100,7 @@ tests_aes_cbc_pad_padding_test_LDADD += src/libwolfpkcs11.la
94100
tests_ecb_check_value_error_test_LDADD += src/libwolfpkcs11.la
95101
tests_operation_active_test_LDADD += src/libwolfpkcs11.la
96102
tests_aes_keygen_attrs_test_LDADD += src/libwolfpkcs11.la
103+
tests_pbkdf2_keygen_attrs_test_LDADD += src/libwolfpkcs11.la
97104
endif
98105

99106
EXTRA_DIST += tests/unit.h \

0 commit comments

Comments
 (0)