From cce50cb3a36bec58db683316a2862f1cfcba4829 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Fri, 11 Sep 2015 14:48:08 -0400 Subject: Add C_FindObject*() to py11. --- py11/__init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'py11/__init__.py') 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") -- cgit v1.2.3