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