aboutsummaryrefslogtreecommitdiff
path: root/py11
diff options
context:
space:
mode:
Diffstat (limited to 'py11')
-rw-r--r--py11/__init__.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/py11/__init__.py b/py11/__init__.py
index ab187f7..bb4813f 100644
--- a/py11/__init__.py
+++ b/py11/__init__.py
@@ -35,8 +35,21 @@ class PKCS11 (object):
self.so.C_GetInfo(byref(info))
return info.cryptokiVersion
- def C_Initialize(self):
- self.so.C_Initialize(None)
+ # http://stackoverflow.com/questions/15786635/using-ctypes-to-write-callbacks-that-pass-in-pointer-to-pointer-parameters-to-be
+ # suggests that it should be straightforward to write callback
+ # functions to implement the mutex semantics, and we get the
+ # CK_CREATEMUTEX call, but we dump core on the CK_LOCKMUTEX call.
+ # Specifying CKF_OS_LOCKING_OK does work, and is sufficient for most
+ # purposes, so leaving the callbacks out of the API for now.
+
+ def C_Initialize(self, flags = 0):
+ if flags == 0:
+ self.so.C_Initialize(None)
+ else:
+ init_arg = CK_C_INITIALIZE_ARGS(cast(None, CK_CREATEMUTEX), cast(None, CK_DESTROYMUTEX),
+ cast(None, CK_LOCKMUTEX), cast(None, CK_UNLOCKMUTEX),
+ flags, None)
+ self.so.C_Initialize(cast(byref(init_arg), CK_VOID_PTR))
def C_Finalize(self):
self.so.C_Finalize(None)