aboutsummaryrefslogtreecommitdiff
path: root/py11/__init__.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-09-11 14:48:08 -0400
committerRob Austein <sra@hactrn.net>2015-09-11 14:48:08 -0400
commitcce50cb3a36bec58db683316a2862f1cfcba4829 (patch)
tree38d6f831a10d5ce54011bacf7c649d9565e0a6d4 /py11/__init__.py
parent6613e3a06ec27bf4bf029b99cfbab1ffa251db15 (diff)
Add C_FindObject*() to py11.
Diffstat (limited to 'py11/__init__.py')
-rw-r--r--py11/__init__.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/py11/__init__.py b/py11/__init__.py
index d99c1b0..d4c07a1 100644
--- a/py11/__init__.py
+++ b/py11/__init__.py
@@ -179,6 +179,22 @@ class PKCS11 (object):
self.so.C_GetAttributeValue(session_handle, object_handle, byref(t), len(t))
return dict((a.type, a.pValue.raw) for a in t)
+ def C_FindObjectsInit(self, session, template):
+ if template:
+ self.so.C_FindObjectsInit(session, attributes_to_ctypes(template), len(template))
+ else:
+ self.so.C_FindObjectsInit(session, None, 0)
+
+ def C_FindObjects(self, session, chunk_size = 10):
+ objects = (CK_OBJECT_HANDLE * chunk_size)()
+ count = CK_ULONG()
+ while True:
+ self.so.C_FindObjects(session, byref(objects), len(objects), byref(count))
+ for i in xrange(count.value):
+ yield objects[i]
+ if count.value == 0:
+ break
+
def C_GenerateKeyPair(self, session, mechanism_type, public_template, private_template):
mechanism = CK_MECHANISM(mechanism_type, None, 0)
public_template = attributes_to_ctypes(public_template)
@@ -191,6 +207,7 @@ class PKCS11 (object):
byref(public_handle), byref(private_handle))
return public_handle.value, private_handle.value
+
__all__ = ["PKCS11"]
__all__.extend(name for name in globals()
if name.startswith("CK")