diff options
-rw-r--r-- | py11/__init__.py | 17 |
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") |