From 0cc1b0a7b5605d86d8a8639651987e25fdb3bdc9 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Thu, 4 May 2017 02:33:40 -0400 Subject: Support using C_GetFunctionList() instead of library symbols. The Python ctypes library allows us direct access to the public symbols of a shared library, so we never bothered to implement support for using the dispatch vector returned by C_GetFunctionList(). Well, it turns out that there are useful debugging tools like pkcs11-spy which require the dispatch vector support, so refactor to add it. --- cryptech/py11/exceptions.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cryptech/py11/exceptions.py') diff --git a/cryptech/py11/exceptions.py b/cryptech/py11/exceptions.py index 7f86fe4..9512cda 100644 --- a/cryptech/py11/exceptions.py +++ b/cryptech/py11/exceptions.py @@ -28,6 +28,11 @@ class CKR_Exception(Exception): def __int__(self): return self.ckr_code + @classmethod + def raise_on_failure(cls, rv, func, *args): + if rv != CKR_OK: + raise cls.ckr_map[rv] + CKR_OK = 0x00000000 class CKR_CANCEL (CKR_Exception): ckr_code = 0x00000001 -- cgit v1.2.3