Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: add a a constant for pyOpenSSL with OpenSSL 3 #7157

Merged
merged 1 commit into from Apr 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/_cffi_src/openssl/err.py
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
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
),
}