aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-03-21 10:04:14 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2014-03-21 10:04:14 -0700
commit59cb7f978b30b833bde4ac355624047c6c6c07e3 (patch)
tree5e4cbba26f401bfbeb04d4ed161be7f6c073a9b1
parent23c641dad201446a019d4a5f1181908744fd347a (diff)
parent06919e91eb8f60c7205b51cc3dac31a35e34430c (diff)
downloadcryptography-59cb7f978b30b833bde4ac355624047c6c6c07e3.tar.gz
cryptography-59cb7f978b30b833bde4ac355624047c6c6c07e3.tar.bz2
cryptography-59cb7f978b30b833bde4ac355624047c6c6c07e3.zip
Merge pull request #837 from reaperhulk/modulename-all-the-things
padding and constant time also need the cffi modulename fix
-rw-r--r--cryptography/hazmat/primitives/constant_time.py20
-rw-r--r--cryptography/hazmat/primitives/padding.py20
2 files changed, 28 insertions, 12 deletions
diff --git a/cryptography/hazmat/primitives/constant_time.py b/cryptography/hazmat/primitives/constant_time.py
index e88a0d95..e0e9aa37 100644
--- a/cryptography/hazmat/primitives/constant_time.py
+++ b/cryptography/hazmat/primitives/constant_time.py
@@ -13,18 +13,20 @@
from __future__ import absolute_import, division, print_function
+import sys
+
import cffi
import six
+from cryptography.hazmat.bindings.utils import _create_modulename
-_ffi = cffi.FFI()
-_ffi.cdef("""
+TYPES = """
uint8_t Cryptography_constant_time_bytes_eq(uint8_t *, size_t, uint8_t *,
size_t);
-""")
-_lib = _ffi.verify(
- """
+"""
+
+FUNCTIONS = """
uint8_t Cryptography_constant_time_bytes_eq(uint8_t *a, size_t len_a,
uint8_t *b, size_t len_b) {
size_t i = 0;
@@ -43,7 +45,13 @@ uint8_t Cryptography_constant_time_bytes_eq(uint8_t *a, size_t len_a,
/* Now check the low bit to see if it's set */
return (mismatch & 1) == 0;
}
-""",
+"""
+
+_ffi = cffi.FFI()
+_ffi.cdef(TYPES)
+_lib = _ffi.verify(
+ source=FUNCTIONS,
+ modulename=_create_modulename([TYPES], FUNCTIONS, sys.version),
ext_package="cryptography",
)
diff --git a/cryptography/hazmat/primitives/padding.py b/cryptography/hazmat/primitives/padding.py
index bf634a65..d78c6a5b 100644
--- a/cryptography/hazmat/primitives/padding.py
+++ b/cryptography/hazmat/primitives/padding.py
@@ -13,20 +13,22 @@
from __future__ import absolute_import, division, print_function
+import sys
+
import cffi
import six
from cryptography import utils
+from cryptography.hazmat.bindings.utils import _create_modulename
from cryptography.hazmat.primitives import interfaces
-_ffi = cffi.FFI()
-_ffi.cdef("""
+TYPES = """
uint8_t Cryptography_check_pkcs7_padding(const uint8_t *, uint8_t);
-""")
-_lib = _ffi.verify(
- """
+"""
+
+FUNCTIONS = """
/* Returns the value of the input with the most-significant-bit copied to all
of the bits. */
static uint8_t Cryptography_DUPLICATE_MSB_TO_ALL(uint8_t a) {
@@ -62,7 +64,13 @@ uint8_t Cryptography_check_pkcs7_padding(const uint8_t *data,
/* Now check the low bit to see if it's set */
return (mismatch & 1) == 0;
}
-""",
+"""
+
+_ffi = cffi.FFI()
+_ffi.cdef(TYPES)
+_lib = _ffi.verify(
+ source=FUNCTIONS,
+ modulename=_create_modulename([TYPES], FUNCTIONS, sys.version),
ext_package="cryptography",
)