|
| 1 | +From 7a341a5d3cb9380e77b0241b5198373ab6fc355e Mon Sep 17 00:00:00 2001 |
| 2 | +From: Charlie Li <vishwin@users.noreply.github.com> |
| 3 | +Date: Sun, 3 Oct 2021 00:20:31 -0400 |
| 4 | +Subject: [PATCH] Support LibreSSL 3.4.0 (#6360) |
| 5 | + |
| 6 | +* Add LibreSSL 3.4.0 to CI |
| 7 | + |
| 8 | +* Add a LibreSSL 3.4.0 guard |
| 9 | + |
| 10 | +Since LibreSSL 3.4.0 makes most of the TLSv1.3 API available, redefine CRYPTOGRAPHY_OPENSSL_LESS_THAN_111 to LibreSSL versions below 3.4.0. |
| 11 | + |
| 12 | +* DTLS_get_data_mtu does not exist in LibreSSL |
| 13 | + |
| 14 | +* Only EVP_Digest{Sign,Verify} exist in LibreSSL 3.4.0+ |
| 15 | + |
| 16 | +* SSL_CTX_{set,get}_keylog_callback does not exist in LibreSSL |
| 17 | + |
| 18 | +* Do not pollute CRYPTOGRAPHY_OPENSSL_LESS_THAN_111 with LibreSSL |
| 19 | + |
| 20 | +While LibreSSL 3.4.0 supports more of TLSv1.3 API, the guard redefinition caused the X448 tests to run when not intended. |
| 21 | +--- |
| 22 | + .github/workflows/ci.yml | 6 ++++-- |
| 23 | + src/_cffi_src/openssl/cryptography.py | 3 +++ |
| 24 | + src/_cffi_src/openssl/evp.py | 15 ++++++++++----- |
| 25 | + src/_cffi_src/openssl/ssl.py | 3 ++- |
| 26 | + 4 files changed, 19 insertions(+), 8 deletions(-) |
| 27 | + |
| 28 | +diff --git src/_cffi_src/openssl/cryptography.py src/_cffi_src/openssl/cryptography.py |
| 29 | +index 878d22d8..821ddc9f 100644 |
| 30 | +--- src/_cffi_src/openssl/cryptography.py |
| 31 | ++++ src/_cffi_src/openssl/cryptography.py |
| 32 | +@@ -36,8 +36,11 @@ INCLUDES = """ |
| 33 | + #if CRYPTOGRAPHY_IS_LIBRESSL |
| 34 | + #define CRYPTOGRAPHY_LIBRESSL_LESS_THAN_332 \ |
| 35 | + (LIBRESSL_VERSION_NUMBER < 0x3030200f) |
| 36 | ++#define CRYPTOGRAPHY_LIBRESSL_LESS_THAN_340 \ |
| 37 | ++ (LIBRESSL_VERSION_NUMBER < 0x3040000f) |
| 38 | + #else |
| 39 | + #define CRYPTOGRAPHY_LIBRESSL_LESS_THAN_332 (0) |
| 40 | ++#define CRYPTOGRAPHY_LIBRESSL_LESS_THAN_340 (0) |
| 41 | + #endif |
| 42 | + |
| 43 | + #define CRYPTOGRAPHY_OPENSSL_110F_OR_GREATER \ |
| 44 | +diff --git src/_cffi_src/openssl/evp.py src/_cffi_src/openssl/evp.py |
| 45 | +index ab7cfeb3..cad3339a 100644 |
| 46 | +--- src/_cffi_src/openssl/evp.py |
| 47 | ++++ src/_cffi_src/openssl/evp.py |
| 48 | +@@ -203,15 +203,21 @@ int (*EVP_PKEY_set1_tls_encodedpoint)(EVP_PKEY *, const unsigned char *, |
| 49 | + size_t) = NULL; |
| 50 | + #endif |
| 51 | + |
| 52 | +-#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_111 |
| 53 | ++#if CRYPTOGRAPHY_LIBRESSL_LESS_THAN_340 || \ |
| 54 | ++ (CRYPTOGRAPHY_OPENSSL_LESS_THAN_111 && !CRYPTOGRAPHY_IS_LIBRESSL) |
| 55 | + static const long Cryptography_HAS_ONESHOT_EVP_DIGEST_SIGN_VERIFY = 0; |
| 56 | +-static const long Cryptography_HAS_RAW_KEY = 0; |
| 57 | +-static const long Cryptography_HAS_EVP_DIGESTFINAL_XOF = 0; |
| 58 | +-int (*EVP_DigestFinalXOF)(EVP_MD_CTX *, unsigned char *, size_t) = NULL; |
| 59 | + int (*EVP_DigestSign)(EVP_MD_CTX *, unsigned char *, size_t *, |
| 60 | + const unsigned char *tbs, size_t) = NULL; |
| 61 | + int (*EVP_DigestVerify)(EVP_MD_CTX *, const unsigned char *, size_t, |
| 62 | + const unsigned char *, size_t) = NULL; |
| 63 | ++#else |
| 64 | ++static const long Cryptography_HAS_ONESHOT_EVP_DIGEST_SIGN_VERIFY = 1; |
| 65 | ++#endif |
| 66 | ++ |
| 67 | ++#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_111 |
| 68 | ++static const long Cryptography_HAS_RAW_KEY = 0; |
| 69 | ++static const long Cryptography_HAS_EVP_DIGESTFINAL_XOF = 0; |
| 70 | ++int (*EVP_DigestFinalXOF)(EVP_MD_CTX *, unsigned char *, size_t) = NULL; |
| 71 | + EVP_PKEY *(*EVP_PKEY_new_raw_private_key)(int, ENGINE *, const unsigned char *, |
| 72 | + size_t) = NULL; |
| 73 | + EVP_PKEY *(*EVP_PKEY_new_raw_public_key)(int, ENGINE *, const unsigned char *, |
| 74 | +@@ -221,7 +227,6 @@ int (*EVP_PKEY_get_raw_private_key)(const EVP_PKEY *, unsigned char *, |
| 75 | + int (*EVP_PKEY_get_raw_public_key)(const EVP_PKEY *, unsigned char *, |
| 76 | + size_t *) = NULL; |
| 77 | + #else |
| 78 | +-static const long Cryptography_HAS_ONESHOT_EVP_DIGEST_SIGN_VERIFY = 1; |
| 79 | + static const long Cryptography_HAS_RAW_KEY = 1; |
| 80 | + static const long Cryptography_HAS_EVP_DIGESTFINAL_XOF = 1; |
| 81 | + #endif |
| 82 | +diff --git src/_cffi_src/openssl/ssl.py src/_cffi_src/openssl/ssl.py |
| 83 | +index ca275e91..0830a463 100644 |
| 84 | +--- src/_cffi_src/openssl/ssl.py |
| 85 | ++++ src/_cffi_src/openssl/ssl.py |
| 86 | +@@ -678,7 +678,8 @@ int (*SSL_set_tlsext_use_srtp)(SSL *, const char *) = NULL; |
| 87 | + SRTP_PROTECTION_PROFILE * (*SSL_get_selected_srtp_profile)(SSL *) = NULL; |
| 88 | + #endif |
| 89 | + |
| 90 | +-#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_111 |
| 91 | ++#if CRYPTOGRAPHY_LIBRESSL_LESS_THAN_340 || \ |
| 92 | ++ (CRYPTOGRAPHY_OPENSSL_LESS_THAN_111 && !CRYPTOGRAPHY_IS_LIBRESSL) |
| 93 | + static const long Cryptography_HAS_TLSv1_3 = 0; |
| 94 | + static const long SSL_OP_NO_TLSv1_3 = 0; |
| 95 | + static const long SSL_VERIFY_POST_HANDSHAKE = 0; |
| 96 | +-- |
| 97 | +2.32.0 |
| 98 | + |
0 commit comments