diff options
author | Rob Austein <sra@hactrn.net> | 2015-09-22 12:53:02 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2015-09-22 12:53:02 -0400 |
commit | d52b9d3acb8e613b388bccd3192d30fff3957718 (patch) | |
tree | dd95e78027c04f07b75d2178260a7f83cbb50dfc /py11 | |
parent | 6c9f61a27667843f245630c67f332cad7630e876 (diff) |
Clean up Python APIs to C_FindObject*() and C_GetSlotList().
Diffstat (limited to 'py11')
-rw-r--r-- | py11/__init__.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/py11/__init__.py b/py11/__init__.py index 80495d9..da79e34 100644 --- a/py11/__init__.py +++ b/py11/__init__.py @@ -95,10 +95,11 @@ class PKCS11 (object): self._C_Initialize_args = None def C_GetSlotList(self): - slots = (CK_SLOT_ID * 10)() - count = CK_ULONG(len(slots)) + count = CK_ULONG() + self.so.C_GetSlotList(CK_TRUE, None, byref(count)) + slots = (CK_SLOT_ID * count.value)() self.so.C_GetSlotList(CK_TRUE, slots, byref(count)) - return [slots[i] for i in xrange(count.value)] + return tuple(slots[i] for i in xrange(count.value)) def C_GetTokenInfo(self, slot_id): token_info = CK_TOKEN_INFO() @@ -145,11 +146,11 @@ class PKCS11 (object): for i in xrange(count.value): yield objects[i] - def Find(self, session, template = None, **kwargs): + def FindObjects(self, session, template = None, **kwargs): self.C_FindObjectsInit(session, template, **kwargs) - for obj in self.C_FindObjects(session): - yield obj + result = tuple(self.C_FindObjects(session)) self.C_FindObjectsFinal(session) + return result def _parse_GenerateKeyPair_template(self, # Attributes common to public and private templates |