-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathdebug_test.c
More file actions
69 lines (52 loc) · 2.07 KB
/
debug_test.c
File metadata and controls
69 lines (52 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdio.h>
#include "wolfpkcs11/pkcs11.h"
int main() {
CK_RV rv;
CK_FUNCTION_LIST_PTR pFunctionList;
printf("=== wolfPKCS11 Debug Test Program ===\n");
#ifdef DEBUG_WOLFPKCS11
printf("Debug mode is ENABLED (DEBUG_WOLFPKCS11 defined)\n");
printf("\nTesting debug control functions:\n");
wolfPKCS11_Debugging_On();
printf("Debug enabled\n");
wolfPKCS11_Debugging_Off();
printf("Debug disabled\n");
wolfPKCS11_Debugging_On();
printf("Debug re-enabled\n");
printf("\nTesting PKCS#11 functions with debug output:\n");
rv = C_GetFunctionList(&pFunctionList);
printf("C_GetFunctionList returned: %lu\n", (unsigned long)rv);
if (rv == CKR_OK && pFunctionList != NULL) {
rv = pFunctionList->C_Initialize(NULL);
printf("C_Initialize returned: %lu\n", (unsigned long)rv);
if (rv == CKR_OK) {
CK_INFO info;
rv = pFunctionList->C_GetInfo(&info);
printf("C_GetInfo returned: %lu\n", (unsigned long)rv);
pFunctionList->C_Finalize(NULL);
printf("C_Finalize called\n");
}
}
wolfPKCS11_Debugging_Off();
printf("Debug disabled at end\n");
#else
printf("Debug mode is DISABLED (DEBUG_WOLFPKCS11 not defined)\n");
printf("Debug functions and macros are compiled out\n");
printf("\nTesting PKCS#11 functions without debug output:\n");
rv = C_GetFunctionList(&pFunctionList);
printf("C_GetFunctionList returned: %lu\n", (unsigned long)rv);
if (rv == CKR_OK && pFunctionList != NULL) {
rv = pFunctionList->C_Initialize(NULL);
printf("C_Initialize returned: %lu\n", (unsigned long)rv);
if (rv == CKR_OK) {
CK_INFO info;
rv = pFunctionList->C_GetInfo(&info);
printf("C_GetInfo returned: %lu\n", (unsigned long)rv);
pFunctionList->C_Finalize(NULL);
printf("C_Finalize called\n");
}
}
#endif
printf("\n=== Test Complete ===\n");
return 0;
}