Skip to content

Commit

Permalink
add a a constant for pyOpenSSL with OpenSSL 3 (#7157)
Browse files Browse the repository at this point in the history
  • Loading branch information
reaperhulk authored Apr 30, 2022
1 parent 7dd4ff6 commit 8b72741
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/_cffi_src/openssl/err.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
static const int SSL_TLSEXT_ERR_NOACK;
static const int X509_R_CERT_ALREADY_IN_HASH_TABLE;
static const int SSL_R_UNEXPECTED_EOF_WHILE_READING;
static const int Cryptography_HAS_UNEXPECTED_EOF_WHILE_READING;
"""

FUNCTIONS = """
Expand Down Expand Up @@ -67,4 +71,13 @@
#else
static const int CIPHER_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH = 0;
#endif
/* SSL_R_UNEXPECTED_EOF_WHILE_READING is needed for pyOpenSSL
with OpenSSL 3+ */
#if defined(SSL_R_UNEXPECTED_EOF_WHILE_READING)
#define Cryptography_HAS_UNEXPECTED_EOF_WHILE_READING 1
#else
#define Cryptography_HAS_UNEXPECTED_EOF_WHILE_READING 0
#define SSL_R_UNEXPECTED_EOF_WHILE_READING 0
#endif
"""
7 changes: 7 additions & 0 deletions src/cryptography/hazmat/bindings/openssl/_conditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ def cryptography_has_300_evp_cipher() -> typing.List[str]:
return ["EVP_CIPHER_fetch", "EVP_CIPHER_free"]


def cryptography_has_unexpected_eof_while_reading() -> typing.List[str]:
return ["SSL_R_UNEXPECTED_EOF_WHILE_READING"]


# This is a mapping of
# {condition: function-returning-names-dependent-on-that-condition} so we can
# loop over them and delete unsupported names at runtime. It will be removed
Expand Down Expand Up @@ -357,4 +361,7 @@ def cryptography_has_300_evp_cipher() -> typing.List[str]:
"Cryptography_HAS_BN_FLAGS": cryptography_has_bn_flags,
"Cryptography_HAS_EVP_PKEY_DH": cryptography_has_evp_pkey_dh,
"Cryptography_HAS_300_EVP_CIPHER": cryptography_has_300_evp_cipher,
"Cryptography_HAS_UNEXPECTED_EOF_WHILE_READING": (
cryptography_has_unexpected_eof_while_reading
),
}

0 comments on commit 8b72741

Please sign in to comment.