diff options
author | Rob Austein <sra@hactrn.net> | 2015-09-16 00:59:35 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2015-09-16 00:59:35 -0400 |
commit | 405a65dea4ef1c12aaec4e232dc3a4b123ca3017 (patch) | |
tree | b851a8d01418a82e966c012f78c50b0423d04165 /py11 | |
parent | f12a5e82f66c0da735bcca8c5010f867a5067946 (diff) |
Add C_SignUpdate(), C_SignFinal(), C_VerifyUpdate(), C_VerifyFinal().
Diffstat (limited to 'py11')
-rw-r--r-- | py11/__init__.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/py11/__init__.py b/py11/__init__.py index fa6e0f5..af7e053 100644 --- a/py11/__init__.py +++ b/py11/__init__.py @@ -109,6 +109,16 @@ class PKCS11 (object): self.so.C_Sign(session, data, len(data), sig, byref(n)) return sig.raw + def C_SignUpdate(self, session, data): + self.so.C_SignUpdate(session, data, len(data)) + + def C_SignFinal(self, session): + n = CK_ULONG() + self.so.C_Sign(session, None, byref(n)) + sig = create_string_buffer(n.value) + self.so.C_Sign(session, sig, byref(n)) + return sig.raw + def C_VerifyInit(self, session, mechanism_type, public_key): mechanism = CK_MECHANISM(mechanism_type, None, 0) self.so.C_VerifyInit(session, byref(mechanism), public_key) @@ -116,12 +126,39 @@ class PKCS11 (object): def C_Verify(self, session, data, signature): self.so.C_Verify(session, data, len(data), signature, len(signature)) + def C_VerifyUpdate(self, session, data): + self.so.C_Verify(session, data, len(data)) + + def C_VerifyFinal(self, session, signature): + self.so.C_Verify(session, signature, len(signature)) + def C_CreateObject(self, session, template): template = self.adb.to_ctypes(template) handle = CK_OBJECT_HANDLE() self.so.C_CreateObject(session, template, len(template), byref(handle)) return handle.value + def C_DigestInit(self, session, mechanism_type): + mechanism = CK_MECHANISM(mechanism_type, None, 0) + self.so.C_DigestInit(session, byref(mechanism)) + + def C_Digest(self, session, data): + n = CK_ULONG() + self.so.C_Digest(session, data, len(data), None, byref(n)) + hash = create_string_buffer(n.value) + self.so.C_Digest(session, data, len(data), hash, byref(n)) + return hash.raw + + def C_DigestUpdate(self, session, data): + self.so.C_DigestUpdate(session, data, len(data)) + + def C_DigestFinal(self, session): + n = CK_ULONG() + self.so.C_Digest(session, None, byref(n)) + hash = create_string_buffer(n.value) + self.so.C_Digest(session, hash, byref(n)) + return hash.raw + __all__ = ["PKCS11"] __all__.extend(name for name in globals() if name.startswith("CK") |