diff options
author | Donald Stufft <donald@stufft.io> | 2013-09-13 19:54:17 -0700 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2013-09-13 19:54:17 -0700 |
commit | 8f5d42828090fb267614a2afc18f84e7b5b6089e (patch) | |
tree | 3e815b26263f55be01be21abbcdd5484b39b5210 | |
parent | c7b0f797b512d7c2a369632c1669326666e6004d (diff) | |
parent | 6e860dd2c75bfa55775f660ae62a13afcbd84b6f (diff) | |
download | cryptography-8f5d42828090fb267614a2afc18f84e7b5b6089e.tar.gz cryptography-8f5d42828090fb267614a2afc18f84e7b5b6089e.tar.bz2 cryptography-8f5d42828090fb267614a2afc18f84e7b5b6089e.zip |
Merge pull request #68 from alex/cleanup
Slightly clean up the OpenSSL binding
-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. |