Skip to content

Commit 1906949

Browse files
committed
Minor test fixes and version improvements
1 parent 2bde1da commit 1906949

File tree

5 files changed

+49
-12
lines changed

5 files changed

+49
-12
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ examples/obj_list
5050
examples/slot_info
5151
examples/token_info
5252
store/wp11*
53+
store/debug
54+
store/empty_pin_test
5355
store/object
5456
store/pkcs11mtt
5557
store/pkcs11test
58+
store/pkcs11v3test
5659
store/rsa
5760
store/str
5861
test/*
@@ -63,6 +66,7 @@ test/*
6366
.settings
6467
add_cert_file
6568
.cache
69+
compile_commands.json
6670

6771
tests/wp11_rsakey_*
6872
tests/wp11_dhkey_*
@@ -72,6 +76,7 @@ tests/wp11_token_*
7276
tests/wp11_obj_*
7377
tests/token_path_test
7478
tests/rsa_session_persistence_test
79+
tests/empty_pin_store_test
7580

7681
IDE/VisualStudio/.vs
7782

src/wolfpkcs11.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
#include <wolfpkcs11/pkcs11.h>
2727
#include <wolfpkcs11/internal.h>
2828

29-
/* Function list table. */
29+
/* Function list table for PKCS#11 v2.40 */
3030
static CK_FUNCTION_LIST wolfpkcs11FunctionList = {
31-
{ 2, 40 },
31+
/* Version: Major, Minor */
32+
{ 2, 40 },
3233

3334
C_Initialize,
3435
C_Finalize,
@@ -104,8 +105,10 @@ static CK_FUNCTION_LIST wolfpkcs11FunctionList = {
104105

105106
CK_RV C_GetInfoV3_0(CK_INFO_PTR pInfo);
106107

108+
/* Function list table for PKCS#11 v3.0 */
107109
static CK_FUNCTION_LIST_3_0 wolfpkcs11FunctionList_3_0 = {
108-
{ 3, 0 },
110+
/* Version: Major, Minor */
111+
{ 3, 0 },
109112

110113
C_Initialize,
111114
C_Finalize,
@@ -207,8 +210,10 @@ static CK_FUNCTION_LIST_3_0 wolfpkcs11FunctionList_3_0 = {
207210

208211
CK_RV C_GetInfoV3_2(CK_INFO_PTR pInfo);
209212

213+
/* Function list table for PKCS#11 v3.2 */
210214
static CK_FUNCTION_LIST_3_2 wolfpkcs11FunctionList_3_2 = {
211-
{ CRYPTOKI_VERSION_MAJOR, CRYPTOKI_VERSION_MINOR },
215+
/* Version: Major, Minor */
216+
{ 3, 2 },
212217

213218
C_Initialize,
214219
C_Finalize,

tests/pkcs11mtt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ static CK_RV test_recover(void* args)
15231523
}
15241524
if (ret == CKR_OK) {
15251525
ret = funcList->C_VerifyRecover(session, sig, sigSz, data, &dataSz);
1526-
#ifndef NO_RSA
1526+
#if !defined(NO_RSA) && defined(WC_RSA_DIRECT)
15271527
CHECK_CKR_FAIL(ret, CKR_OPERATION_NOT_INITIALIZED,
15281528
"Verify Recover not initialized");
15291529
#else

tests/pkcs11test.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,20 @@ static CK_RV test_pkcs5_pbkdf2_key_gen(void* args)
18881888
}
18891889
#endif
18901890

1891+
#ifdef WOLFSSL_SHA384
1892+
if (ret == CKR_OK) {
1893+
CK_PKCS5_PBKD2_PARAMS sha384Params = pbkdf2Params;
1894+
CK_MECHANISM sha384Mech = mechanism;
1895+
sha384Params.prf = CKP_PKCS5_PBKD2_HMAC_SHA384;
1896+
sha384Mech.pParameter = &sha384Params;
1897+
1898+
ret = funcList->C_GenerateKey(session, &sha384Mech, keyTemplate,
1899+
sizeof(keyTemplate)/sizeof(CK_ATTRIBUTE), &key);
1900+
CHECK_CKR(ret, "PKCS#5 PBKDF2 with SHA384");
1901+
}
1902+
#endif
1903+
1904+
#ifdef WOLFSSL_SHA512
18911905
if (ret == CKR_OK) {
18921906
CK_PKCS5_PBKD2_PARAMS sha512Params = pbkdf2Params;
18931907
CK_MECHANISM sha512Mech = mechanism;
@@ -1898,6 +1912,7 @@ static CK_RV test_pkcs5_pbkdf2_key_gen(void* args)
18981912
sizeof(keyTemplate)/sizeof(CK_ATTRIBUTE), &key);
18991913
CHECK_CKR(ret, "PKCS#5 PBKDF2 with SHA512");
19001914
}
1915+
#endif
19011916

19021917
return ret;
19031918
}
@@ -2460,7 +2475,7 @@ static CK_RV test_copy_object_deep_copy(void* args)
24602475
return ret;
24612476
}
24622477

2463-
#if (!defined(NO_RSA) && !defined(WOLFPKCS11_TPM))
2478+
#if (!defined(NO_RSA) && !defined(WOLFPKCS11_TPM) && defined(WOLFSSL_KEY_GEN))
24642479
static CK_RV test_copy_object_rsa_key(void* args)
24652480
{
24662481
CK_SESSION_HANDLE session = *(CK_SESSION_HANDLE*)args;
@@ -5353,7 +5368,7 @@ static CK_RV test_recover(void* args)
53535368
}
53545369
if (ret == CKR_OK) {
53555370
ret = funcList->C_VerifyRecover(session, sig, sigSz, data, &dataSz);
5356-
#ifndef NO_RSA
5371+
#if !defined(NO_RSA) && defined(WC_RSA_DIRECT)
53575372
CHECK_CKR_FAIL(ret, CKR_OPERATION_NOT_INITIALIZED,
53585373
"Verify Recover not initialized");
53595374
#else
@@ -5365,7 +5380,7 @@ static CK_RV test_recover(void* args)
53655380
return ret;
53665381
}
53675382

5368-
#ifndef NO_RSA
5383+
#if !defined(NO_RSA) && defined(WC_RSA_DIRECT)
53695384
static CK_RV rsa_verify_recover(CK_SESSION_HANDLE session,
53705385
CK_MECHANISM_TYPE mech_type)
53715386
{
@@ -15762,7 +15777,7 @@ static TEST_FUNC testFunc[] = {
1576215777
PKCS11TEST_FUNC_SESS_DECL(test_op_state_fail),
1576315778
PKCS11TEST_FUNC_SESS_DECL(test_object),
1576415779
PKCS11TEST_FUNC_SESS_DECL(test_copy_object_deep_copy),
15765-
#if (!defined(NO_RSA) && !defined(WOLFPKCS11_TPM))
15780+
#if (!defined(NO_RSA) && !defined(WOLFPKCS11_TPM) && defined(WOLFSSL_KEY_GEN))
1576615781
PKCS11TEST_FUNC_SESS_DECL(test_copy_object_rsa_key),
1576715782
#endif
1576815783
#ifdef HAVE_ECC
@@ -15793,7 +15808,7 @@ static TEST_FUNC testFunc[] = {
1579315808
PKCS11TEST_FUNC_SESS_DECL(test_digest_fail),
1579415809
PKCS11TEST_FUNC_SESS_DECL(test_sign_verify),
1579515810
PKCS11TEST_FUNC_SESS_DECL(test_recover),
15796-
#ifndef NO_RSA
15811+
#if !defined(NO_RSA) && defined(WC_RSA_DIRECT)
1579715812
PKCS11TEST_FUNC_SESS_DECL(test_verify_recover_pkcs),
1579815813
PKCS11TEST_FUNC_SESS_DECL(test_verify_recover_x509),
1579915814
#endif

wolfpkcs11/pkcs11.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#ifdef WOLFPKCS11_USER_SETTINGS
2626
#include "user_settings.h"
27+
#else
28+
#include <wolfpkcs11/options.h>
2729
#endif
2830

2931
#include <wolfpkcs11/visibility.h>
@@ -73,8 +75,18 @@ extern "C" {
7375

7476
#define CK_NULL_PTR NULL_PTR
7577

76-
#define CRYPTOKI_VERSION_MAJOR 3
77-
#define CRYPTOKI_VERSION_MINOR 2
78+
#ifndef CRYPTOKI_VERSION_MAJOR
79+
#if defined(WOLFPKCS11_PKCS11_V3_2)
80+
#define CRYPTOKI_VERSION_MAJOR 3
81+
#define CRYPTOKI_VERSION_MINOR 2
82+
#elif defined(WOLFPKCS11_PKCS11_V3_0)
83+
#define CRYPTOKI_VERSION_MAJOR 3
84+
#define CRYPTOKI_VERSION_MINOR 0
85+
#else
86+
#define CRYPTOKI_VERSION_MAJOR 2
87+
#define CRYPTOKI_VERSION_MINOR 40
88+
#endif
89+
#endif
7890

7991

8092
#define CK_INVALID_HANDLE 0UL

0 commit comments

Comments
 (0)