Skip to content
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
8 changes: 8 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ jobs:
with:
config: CC=g++ C_EXTRA_FLAGS="-Werror=narrowing"

# The same C++ build with --enable-debug, which adds the debug-only test
# hooks and the tests that declare them. Those declarations need
# extern "C" to match the library's C linkage, or the tests fail to link.
cpp_debug_build:
uses: ./.github/workflows/build-workflow.yml
with:
config: CC=g++ C_EXTRA_FLAGS="-Werror=narrowing" --enable-debug

wolfssl_v5_6_6:
uses: ./.github/workflows/wolfssl-v5.6.6-build-workflow.yml

Expand Down
6 changes: 6 additions & 0 deletions tests/destroy_stale_handle_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@
#if defined(DEBUG_WOLFPKCS11) && !defined(NO_AES)

/* DEBUG_WOLFPKCS11-only test hook exported by libwolfpkcs11. */
#ifdef __cplusplus
extern "C" {
#endif
extern int WP11_Test_RemoveObjectStale(CK_SESSION_HANDLE hSession,
CK_OBJECT_HANDLE liveHandle, CK_OBJECT_HANDLE staleHandle);
#ifdef __cplusplus
}
#endif

/* Mirrors WP11_OBJECT_ALREADY_REMOVED in wolfpkcs11/internal.h. */
#define OBJECT_ALREADY_REMOVED 1
Expand Down
12 changes: 12 additions & 0 deletions tests/login_pin_state_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,14 @@ static byte aesValue[16] = {

#ifdef LOGIN_TEST_FILE_STORE
/* DEBUG_WOLFPKCS11-only introspection hooks exported by libwolfpkcs11. */
#ifdef __cplusplus
extern "C" {
#endif
extern int WP11_Slot_TokenKeyIsZero(CK_SLOT_ID slotId);
extern int WP11_Slot_TokenDecodedObjectCount(CK_SLOT_ID slotId);
#ifdef __cplusplus
}
#endif

#define SYMMKEY_FILENAME "wp11_symmkey_0000000000000001_0000000000000000"

Expand Down Expand Up @@ -1157,7 +1163,13 @@ static void find_with_racing_logout_test(void)

#if defined(DEBUG_WOLFPKCS11) && defined(LOGIN_TEST_THREADS) && \
!defined(WOLFPKCS11_NO_TIME)
#ifdef __cplusplus
extern "C" {
#endif
extern void WP11_Slot_SetPinCheckHook(void (*hook)(void));
#ifdef __cplusplus
}
#endif

static pthread_mutex_t pinMutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t pinCond = PTHREAD_COND_INITIALIZER;
Expand Down
6 changes: 6 additions & 0 deletions tests/logout_retire_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,14 @@ static void retired_objects_bounded_test(CK_SLOT_ID slot)
}

#ifdef DEBUG_WOLFPKCS11
#ifdef __cplusplus
extern "C" {
#endif
extern void WP11_Object_SetFindHook(void (*hook)(void));
extern void WP11_Session_SetAddObjectHook(void (*hook)(void));
#ifdef __cplusplus
}
#endif

static CK_SESSION_HANDLE hookLogoutSession = CK_INVALID_HANDLE;
static CK_RV hookLogoutRv = CKR_GENERAL_ERROR;
Expand Down
6 changes: 6 additions & 0 deletions tests/logout_token_key_zero_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@
#if defined(DEBUG_WOLFPKCS11) && !defined(WOLFPKCS11_NO_STORE)

/* DEBUG_WOLFPKCS11-only introspection hook exported by libwolfpkcs11. */
#ifdef __cplusplus
extern "C" {
#endif
extern int WP11_Slot_TokenKeyIsZero(CK_SLOT_ID slotId);
#ifdef __cplusplus
}
#endif

#define LOGOUT_KEY_TEST_DIR "./store/logout_token_key_zero_test"
#define WOLFPKCS11_TOKEN_FILENAME "wp11_token_0000000000000001"
Expand Down
6 changes: 6 additions & 0 deletions tests/object_policy_integrity_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,13 @@ static void test_recovery_ignores_dir_spelling(void)
#define STORE_EXIT_CODE 75
#define CRASH_MAX_RENAMES 40

#ifdef __cplusplus
extern "C" {
#endif
extern void WP11_Test_StoreExitAfterRenames(int renames);
#ifdef __cplusplus
}
#endif

static int crashAt = 0;

Expand Down
6 changes: 6 additions & 0 deletions tests/token_reset_fail_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@

#ifdef DEBUG_WOLFPKCS11

#ifdef __cplusplus
extern "C" {
#endif
extern void WP11_Test_FailTokenInit(int fail);
#ifdef __cplusplus
}
#endif

static const char* soPin = "password123456";
static const char* userPin = "wolfpkcs11-test";
Expand Down
12 changes: 12 additions & 0 deletions tests/token_store_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,13 @@ static void test_derive_reports_commit_failure(void)

#ifdef DEBUG_WOLFPKCS11
/* Debug-only hook exported by libwolfpkcs11. */
#ifdef __cplusplus
extern "C" {
#endif
extern void WP11_Test_StoreCloseFailAfter(int closes);
#ifdef __cplusplus
}
#endif

/* A token object whose record cannot be closed is not reported created. */
static void test_create_reports_close_failure(void)
Expand Down Expand Up @@ -1005,9 +1011,15 @@ static void test_load_record_without_trailing_fields(void)

#ifdef TOKEN_STORE_TPM_TEST
/* Debug-only hooks exported by libwolfpkcs11. */
#ifdef __cplusplus
extern "C" {
#endif
extern int WP11_Test_StoreWriteFailAfter(int writes);
extern int WP11_Test_StoreWriteFailOnce(int writes);
extern void WP11_Test_TpmStoreShortBy(int bytes);
#ifdef __cplusplus
}
#endif

#define MAX_STORE_WRITES 500

Expand Down
6 changes: 6 additions & 0 deletions tests/tpm_decode_bounds_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@
(!defined(NO_RSA) || defined(HAVE_ECC))

/* DEBUG_WOLFPKCS11-only hook exported by libwolfpkcs11. */
#ifdef __cplusplus
extern "C" {
#endif
extern int WP11_Test_DecodeTpmKey(CK_SLOT_ID slotId, unsigned char* keyData,
int keyDataLen);
#ifdef __cplusplus
}
#endif

static int test_passed = 0;
static int test_failed = 0;
Expand Down
Loading