8ed4210a56921e89642f577e387bab9be6199902
[feed/packages.git] /
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
5
6 Deprecated in OpenSSL 1.1
7 ---
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(-)
11
12 diff --git a/src/_cffi_src/openssl/evp.py b/src/_cffi_src/openssl/evp.py
13 index d7ac93e6..0b3e067d 100644
14 --- a/src/_cffi_src/openssl/evp.py
15 +++ b/src/_cffi_src/openssl/evp.py
16 @@ -48,6 +48,7 @@ int EVP_CipherUpdate(EVP_CIPHER_CTX *, unsigned char *, int *,
17 const unsigned char *, int);
18 int EVP_CipherFinal_ex(EVP_CIPHER_CTX *, unsigned char *, int *);
19 int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *);
20 +int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *);
21 EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
22 void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *);
23 int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *, int);
24 @@ -273,4 +274,13 @@ static const long Cryptography_HAS_EVP_DIGESTFINAL_XOF = 1;
25 #ifndef EVP_PKEY_POLY1305
26 #define EVP_PKEY_POLY1305 NID_poly1305
27 #endif
28 +
29 +#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_110 && !CRYPTOGRAPHY_LIBRESSL_27_OR_GREATER
30 +#define EVP_CIPHER_CTX_reset EVP_CIPHER_CTX_cleanup
31 +#endif
32 +
33 +#if (OPENSSL_API_COMPAT >= 0x10100000L) && !CRYPTOGRAPHY_IS_LIBRESSL
34 +#define EVP_CIPHER_CTX_cleanup EVP_CIPHER_CTX_reset
35 +#define OpenSSL_add_all_algorithms() do {} while(0)
36 +#endif
37 """
38 diff --git a/src/cryptography/hazmat/backends/openssl/ciphers.py b/src/cryptography/hazmat/backends/openssl/ciphers.py
39 index 171605a6..4c0504ca 100644
40 --- a/src/cryptography/hazmat/backends/openssl/ciphers.py
41 +++ b/src/cryptography/hazmat/backends/openssl/ciphers.py
42 @@ -199,7 +199,7 @@ class _CipherContext(object):
43 self._backend.openssl_assert(res != 0)
44 self._tag = self._backend._ffi.buffer(tag_buf)[:]
45
46 - res = self._backend._lib.EVP_CIPHER_CTX_cleanup(self._ctx)
47 + res = self._backend._lib.EVP_CIPHER_CTX_reset(self._ctx)
48 self._backend.openssl_assert(res == 1)
49 return self._backend._ffi.buffer(buf)[: outlen[0]]
50
51 --
52 2.26.2
53