1 From 50c1e937342c8b13c8a80c3bb55ce245aecdcdfe Mon Sep 17 00:00:00 2001
2 From: Rosen Penev <rosenp@gmail.com>
3 Date: Sat, 15 Jun 2019 17:49:25 -0700
4 Subject: [PATCH] Replace EVP_CIPHER_CTX_cleanup with EVP_CIPHER_CTX_reset
6 Deprecated in OpenSSL 1.1
8 src/_cffi_src/openssl/evp.py | 10 ++++++++++
9 src/cryptography/hazmat/backends/openssl/ciphers.py | 2 +-
10 2 files changed, 11 insertions(+), 1 deletion(-)
12 --- a/src/_cffi_src/openssl/evp.py
13 +++ b/src/_cffi_src/openssl/evp.py
14 @@ -48,6 +48,7 @@ int EVP_CipherUpdate(EVP_CIPHER_CTX *, u
15 const unsigned char *, int);
16 int EVP_CipherFinal_ex(EVP_CIPHER_CTX *, unsigned char *, int *);
17 int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *);
18 +int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *);
19 EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
20 void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *);
21 int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *, int);
22 @@ -273,4 +274,13 @@ static const long Cryptography_HAS_EVP_D
23 #ifndef EVP_PKEY_POLY1305
24 #define EVP_PKEY_POLY1305 NID_poly1305
27 +#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_110 && !CRYPTOGRAPHY_LIBRESSL_27_OR_GREATER
28 +#define EVP_CIPHER_CTX_reset EVP_CIPHER_CTX_cleanup
31 +#if (OPENSSL_API_COMPAT >= 0x10100000L) && !CRYPTOGRAPHY_IS_LIBRESSL
32 +#define EVP_CIPHER_CTX_cleanup EVP_CIPHER_CTX_reset
33 +#define OpenSSL_add_all_algorithms() do {} while(0)
36 --- a/src/cryptography/hazmat/backends/openssl/ciphers.py
37 +++ b/src/cryptography/hazmat/backends/openssl/ciphers.py
38 @@ -199,7 +199,7 @@ class _CipherContext(object):
39 self._backend.openssl_assert(res != 0)
40 self._tag = self._backend._ffi.buffer(tag_buf)[:]
42 - res = self._backend._lib.EVP_CIPHER_CTX_cleanup(self._ctx)
43 + res = self._backend._lib.EVP_CIPHER_CTX_reset(self._ctx)
44 self._backend.openssl_assert(res == 1)
45 return self._backend._ffi.buffer(buf)[: outlen[0]]