summaryrefslogtreecommitdiff
path: root/module/p11-capi.c
diff options
context:
space:
mode:
Diffstat (limited to 'module/p11-capi.c')
-rw-r--r--module/p11-capi.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/module/p11-capi.c b/module/p11-capi.c
index b5f7f62..8f15cf5 100644
--- a/module/p11-capi.c
+++ b/module/p11-capi.c
@@ -37,8 +37,8 @@
static int cryptoki_initialized = 0;
static HANDLE global_mutex = NULL;
-#define MANUFACTURER_ID "Cryptoki CAPI "
-#define LIBRARY_DESCRIPTION "Cryptoki CAPI Provider "
+#define MANUFACTURER_ID "p11-capi "
+#define LIBRARY_DESCRIPTION "PKCS#11 CAPI Provider "
#define LIBRARY_VERSION_MAJOR 1
#define LIBRARY_VERSION_MINOR 1
#define HARDWARE_VERSION_MAJOR 0
@@ -61,7 +61,7 @@ static CK_MECHANISM_TYPE all_mechanisms[] = {
#define LINE 1024
void
-p11c_debug(const char* msg, ...)
+p11c_log(const char* msg, ...)
{
char buf[LINE];
va_list va;
@@ -76,10 +76,12 @@ p11c_debug(const char* msg, ...)
strncpy(buf + len, "\n", 1024 - len);
buf[LINE - 1] = 0;
- // OutputDebugStringA(buf);
+ OutputDebugStringA(buf);
}
/* Bah humbug, MSVC doesn't have __func__ */
+#if DBG_OUTPUT
+
#define ENTER(func) \
char* _func = #func; \
p11c_debug("%s: enter", _func)
@@ -87,8 +89,26 @@ p11c_debug(const char* msg, ...)
#define RETURN(ret) \
return (p11c_debug("%s: %d", _func, ret), ret)
+#else /* !DBG_OUTPUT */
+
+#define ENTER(func) \
+ char* _func = #func;
+
+#define RETURN(ret) \
+ return log_return(_func, ret)
+
+static CK_RV
+log_return(char *func, CK_RV ret)
+{
+ if(ret != CKR_OK)
+ p11c_log("%s: %d", func, ret);
+ return ret;
+}
+
+#endif /* !DBG_OUTPUT */
+
#define PREREQ(cond, ret) \
- if (!(cond)) { p11c_debug("%s: %s failed: %d", _func, #cond, ret); return ret; }
+ if (!(cond)) { p11c_log("%s: %s failed: %d", _func, #cond, ret); return ret; }
void
p11c_lock_global(void)
@@ -325,7 +345,7 @@ p11c_return_filetime(CK_ATTRIBUTE_PTR attr, FILETIME *ftime)
if(!FileTimeToSystemTime(ftime, &stime))
{
- DBG(("An invalid FILETIME was encountered"));
+ WARN(("An invalid FILETIME was encountered"));
return CKR_GENERAL_ERROR;
}
@@ -377,7 +397,7 @@ PC_C_Initialize(CK_VOID_PTR init_args)
}
cryptoki_initialized = 1;
-
+ p11c_log("initialized p11-capi module");
RETURN(CKR_OK);
}
@@ -393,6 +413,7 @@ PC_C_Finalize(CK_VOID_PTR pReserved)
p11c_session_cleanup_all();
p11c_token_cleanup_all();
+ p11c_log("finalized p11-capi module");
RETURN(CKR_OK);
}
@@ -893,6 +914,11 @@ PC_C_GetAttributeValue(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object,
p11c_session_unref_unlock(sess);
}
+ if(ret == CKR_OBJECT_HANDLE_INVALID)
+ {
+ WARN(("object handle invalid"));
+ }
+
RETURN(ret);
}