Skip to content

Commit c8d6a4d

Browse files
committed
Add mechanism to NSS generated keys
F-2037
1 parent dc5bd0d commit c8d6a4d

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
@@ -6759,6 +6759,7 @@ CK_RV C_GenerateKey(CK_SESSION_HANDLE hSession,
67596759

67606760
ret = WP11_Object_SetSecretKey(pbkdf2Key, secretKeyData, secretKeyLen);
67616761
if (ret == 0) {
6762+
WP11_Object_SetKeyGeneration(pbkdf2Key, pMechanism->mechanism);
67626763
rv = AddObject(session, pbkdf2Key, pTemplate, ulCount, phKey);
67636764
if (rv != CKR_OK) {
67646765
WP11_Object_Free(pbkdf2Key);
@@ -6856,6 +6857,7 @@ CK_RV C_GenerateKey(CK_SESSION_HANDLE hSession,
68566857

68576858
ret = WP11_Object_SetSecretKey(pbeKey, secretKeyData, secretKeyLen);
68586859
if (ret == 0) {
6860+
WP11_Object_SetKeyGeneration(pbeKey, pMechanism->mechanism);
68596861
rv = AddObject(session, pbeKey, pTemplate, ulCount, phKey);
68606862
if (rv != CKR_OK) {
68616863
WP11_Object_Free(pbeKey);

src/internal.c

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

10630+
/**
10631+
* Mark an object as locally generated and record the mechanism used.
10632+
*
10633+
* @param object [in] Object to update.
10634+
* @param mechanism [in] Generation mechanism.
10635+
*/
10636+
void WP11_Object_SetKeyGeneration(WP11_Object* object,
10637+
CK_MECHANISM_TYPE mechanism)
10638+
{
10639+
object->local = 1;
10640+
object->keyGenMech = mechanism;
10641+
}
10642+
1063010643
/**
1063110644
* Check whether the attribute matches in the object.
1063210645
*

tests/include.am

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ noinst_PROGRAMS += tests/aes_keygen_attrs_test
6161
tests_aes_keygen_attrs_test_SOURCES = tests/aes_keygen_attrs_test.c
6262
tests_aes_keygen_attrs_test_LDADD =
6363

64+
check_PROGRAMS += tests/pbkdf2_keygen_attrs_test
65+
noinst_PROGRAMS += tests/pbkdf2_keygen_attrs_test
66+
tests_pbkdf2_keygen_attrs_test_SOURCES = tests/pbkdf2_keygen_attrs_test.c
67+
tests_pbkdf2_keygen_attrs_test_LDADD =
68+
6469
check_PROGRAMS += tests/pkcs11v3test
6570
noinst_PROGRAMS += tests/pkcs11v3test
6671
tests_pkcs11v3test_SOURCES = tests/pkcs11v3test.c
@@ -79,6 +84,7 @@ tests_find_objects_null_template_test_LDADD += src/libwolfpkcs11.la
7984
tests_aes_cbc_pad_padding_test_LDADD += src/libwolfpkcs11.la
8085
tests_ecb_check_value_error_test_LDADD += src/libwolfpkcs11.la
8186
tests_aes_keygen_attrs_test_LDADD += src/libwolfpkcs11.la
87+
tests_pbkdf2_keygen_attrs_test_LDADD += src/libwolfpkcs11.la
8288
tests_pkcs11v3test_LDADD += src/libwolfpkcs11.la
8389
else
8490
tests_object_id_uniqueness_test_LDADD += src/libwolfpkcs11.la
@@ -87,6 +93,7 @@ tests_find_objects_null_template_test_LDADD += src/libwolfpkcs11.la
8793
tests_aes_cbc_pad_padding_test_LDADD += src/libwolfpkcs11.la
8894
tests_ecb_check_value_error_test_LDADD += src/libwolfpkcs11.la
8995
tests_aes_keygen_attrs_test_LDADD += src/libwolfpkcs11.la
96+
tests_pbkdf2_keygen_attrs_test_LDADD += src/libwolfpkcs11.la
9097
endif
9198

9299
EXTRA_DIST += tests/unit.h \

0 commit comments

Comments
 (0)