aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-01-04 12:52:20 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-01-04 12:52:20 -0600
commit24ff720b4e9b4d6299a8c7c4d5a0bbc3f377fea0 (patch)
treeee48da93f98f5da02917d490fdafbbc63b9969c9
parentf38074703c6fddabbd8cc76bec91d976d029e5ec (diff)
downloadcryptography-24ff720b4e9b4d6299a8c7c4d5a0bbc3f377fea0.tar.gz
cryptography-24ff720b4e9b4d6299a8c7c4d5a0bbc3f377fea0.tar.bz2
cryptography-24ff720b4e9b4d6299a8c7c4d5a0bbc3f377fea0.zip
remove verify_kwargs and replace with pre_include/post_include/libraries
-rw-r--r--cryptography/hazmat/bindings/openssl/binding.py32
-rw-r--r--cryptography/hazmat/bindings/utils.py28
2 files changed, 29 insertions, 31 deletions
diff --git a/cryptography/hazmat/bindings/openssl/binding.py b/cryptography/hazmat/bindings/openssl/binding.py
index 208bbdca..3fb3dc8b 100644
--- a/cryptography/hazmat/bindings/openssl/binding.py
+++ b/cryptography/hazmat/bindings/openssl/binding.py
@@ -34,36 +34,9 @@ _OSX_POST_INCLUDE = """
"""
-def verify_kwargs(includes, functions, customizations):
- return {
- "source": "\n".join(
- [_OSX_PRE_INCLUDE] +
- includes +
- [_OSX_POST_INCLUDE] +
- functions +
- customizations
- ),
- "libraries": ["crypto", "ssl"],
- }
-
-
class Binding(object):
"""
OpenSSL API wrapper.
-
- Modules listed in the ``_modules`` listed should have the following
- attributes:
-
- * ``INCLUDES``: A string containg C includes.
- * ``TYPES``: A string containing C declarations for types.
- * ``FUNCTIONS``: A string containing C declarations for functions.
- * ``MACROS``: A string containing C declarations for any macros.
- * ``CUSTOMIZATIONS``: A string containing arbitrary top-level C code, this
- can be used to do things like test for a define and provide an
- alternate implementation based on that.
- * ``CONDITIONAL_NAMES``: A dict mapping strings of condition names from the
- library to a list of names which will not be present without the
- condition.
"""
_module_prefix = "cryptography.hazmat.bindings.openssl."
_modules = [
@@ -103,5 +76,6 @@ class Binding(object):
if cls.ffi is not None and cls.lib is not None:
return
- cls.ffi, cls.lib = utils.build_ffi(cls._modules, cls._module_prefix,
- verify_kwargs)
+ cls.ffi, cls.lib = utils.build_ffi(cls._module_prefix, cls._modules,
+ _OSX_PRE_INCLUDE, _OSX_POST_INCLUDE,
+ ["crypto", "ssl"])
diff --git a/cryptography/hazmat/bindings/utils.py b/cryptography/hazmat/bindings/utils.py
index 02ba1f26..67f58795 100644
--- a/cryptography/hazmat/bindings/utils.py
+++ b/cryptography/hazmat/bindings/utils.py
@@ -18,7 +18,22 @@ import sys
import cffi
-def build_ffi(modules, module_prefix, verify_kwargs):
+def build_ffi(module_prefix, modules, pre_include, post_include, libraries):
+ """
+ Modules listed in the ``modules`` listed should have the following
+ attributes:
+
+ * ``INCLUDES``: A string containing C includes.
+ * ``TYPES``: A string containing C declarations for types.
+ * ``FUNCTIONS``: A string containing C declarations for functions.
+ * ``MACROS``: A string containing C declarations for any macros.
+ * ``CUSTOMIZATIONS``: A string containing arbitrary top-level C code, this
+ can be used to do things like test for a define and provide an
+ alternate implementation based on that.
+ * ``CONDITIONAL_NAMES``: A dict mapping strings of condition names from the
+ library to a list of names which will not be present without the
+ condition.
+ """
ffi = cffi.FFI()
includes = []
functions = []
@@ -52,7 +67,16 @@ def build_ffi(modules, module_prefix, verify_kwargs):
# is legal, but the following will fail to compile:
# int foo(int);
# int foo(short);
- lib = ffi.verify(**verify_kwargs(includes, functions, customizations))
+ lib = ffi.verify(
+ source="\n".join(
+ [pre_include] +
+ includes +
+ [post_include] +
+ functions +
+ customizations
+ ),
+ libraries=libraries
+ )
for name in modules:
module_name = module_prefix + name