Skip to content

Commit

Permalink
Merge pull request #24 from dgarske/portability
Browse files Browse the repository at this point in the history
Portability fixes
  • Loading branch information
SparkiDev authored Dec 14, 2023
2 parents ffb7f06 + 91a8b5f commit b18d011
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
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

0 comments on commit b18d011

Please sign in to comment.