From 2ca30db7b8608af3e9994f6b324d9311ca437b78 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 23 Dec 2013 08:21:34 -0800 Subject: This name is alreayd known to be imported --- cryptography/hazmat/backends/openssl/backend.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index 6cc8275d..9cd07ea5 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -144,7 +144,6 @@ class Backend(object): for name in cls._modules: module_name = cls._module_prefix + name - __import__(module_name) module = sys.modules[module_name] for condition, names in module.CONDITIONAL_NAMES.items(): if not getattr(lib, condition): -- cgit v1.2.3 From 834342bea3990d166b9c63620a133d18ae5c9339 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 23 Dec 2013 08:25:24 -0800 Subject: A docstring --- cryptography/hazmat/backends/openssl/backend.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index 9cd07ea5..3e47afa1 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -56,6 +56,20 @@ _OSX_POST_INCLUDE = """ class Backend(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.backends.openssl." _modules = [ -- cgit v1.2.3 From f1ca56c42a9cb6fc1e83f6c28ae941d0f0044fb9 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 23 Dec 2013 09:54:03 -0800 Subject: Make the naming of things in the OpenSSL backend more consistent --- cryptography/hazmat/backends/openssl/backend.py | 6 +++--- cryptography/hazmat/backends/openssl/evp.py | 15 ++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index 3e47afa1..f11ddf22 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -345,7 +345,7 @@ class _CipherContext(object): assert res != 0 if isinstance(mode, GCM): res = self._backend.lib.EVP_CIPHER_CTX_ctrl( - ctx, self._backend.lib.Cryptography_EVP_CTRL_GCM_SET_IVLEN, + ctx, self._backend.lib.EVP_CTRL_GCM_SET_IVLEN, len(iv_nonce), self._backend.ffi.NULL ) assert res != 0 @@ -354,7 +354,7 @@ class _CipherContext(object): raise ValueError("Authentication tag must be provided and " "be 4 bytes or longer when decrypting") res = self._backend.lib.EVP_CIPHER_CTX_ctrl( - ctx, self._backend.lib.Cryptography_EVP_CTRL_GCM_SET_TAG, + ctx, self._backend.lib.EVP_CTRL_GCM_SET_TAG, len(mode.tag), mode.tag ) assert res != 0 @@ -396,7 +396,7 @@ class _CipherContext(object): block_byte_size = self._block_size // 8 tag_buf = self._backend.ffi.new("unsigned char[]", block_byte_size) res = self._backend.lib.EVP_CIPHER_CTX_ctrl( - self._ctx, self._backend.lib.Cryptography_EVP_CTRL_GCM_GET_TAG, + self._ctx, self._backend.lib.EVP_CTRL_GCM_GET_TAG, block_byte_size, tag_buf ) assert res != 0 diff --git a/cryptography/hazmat/backends/openssl/evp.py b/cryptography/hazmat/backends/openssl/evp.py index 7e50a6b3..e7b61b72 100644 --- a/cryptography/hazmat/backends/openssl/evp.py +++ b/cryptography/hazmat/backends/openssl/evp.py @@ -32,9 +32,9 @@ typedef struct evp_pkey_st { } EVP_PKEY; static const int EVP_PKEY_RSA; static const int EVP_PKEY_DSA; -static const int Cryptography_EVP_CTRL_GCM_SET_IVLEN; -static const int Cryptography_EVP_CTRL_GCM_GET_TAG; -static const int Cryptography_EVP_CTRL_GCM_SET_TAG; +static const int EVP_CTRL_GCM_SET_IVLEN; +static const int EVP_CTRL_GCM_GET_TAG; +static const int EVP_CTRL_GCM_SET_TAG; static const int Cryptography_HAS_GCM; """ @@ -104,9 +104,6 @@ int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *, int, int, void *); CUSTOMIZATIONS = """ #ifdef EVP_CTRL_GCM_SET_TAG const int Cryptography_HAS_GCM = 1; -const int Cryptography_EVP_CTRL_GCM_GET_TAG = EVP_CTRL_GCM_GET_TAG; -const int Cryptography_EVP_CTRL_GCM_SET_TAG = EVP_CTRL_GCM_SET_TAG; -const int Cryptography_EVP_CTRL_GCM_SET_IVLEN = EVP_CTRL_GCM_SET_IVLEN; #else const int Cryptography_HAS_GCM = 0; const int Cryptography_EVP_CTRL_GCM_GET_TAG = -1; @@ -117,8 +114,8 @@ const int Cryptography_EVP_CTRL_GCM_SET_IVLEN = -1; CONDITIONAL_NAMES = { "Cryptography_HAS_GCM": [ - "Cryptography_EVP_CTRL_GCM_GET_TAG", - "Cryptography_EVP_CTRL_GCM_SET_TAG", - "Cryptography_EVP_CTRL_GCM_SET_IVLEN", + "EVP_CTRL_GCM_GET_TAG", + "EVP_CTRL_GCM_SET_TAG", + "EVP_CTRL_GCM_SET_IVLEN", ] } -- cgit v1.2.3 From 0245a9a1070b4d0834cd84aad6292238cf74cb81 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Mon, 23 Dec 2013 09:57:07 -0800 Subject: Fix --- cryptography/hazmat/backends/openssl/evp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cryptography/hazmat/backends/openssl/evp.py b/cryptography/hazmat/backends/openssl/evp.py index e7b61b72..8cf96b2d 100644 --- a/cryptography/hazmat/backends/openssl/evp.py +++ b/cryptography/hazmat/backends/openssl/evp.py @@ -106,9 +106,9 @@ CUSTOMIZATIONS = """ const int Cryptography_HAS_GCM = 1; #else const int Cryptography_HAS_GCM = 0; -const int Cryptography_EVP_CTRL_GCM_GET_TAG = -1; -const int Cryptography_EVP_CTRL_GCM_SET_TAG = -1; -const int Cryptography_EVP_CTRL_GCM_SET_IVLEN = -1; +const int EVP_CTRL_GCM_GET_TAG = -1; +const int EVP_CTRL_GCM_SET_TAG = -1; +const int EVP_CTRL_GCM_SET_IVLEN = -1; #endif """ -- cgit v1.2.3