diff options
Diffstat (limited to 'py11')
-rw-r--r-- | py11/__init__.py | 17 |
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() |