Skip to content

Commit

Permalink
Fixes to get pkcs11 tests passing on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske committed Jan 23, 2024
1 parent e77e785 commit 30f346b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
9 changes: 7 additions & 2 deletions IDE/VisualStudio/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ extern "C" {

/* PKCS11 TPM */
#define WOLFPKCS11_TPM
#define WOLFPKCS11_TPM_STORE
#ifndef WOLFTPM_WINAPI
/* Windows does not allow TPM NV use */
#define WOLFPKCS11_TPM_STORE
#endif

/* TLS */
#if 0
Expand Down Expand Up @@ -124,7 +127,9 @@ extern "C" {

/* RNG */
#define HAVE_HASHDRBG
#define WC_RNG_SEED_CB
#ifdef HAVE_FIPS
#define WC_RNG_SEED_CB
#endif

/* Asymmetric */
#define HAVE_ECC
Expand Down
18 changes: 11 additions & 7 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ int wolfPKCS11_Store_Open(int type, CK_ULONG id1, CK_ULONG id2, int read,
WOLFTPM2_HANDLE parent;
#else
char name[120] = "\0";
XFILE file;
XFILE file = XBADFILE;
#endif

#ifdef WOLFPKCS11_DEBUG_STORE
Expand Down Expand Up @@ -841,7 +841,7 @@ int wolfPKCS11_Store_Open(int type, CK_ULONG id1, CK_ULONG id2, int read,
*store = file;
}
#ifdef WOLFPKCS11_DEBUG_STORE
printf("Store Open %p: ret %d, name %s, ret %d\n", *store, ret, name);
printf("Store Open %p: ret %d, name %s\n", *store, ret, name);
#endif
#endif
return ret;
Expand Down Expand Up @@ -3398,12 +3398,16 @@ void WP11_Library_Final(void)
*/
int WP11_Library_IsInitialized(void)
{
int ret;

WP11_Lock_LockRO(&globalLock);
int ret, locked = 0;
if (libraryInitCount > 0) {
/* cannot used globalLock before init */
WP11_Lock_LockRO(&globalLock);
locked = 1;
}
ret = libraryInitCount > 0;
WP11_Lock_UnlockRO(&globalLock);

if (locked) {
WP11_Lock_UnlockRO(&globalLock);
}
return ret;
}

Expand Down

0 comments on commit 30f346b

Please sign in to comment.