Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portability fixes #24

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions tests/pkcs11mtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include <stdio.h>

#ifdef _POSIX_THREADS
#if defined(_POSIX_THREADS) && !defined(SINGLE_THREADED)
#include <wolfssl/wolfcrypt/misc.h>
#include <wolfpkcs11/pkcs11.h>

Expand All @@ -49,14 +49,14 @@ static void* dlib;
#endif
static CK_FUNCTION_LIST* funcList;
static int slot;
const char* tokenName = "wolfpkcs11";
static const char* tokenName = "wolfpkcs11";

/* FIPS requires pin to be at least 14 characters, since it is used for
* the HMAC key */
static byte* soPin = (byte*)"password123456";
static int soPinLen = 14;
byte* userPin = (byte*)"wolfpkcs11-test";
int userPinLen;
static byte* userPin = (byte*)"wolfpkcs11-test";
static int userPinLen;

#if !defined(NO_RSA) || defined(HAVE_ECC) || !defined(NO_DH)
static CK_OBJECT_CLASS pubKeyClass = CKO_PUBLIC_KEY;
Expand Down Expand Up @@ -6482,7 +6482,11 @@ static void Usage(void)
printf("<num> Test case number to try\n");
}

#ifndef NO_MAIN_DRIVER
int main(int argc, char* argv[])
#else
int pkcs11test_mtt(int argc, char* argv[])
#endif
{
int ret;
CK_RV rv;
Expand Down Expand Up @@ -6603,12 +6607,16 @@ int main(int argc, char* argv[])

#else

#ifndef NO_MAIN_DRIVER
int main(int argc, char* argv[])
#else
int pkcs11test_mtt(int argc, char* argv[])
#endif
{
(void)argc;
(void)argv;
fprintf(stderr, "%s: multi-threaded example not compiled in!\n", argv[0]);
return 0;
}

#endif /* _POSIX_THREADS */
#endif /* _POSIX_THREADS && !SINGLE_THREADED */
10 changes: 7 additions & 3 deletions tests/pkcs11str.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ static void* dlib;
#endif
static CK_FUNCTION_LIST* funcList;
static int slot = 0;
const char* tokenName = "wolfpkcs11";
static const char* tokenName = "wolfpkcs11";

/* FIPS requires pin to be at least 14 characters, since it is used for
* the HMAC key */
static byte* soPin = (byte*)"password123456";
static int soPinLen = 14;
byte* userPin = (byte*)"wolfpkcs11-test";
int userPinLen;
static byte* userPin = (byte*)"wolfpkcs11-test";
static int userPinLen;

#if !defined(NO_RSA) || defined(HAVE_ECC) || !defined(NO_DH)
static CK_OBJECT_CLASS pubKeyClass = CKO_PUBLIC_KEY;
Expand Down Expand Up @@ -909,7 +909,11 @@ static int string_matches(const char* arg, const char* str)
return XSTRNCMP(arg, str, len) == 0;
}

#ifndef NO_MAIN_DRIVER
int main(int argc, char* argv[])
#else
int pkcs11test_str(int argc, char* argv[])
#endif
{
int ret;
CK_RV rv;
Expand Down
12 changes: 8 additions & 4 deletions tests/pkcs11test.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ static void* dlib;
#endif
static CK_FUNCTION_LIST* funcList;
static int slot = 0;
const char* tokenName = "wolfpkcs11";
static const char* tokenName = "wolfpkcs11";

/* FIPS requires pin to be at least 14 characters, since it is used for
* the HMAC key */
static byte* soPin = (byte*)"password123456";
static int soPinLen = 14;
byte* userPin = (byte*)"wolfpkcs11-test";
int userPinLen;
static byte* userPin = (byte*)"wolfpkcs11-test";
static int userPinLen;

#if !defined(NO_RSA) || defined(HAVE_ECC) || !defined(NO_DH)
static CK_OBJECT_CLASS pubKeyClass = CKO_PUBLIC_KEY;
Expand Down Expand Up @@ -7896,7 +7896,11 @@ static void Usage(void)
printf("<num> Test case number to try\n");
}

#ifndef NO_MAIN_DRIVER
int main(int argc, char* argv[])
#else
int pkcs11test_test(int argc, char* argv[])
#endif
{
int ret;
CK_RV rv;
Expand Down Expand Up @@ -7974,7 +7978,7 @@ int main(int argc, char* argv[])
fprintf(stderr, "%d: %s\n", i + 1, testFunc[i].name);
return 0;
}
else if (isdigit(argv[0][0])) {
else if (isdigit((int)argv[0][0])) {
testCase = atoi(*argv);
if (testCase <= 0 || testCase > testFuncCnt) {
fprintf(stderr, "Test case out of range: %s\n", *argv);
Expand Down