From 3345ef8b1a7ad719dbd3a0f26697c6bc4bd884b1 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Mon, 14 Sep 2015 17:14:57 -0400 Subject: Debug PKCS #11 ECDSA signature and verification. --- py11/__init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'py11') 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() -- cgit v1.2.3