diff options
author | Rob Austein <sra@hactrn.net> | 2017-05-10 19:56:44 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2017-05-10 19:56:44 -0400 |
commit | ccef1b59bc6cca89474eaddf7144972926281e29 (patch) | |
tree | acba87b2b069a2d788d256a266db203d4920924e | |
parent | 743ec40231db809d22487ee60f64d00b7b845807 (diff) |
Clean up default location of PKCS #11 library.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | cryptech/py11/__init__.py | 11 | ||||
-rwxr-xr-x | scripts/time-signature.py | 7 | ||||
-rw-r--r-- | unit_tests.py | 8 |
4 files changed, 13 insertions, 15 deletions
@@ -193,7 +193,7 @@ TAGS: *.[ch] # Basic testing, via the Python unittest library and our cryptech.py11 interface code test: all - python unit_tests.py + python unit_tests.py --libpkcs11 ./${SONAME} # Further testing using hsmbully, if we can find a copy of it. diff --git a/cryptech/py11/__init__.py b/cryptech/py11/__init__.py index fb9af7e..1618a76 100644 --- a/cryptech/py11/__init__.py +++ b/cryptech/py11/__init__.py @@ -12,6 +12,15 @@ from .types import * from .constants import * from .attributes import * +import platform + +if platform.system() == "Darwin": + default_so_name = "/usr/local/lib/libcryptech-pkcs11.dylib" +elif platform.system() == "Linux": + default_so_name = "/usr/lib/libcryptech-pkcs11.so" +else: + default_so_name = "/usr/local/lib/libcryptech-pkcs11.so" + class PKCS11 (object): """ @@ -46,7 +55,7 @@ class PKCS11 (object): # Whether to use C_GetFunctionList() instead of dynamic link symbols. use_C_GetFunctionList = False - def __init__(self, so_name = "libpkcs11.so"): + def __init__(self, so_name = default_so_name): self.so_name = so_name self.so = CDLL(so_name) self.d = type("Dispatch", (object,), {})() diff --git a/scripts/time-signature.py b/scripts/time-signature.py index 99ec718..732eaa4 100755 --- a/scripts/time-signature.py +++ b/scripts/time-signature.py @@ -7,7 +7,6 @@ Time PKCS #11 signatures. import collections import argparse import datetime -import platform import sys from Crypto.Hash.SHA256 import SHA256Hash as SHA256 @@ -22,11 +21,7 @@ except ImportError: sys.path.append(dirname(dirname(abspath(sys.argv[0])))) from cryptech.py11 import * - -if platform.system() == "Darwin": - libpkcs11_default = "./libcryptech-pkcs11.dylib" -else: - libpkcs11_default = "./libcryptech-pkcs11.so" +from cryptech.py11 import default_so_name as libpkcs11_default class RSAKey(object): diff --git a/unit_tests.py b/unit_tests.py index fe96207..e4c4a97 100644 --- a/unit_tests.py +++ b/unit_tests.py @@ -6,10 +6,10 @@ PKCS #11 unit tests, using cryptech.py11 and the Python unit_test framework. import unittest import datetime -import platform import sys from cryptech.py11 import * +from cryptech.py11 import default_so_name as libpkcs11_default from cryptech.py11.mutex import MutexDB try: @@ -22,12 +22,6 @@ except ImportError: pycrypto_loaded = False -if platform.system() == "Darwin": - libpkcs11_default = "./libcryptech-pkcs11.dylib" -else: - libpkcs11_default = "./libcryptech-pkcs11.so" - - def log(msg): if not args.quiet: sys.stderr.write(msg) |