aboutsummaryrefslogtreecommitdiff
path: root/py11
diff options
context:
space:
mode:
Diffstat (limited to 'py11')
-rw-r--r--py11/__init__.py37
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")