diff options
-rw-r--r-- | py11/__init__.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/py11/__init__.py b/py11/__init__.py index d4c07a1..7acb7aa 100644 --- a/py11/__init__.py +++ b/py11/__init__.py @@ -168,16 +168,16 @@ class PKCS11 (object): attributes = tuple(attributes) if not all(isinstance(a, (int, long)) for a in attributes): raise TypeError - t = (CK_ATTRIBUTE * len(attributes))() + template = (CK_ATTRIBUTE * len(attributes))() for i in xrange(len(attributes)): - t[i].type = attributes[i] - t[i].pValue = None - t[i].ulValueLen = 0 - self.so.C_GetAttributeValue(session_handle, object_handle, byref(t), len(t)) - for a in t: - a.pValue = create_string_buffer(a.ulValueLen) - self.so.C_GetAttributeValue(session_handle, object_handle, byref(t), len(t)) - return dict((a.type, a.pValue.raw) for a in t) + template[i].type = attributes[i] + template[i].pValue = None + template[i].ulValueLen = 0 + self.so.C_GetAttributeValue(session_handle, object_handle, template, len(template)) + for t in template: + t.pValue = create_string_buffer(t.ulValueLen) + self.so.C_GetAttributeValue(session_handle, object_handle, template, len(template)) + return dict((t.type, t.pValue[:t.ulValueLen]) for t in template) def C_FindObjectsInit(self, session, template): if template: @@ -189,7 +189,7 @@ class PKCS11 (object): objects = (CK_OBJECT_HANDLE * chunk_size)() count = CK_ULONG() while True: - self.so.C_FindObjects(session, byref(objects), len(objects), byref(count)) + self.so.C_FindObjects(session, objects, len(objects), byref(count)) for i in xrange(count.value): yield objects[i] if count.value == 0: |