aboutsummaryrefslogtreecommitdiff
path: root/py11
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-09-14 17:14:57 -0400
committerRob Austein <sra@hactrn.net>2015-09-14 17:14:57 -0400
commit3345ef8b1a7ad719dbd3a0f26697c6bc4bd884b1 (patch)
tree6dcc1f493f6ad5b0a008732054dc82b47d9bf092 /py11
parente9eb486fae220903f039ffae5125894c1e156aa4 (diff)
Debug PKCS #11 ECDSA signature and verification.
Diffstat (limited to 'py11')
-rw-r--r--py11/__init__.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/py11/__init__.py b/py11/__init__.py
index da0c946..204c897 100644
--- a/py11/__init__.py
+++ b/py11/__init__.py
@@ -98,6 +98,23 @@ class PKCS11 (object):
byref(public_handle), byref(private_handle))
return public_handle.value, private_handle.value
+ def C_SignInit(self, session, mechanism_type, private_key):
+ mechanism = CK_MECHANISM(mechanism_type, None, 0)
+ self.so.C_SignInit(session, byref(mechanism), private_key)
+
+ def C_Sign(self, session, data):
+ n = CK_ULONG()
+ self.so.C_Sign(session, data, len(data), None, byref(n))
+ sig = create_string_buffer(n.value)
+ self.so.C_Sign(session, data, len(data), 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)
+
+ def C_Verify(self, session, data, signature):
+ self.so.C_Verify(session, data, len(data), signature, len(signature))
__all__ = ["PKCS11"]
__all__.extend(name for name in globals()