diff options
-rw-r--r-- | cryptography/bindings/openssl/api.py | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index bc2b4ae4..27afee57 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -13,10 +13,11 @@ from __future__ import absolute_import, division, print_function -from cryptography.primitives import interfaces +import sys import cffi -import sys + +from cryptography.primitives import interfaces class API(object): @@ -30,36 +31,21 @@ class API(object): def __init__(self): self._ffi = cffi.FFI() - self.includes, self.types, self.functions = [], [], [] - self._import() - self._define() - self._verify() - - self._lib.OpenSSL_add_all_algorithms() - - def _import(self): - """ - Import all library definitions - """ + includes = [] for name in self._modules: - __import__('cryptography.bindings.openssl.' + name) - module = sys.modules['cryptography.bindings.openssl.' + name] - self.includes.append(module.INCLUDES) - self.types.append(module.TYPES) - self.functions.append(module.FUNCTIONS) - - def _define(self): - for typedef in self.types: - self._ffi.cdef(typedef) - for function in self.functions: - self._ffi.cdef(function) - - def _verify(self): + __import__("cryptography.bindings.openssl." + name) + module = sys.modules["cryptography.bindings.openssl." + name] + self._ffi.cdef(module.TYPES) + self._ffi.cdef(module.FUNCTIONS) + includes.append(module.INCLUDES) + self._lib = self._ffi.verify( - source="\n".join(self.includes), - libraries=['crypto'] + source="\n".join(includes), + libraries=["crypto"] ) + self._lib.OpenSSL_add_all_algorithms() + def openssl_version_text(self): """ Friendly string name of linked OpenSSL. |