Skip to content

Commit 47e1453

Browse files
authored
Merge pull request #184 from LinuxJedi/verify-recover-test
Fix attributes in tests
2 parents f0fbfab + 0722e98 commit 47e1453

4 files changed

Lines changed: 15 additions & 7 deletions

File tree

.github/workflows/storage-upgrade-test-tpm.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ jobs:
9999
else
100100
echo "WOLFPKCS11_NO_STORE not found, assuming WOLFPKCS11_TOKEN_PATH is already set"
101101
fi
102+
# Patch test_verify_recover_op_not_supported on older bases that
103+
# still set CKA_VERIFY=FALSE (the op check now uses CKA_VERIFY_RECOVER).
104+
sed -i '/CK_ATTRIBUTE rsaPubNoVerify/,/};/{s/CKA_VERIFY,/CKA_VERIFY_RECOVER,/;}' tests/pkcs11test.c
102105
echo "=== pkcs11test.c modification completed ==="
103106
104107
- name: Build wolfPKCS11 ${{ matrix.base-ref.name }} with TPM

.github/workflows/storage-upgrade-test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ jobs:
8080
else
8181
echo "WOLFPKCS11_NO_STORE not found, assuming WOLFPKCS11_TOKEN_PATH is already set"
8282
fi
83+
# Patch test_verify_recover_op_not_supported on older bases that
84+
# still set CKA_VERIFY=FALSE (the op check now uses CKA_VERIFY_RECOVER).
85+
sed -i '/CK_ATTRIBUTE rsaPubNoVerify/,/};/{s/CKA_VERIFY,/CKA_VERIFY_RECOVER,/;}' tests/pkcs11test.c
8386
echo "=== pkcs11test.c modification completed ==="
8487
8588
- name: Build wolfPKCS11 ${{ matrix.base-ref.name }}

tests/pkcs11mtt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6681,10 +6681,12 @@ static CK_RV mlkem_encap_decap(CK_SESSION_HANDLE session,
66816681
funcListExt = (CK_FUNCTION_LIST_3_2*)interface->pFunctionList;
66826682
CK_OBJECT_CLASS secClass = CKO_SECRET_KEY;
66836683
CK_BBOOL extr = CK_TRUE;
6684+
CK_BBOOL sensitive = CK_FALSE;
66846685
CK_ATTRIBUTE secretTmpl[] = {
66856686
{ CKA_CLASS, &secClass, sizeof(secClass) },
66866687
{ CKA_KEY_TYPE, &genericKeyType, sizeof(genericKeyType) },
66876688
{ CKA_EXTRACTABLE, &extr, sizeof(extr) },
6689+
{ CKA_SENSITIVE, &sensitive, sizeof(sensitive) },
66886690
};
66896691
CK_ULONG secretTmplCnt = sizeof(secretTmpl) / sizeof(*secretTmpl);
66906692
CK_OBJECT_HANDLE encapKey = CK_INVALID_HANDLE;

tests/pkcs11test.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5777,23 +5777,23 @@ static CK_RV test_verify_recover_op_not_supported(void* args)
57775777
CK_BBOOL trueVal = CK_TRUE;
57785778
CK_MECHANISM mech = { CKM_RSA_PKCS, NULL_PTR, 0 };
57795779

5780-
CK_ATTRIBUTE rsaPubNoVerify[] = {
5780+
CK_ATTRIBUTE rsaPubNoVerifyRecover[] = {
57815781
{ CKA_CLASS, &pubKeyClass, sizeof(pubKeyClass) },
57825782
{ CKA_KEY_TYPE, &rsaKeyType, sizeof(rsaKeyType) },
57835783
{ CKA_ENCRYPT, &trueVal, sizeof(trueVal) },
5784-
{ CKA_VERIFY, &falseVal, sizeof(falseVal) },
5784+
{ CKA_VERIFY_RECOVER, &falseVal, sizeof(falseVal) },
57855785
{ CKA_MODULUS, rsa_2048_modulus, sizeof(rsa_2048_modulus) },
57865786
{ CKA_PUBLIC_EXPONENT, rsa_2048_pub_exp, sizeof(rsa_2048_pub_exp) },
57875787
};
57885788

5789-
ret = funcList->C_CreateObject(session, rsaPubNoVerify,
5790-
sizeof(rsaPubNoVerify)/sizeof(*rsaPubNoVerify),
5791-
&pubKey);
5792-
CHECK_CKR(ret, "Create RSA pub key with CKA_VERIFY=FALSE");
5789+
ret = funcList->C_CreateObject(session, rsaPubNoVerifyRecover,
5790+
sizeof(rsaPubNoVerifyRecover)/sizeof(*rsaPubNoVerifyRecover),
5791+
&pubKey);
5792+
CHECK_CKR(ret, "Create RSA pub key with CKA_VERIFY_RECOVER=FALSE");
57935793
if (ret == CKR_OK) {
57945794
ret = funcList->C_VerifyRecoverInit(session, &mech, pubKey);
57955795
CHECK_CKR_FAIL(ret, CKR_KEY_TYPE_INCONSISTENT,
5796-
"VerifyRecoverInit should fail with CKA_VERIFY=FALSE");
5796+
"VerifyRecoverInit should fail with CKA_VERIFY_RECOVER=FALSE");
57975797
}
57985798

57995799
return ret;

0 commit comments

Comments
 (0)