From: "cron2 (Code Review)" Date: Tue, 14 May 2024 16:51:04 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="1G3KspjCPME="; charset=UTF-8 Subject: [Openvpn-devel] [L] Change in openvpn[master]: Remove OpenSSL 1.0.2 support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: flichtenheld , openvpn-devel --1G3KspjCPME= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/55= 9?usp=3Demail ) Change subject: Remove OpenSSL 1.0.2 support ...................................................................... Remove OpenSSL 1.0.2 support With Centos 7/Red Hat Enterprise Linux 7 being EOL this June, the last distributions that still support OpenSSL 1.0.2 are finally EOL. This means we no longer need to support OpenSSL 1.0.2 Change-Id: I90875311a4e4c403e77e30b609c1878cbaaaad45 Signed-off-by: Arne Schwabe Acked-by: Gert Doering Message-Id: <20240514141550.17544-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28= 665.html Signed-off-by: Gert Doering --- M Changes.rst M INSTALL M configure.ac M src/openvpn/crypto_openssl.c M src/openvpn/openssl_compat.h M src/openvpn/ssl_openssl.c 6 files changed, 27 insertions(+), 693 deletions(-) diff --git a/Changes.rst b/Changes.rst index fa0fb22..4bc3bb3 100644 --- a/Changes.rst +++ b/Changes.rst @@ -33,6 +33,10 @@ ``--topology net30`` to the config should fix the problem. By default ``--topology`` is pushed from server to client. =20 +OpenSSL 1.0.2 support + Support for building with OpenSSL 1.0.2 has been removed. The minimum + supported OpenSSL version is now 1.1.0. + Overview of changes in 2.6 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D diff --git a/INSTALL b/INSTALL index a63bab6..6007338 100644 --- a/INSTALL +++ b/INSTALL @@ -66,7 +66,7 @@ (1) TUN and/or TAP driver to allow user-space programs to control a virtual point-to-point IP or Ethernet device. See TUN/TAP Driver References section below for more info. - (2a) OpenSSL library, necessary for encryption, version 1.0.2 or higher + (2a) OpenSSL library, necessary for encryption, version 1.1.0 or higher required, available from http://www.openssl.org/ or (2b) mbed TLS library, an alternative for encryption, version 2.0 or hig= her diff --git a/configure.ac b/configure.ac index ce8b2b0..965ed1a 100644 --- a/configure.ac +++ b/configure.ac @@ -888,7 +888,7 @@ # if the user did not explicitly specify flags, try to autodetect PKG_CHECK_MODULES( [OPENSSL], - [openssl >=3D 1.0.2], + [openssl >=3D 1.1.0], [have_openssl=3D"yes"], [AC_MSG_WARN([OpenSSL not found by pkg-config ${pkg_config_found}])] # = If this fails, we will do another test next ) @@ -903,7 +903,7 @@ # If pkgconfig check failed or OPENSSL_CFLAGS/OPENSSL_LIBS env vars # are used, check the version directly in the OpenSSL include file if test "${have_openssl}" !=3D "yes"; then - AC_MSG_CHECKING([additionally if OpenSSL is available and version >=3D 1= .0.2]) + AC_MSG_CHECKING([additionally if OpenSSL is available and version >=3D 1= .1.0]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ @@ -911,7 +911,7 @@ ]], [[ /* Version encoding: MNNFFPPS - see opensslv.h for details */ -#if OPENSSL_VERSION_NUMBER < 0x10002000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L #error OpenSSL too old #endif ]] @@ -981,7 +981,7 @@ [AC_MSG_ERROR([OpenSSL check for AES-256-GCM support failed])] ) - # All supported OpenSSL version (>=3D 1.0.2) + # All supported OpenSSL version (>=3D 1.1.0) # have this feature have_export_keying_material=3D"yes" diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index 1649ab7..0473fad 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -49,7 +49,7 @@ #include #include -#if (OPENSSL_VERSION_NUMBER >=3D 0x10100000L) && !defined(LIBRESSL_VERSION= _NUMBER) +#if !defined(LIBRESSL_VERSION_NUMBER) #include #endif #if OPENSSL_VERSION_NUMBER >=3D 0x30000000L @@ -193,11 +193,7 @@ void crypto_init_lib(void) { -#if (OPENSSL_VERSION_NUMBER >=3D 0x10100000L) OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL); -#else - OPENSSL_config(NULL); -#endif /* * If you build the OpenSSL library and OpenVPN with * CRYPTO_MDEBUG, you will get a listing of OpenSSL @@ -1401,7 +1397,7 @@ return ret; } -#elif (OPENSSL_VERSION_NUMBER >=3D 0x10100000L) && !defined(LIBRESSL_VERSI= ON_NUMBER) +#elif !defined(LIBRESSL_VERSION_NUMBER) bool ssl_tls1_PRF(const uint8_t *seed, int seed_len, const uint8_t *secret, int secret_len, uint8_t *output, int output_len) @@ -1447,7 +1443,7 @@ EVP_PKEY_CTX_free(pctx); return ret; } -#else /* if OPENSSL_VERSION_NUMBER >=3D 0x10100000L */ +#else /* if defined(LIBRESSL_VERSION_NUMBER) */ /* * Generate the hash required by for the \c tls1_PRF function. * @@ -1626,5 +1622,5 @@ gc_free(&gc); return ret; } -#endif /* if OPENSSL_VERSION_NUMBER >=3D 0x10100000L */ +#endif /* if LIBRESSL_VERSION_NUMBER */ #endif /* ENABLE_CRYPTO_OPENSSL */ diff --git a/src/openvpn/openssl_compat.h b/src/openvpn/openssl_compat.h index c9fa719..95417b2 100644 --- a/src/openvpn/openssl_compat.h +++ b/src/openvpn/openssl_compat.h @@ -50,8 +50,8 @@ #define SSL_CTX_set1_groups SSL_CTX_set1_curves #endif -/* Functionality missing in LibreSSL before 3.5 and OpenSSL 1.0.2 */ -#if (OPENSSL_VERSION_NUMBER < 0x10100000L || (defined(LIBRESSL_VERSION_NUM= BER) && LIBRESSL_VERSION_NUMBER < 0x3050000fL)) && !defined(ENABLE_CRYPTO_W= OLFSSL) +/* Functionality missing in LibreSSL before 3.5 */ +#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x305000= 0fL /** * Destroy a X509 object * @@ -71,659 +71,14 @@ #define EVP_CTRL_AEAD_GET_TAG EVP_CTRL_GCM_GET_TAG #endif -#if (OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMB= ER)) && !defined(ENABLE_CRYPTO_WOLFSSL) +#if defined(LIBRESSL_VERSION_NUMBER) #define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT RSA_F_RSA_EAY_PRIVATE_ENCRYPT #endif -#if (OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(ENABLE_CRYPTO_WOLFSS= L)) || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x305= 0400fL) +#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x305040= 0fL #define SSL_get_peer_tmp_key SSL_get_server_tmp_key #endif -/* Functionality missing in 1.0.2 */ -#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(ENABLE_CRYPTO_WOLFSSL) -/** - * Reset a message digest context - * - * @param ctx The message digest context - * @return 1 on success, 0 on error - */ -static inline int -EVP_MD_CTX_reset(EVP_MD_CTX *ctx) -{ - EVP_MD_CTX_cleanup(ctx); - return 1; -} - -/** - * Free an existing message digest context - * - * @param ctx The message digest context - */ -static inline void -EVP_MD_CTX_free(EVP_MD_CTX *ctx) -{ - free(ctx); -} - -/** - * Allocate a new message digest object - * - * @return A zero'ed message digest object - */ -static inline EVP_MD_CTX * -EVP_MD_CTX_new(void) -{ - EVP_MD_CTX *ctx =3D NULL; - ALLOC_OBJ_CLEAR(ctx, EVP_MD_CTX); - return ctx; -} - -#define EVP_CIPHER_CTX_reset EVP_CIPHER_CTX_init -#define X509_get0_notBefore X509_get_notBefore -#define X509_get0_notAfter X509_get_notAfter - -/** - * Reset a HMAC context - * - * OpenSSL 1.1+ removes APIs HMAC_CTX_init() and HMAC_CTX_cleanup() - * and replace them with a single call that does a cleanup followed - * by an init. A proper _reset() for OpenSSL < 1.1 should perform - * a similar set of operations. - * - * It means that before we kill a HMAC context, we'll have to cleanup - * again, as we probably have allocated a few resources when we forced - * an init. - * - * @param ctx The HMAC context - * @return 1 on success, 0 on error - */ -static inline int -HMAC_CTX_reset(HMAC_CTX *ctx) -{ - HMAC_CTX_cleanup(ctx); - HMAC_CTX_init(ctx); - return 1; -} - -/** - * Cleanup and free an existing HMAC context - * - * @param ctx The HMAC context - */ -static inline void -HMAC_CTX_free(HMAC_CTX *ctx) -{ - HMAC_CTX_cleanup(ctx); - free(ctx); -} - -/** - * Allocate a new HMAC context object - * - * @return A zero'ed HMAC context object - */ -static inline HMAC_CTX * -HMAC_CTX_new(void) -{ - HMAC_CTX *ctx =3D NULL; - ALLOC_OBJ_CLEAR(ctx, HMAC_CTX); - return ctx; -} - -/** - * Fetch the default password callback user data from the SSL context - * - * @param ctx SSL context - * @return The password callback user data - */ -static inline void * -SSL_CTX_get_default_passwd_cb_userdata(SSL_CTX *ctx) -{ - return ctx ? ctx->default_passwd_callback_userdata : NULL; -} - -/** - * Fetch the default password callback from the SSL context - * - * @param ctx SSL context - * @return The password callback - */ -static inline pem_password_cb * -SSL_CTX_get_default_passwd_cb(SSL_CTX *ctx) -{ - return ctx ? ctx->default_passwd_callback : NULL; -} - -/** - * Get the public key from a X509 certificate - * - * @param x X509 certificate - * @return The certificate public key - */ -static inline EVP_PKEY * -X509_get0_pubkey(const X509 *x) -{ - return (x && x->cert_info && x->cert_info->key) ? - x->cert_info->key->pkey : NULL; -} - -/** - * Fetch the X509 object stack from the X509 store - * - * @param store X509 object store - * @return the X509 object stack - */ -static inline STACK_OF(X509_OBJECT) -*X509_STORE_get0_objects(X509_STORE *store) -{ - return store ? store->objs : NULL; -} - -/** - * Get the type of an X509 object - * - * @param obj X509 object - * @return The underlying object type - */ -static inline int -X509_OBJECT_get_type(const X509_OBJECT *obj) -{ - return obj ? obj->type : X509_LU_FAIL; -} - -/** - * Get the RSA object of a public key - * - * @param pkey Public key object - * @return The underlying RSA object - */ -static inline RSA * -EVP_PKEY_get0_RSA(EVP_PKEY *pkey) -{ - return (pkey && pkey->type =3D=3D EVP_PKEY_RSA) ? pkey->pkey.rsa : NUL= L; -} - -/** - * Get the EC_KEY object of a public key - * - * @param pkey Public key object - * @return The underlying EC_KEY object - */ -static inline EC_KEY * -EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) -{ - return (pkey && pkey->type =3D=3D EVP_PKEY_EC) ? pkey->pkey.ec : NULL; -} - - -/** - * Get the DSA object of a public key - * - * @param pkey Public key object - * @return The underlying DSA object - */ -static inline DSA * -EVP_PKEY_get0_DSA(EVP_PKEY *pkey) -{ - return (pkey && pkey->type =3D=3D EVP_PKEY_DSA) ? pkey->pkey.dsa : NUL= L; -} - -/** - * Set the RSA flags - * - * @param rsa The RSA object - * @param flags New flags value - */ -static inline void -RSA_set_flags(RSA *rsa, int flags) -{ - if (rsa) - { - rsa->flags =3D flags; - } -} - -/** - * Get the RSA parameters - * - * @param rsa The RSA object - * @param n The @c n parameter - * @param e The @c e parameter - * @param d The @c d parameter - */ -static inline void -RSA_get0_key(const RSA *rsa, const BIGNUM **n, - const BIGNUM **e, const BIGNUM **d) -{ - if (n !=3D NULL) - { - *n =3D rsa ? rsa->n : NULL; - } - if (e !=3D NULL) - { - *e =3D rsa ? rsa->e : NULL; - } - if (d !=3D NULL) - { - *d =3D rsa ? rsa->d : NULL; - } -} - -/** - * Set the RSA parameters - * - * @param rsa The RSA object - * @param n The @c n parameter - * @param e The @c e parameter - * @param d The @c d parameter - * @return 1 on success, 0 on error - */ -static inline int -RSA_set0_key(RSA *rsa, BIGNUM *n, BIGNUM *e, BIGNUM *d) -{ - if ((rsa->n =3D=3D NULL && n =3D=3D NULL) - || (rsa->e =3D=3D NULL && e =3D=3D NULL)) - { - return 0; - } - - if (n !=3D NULL) - { - BN_free(rsa->n); - rsa->n =3D n; - } - if (e !=3D NULL) - { - BN_free(rsa->e); - rsa->e =3D e; - } - if (d !=3D NULL) - { - BN_free(rsa->d); - rsa->d =3D d; - } - - return 1; -} - -/** - * Number of significant RSA bits - * - * @param rsa The RSA object ; shall not be NULL - * @return The number of RSA bits or 0 on error - */ -static inline int -RSA_bits(const RSA *rsa) -{ - const BIGNUM *n =3D NULL; - RSA_get0_key(rsa, &n, NULL, NULL); - return n ? BN_num_bits(n) : 0; -} - -/** - * Get the DSA parameters - * - * @param dsa The DSA object - * @param p The @c p parameter - * @param q The @c q parameter - * @param g The @c g parameter - */ -static inline void -DSA_get0_pqg(const DSA *dsa, const BIGNUM **p, - const BIGNUM **q, const BIGNUM **g) -{ - if (p !=3D NULL) - { - *p =3D dsa ? dsa->p : NULL; - } - if (q !=3D NULL) - { - *q =3D dsa ? dsa->q : NULL; - } - if (g !=3D NULL) - { - *g =3D dsa ? dsa->g : NULL; - } -} - -/** - * Number of significant DSA bits - * - * @param rsa The DSA object ; shall not be NULL - * @return The number of DSA bits or 0 on error - */ -static inline int -DSA_bits(const DSA *dsa) -{ - const BIGNUM *p =3D NULL; - DSA_get0_pqg(dsa, &p, NULL, NULL); - return p ? BN_num_bits(p) : 0; -} - -/** - * Allocate a new RSA method object - * - * @param name The object name - * @param flags Configuration flags - * @return A new RSA method object - */ -static inline RSA_METHOD * -RSA_meth_new(const char *name, int flags) -{ - RSA_METHOD *rsa_meth =3D NULL; - ALLOC_OBJ_CLEAR(rsa_meth, RSA_METHOD); - rsa_meth->name =3D string_alloc(name, NULL); - rsa_meth->flags =3D flags; - return rsa_meth; -} - -/** - * Free an existing RSA_METHOD object - * - * @param meth The RSA_METHOD object - */ -static inline void -RSA_meth_free(RSA_METHOD *meth) -{ - if (meth) - { - /* OpenSSL defines meth->name to be a const pointer, yet we - * feed it with an allocated string (from RSA_meth_new()). - * Thus we are allowed to free it here. In order to avoid a - * "passing 'const char *' to parameter of type 'void *' discards - * qualifiers" warning, we force the pointer to be a non-const val= ue. - */ - free((char *)meth->name); - free(meth); - } -} - -/** - * Set the public encoding function of an RSA_METHOD object - * - * @param meth The RSA_METHOD object - * @param pub_enc the public encoding function - * @return 1 on success, 0 on error - */ -static inline int -RSA_meth_set_pub_enc(RSA_METHOD *meth, - int (*pub_enc)(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)) -{ - if (meth) - { - meth->rsa_pub_enc =3D pub_enc; - return 1; - } - return 0; -} - -/** - * Set the public decoding function of an RSA_METHOD object - * - * @param meth The RSA_METHOD object - * @param pub_dec the public decoding function - * @return 1 on success, 0 on error - */ -static inline int -RSA_meth_set_pub_dec(RSA_METHOD *meth, - int (*pub_dec)(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)) -{ - if (meth) - { - meth->rsa_pub_dec =3D pub_dec; - return 1; - } - return 0; -} - -/** - * Set the private encoding function of an RSA_METHOD object - * - * @param meth The RSA_METHOD object - * @param priv_enc the private encoding function - * @return 1 on success, 0 on error - */ -static inline int -RSA_meth_set_priv_enc(RSA_METHOD *meth, - int (*priv_enc)(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)) -{ - if (meth) - { - meth->rsa_priv_enc =3D priv_enc; - return 1; - } - return 0; -} - -/** - * Set the private decoding function of an RSA_METHOD object - * - * @param meth The RSA_METHOD object - * @param priv_dec the private decoding function - * @return 1 on success, 0 on error - */ -static inline int -RSA_meth_set_priv_dec(RSA_METHOD *meth, - int (*priv_dec)(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)) -{ - if (meth) - { - meth->rsa_priv_dec =3D priv_dec; - return 1; - } - return 0; -} - -/** - * Set the init function of an RSA_METHOD object - * - * @param meth The RSA_METHOD object - * @param init the init function - * @return 1 on success, 0 on error - */ -static inline int -RSA_meth_set_init(RSA_METHOD *meth, int (*init)(RSA *rsa)) -{ - if (meth) - { - meth->init =3D init; - return 1; - } - return 0; -} - -/** - * Set the sign function of an RSA_METHOD object - * - * @param meth The RSA_METHOD object - * @param sign The sign function - * @return 1 on success, 0 on error - */ -static inline -int -RSA_meth_set_sign(RSA_METHOD *meth, - int (*sign)(int type, const unsigned char *m, - unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, - const RSA *rsa)) -{ - meth->rsa_sign =3D sign; - return 1; -} - -/** - * Set the finish function of an RSA_METHOD object - * - * @param meth The RSA_METHOD object - * @param finish the finish function - * @return 1 on success, 0 on error - */ -static inline int -RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa)) -{ - if (meth) - { - meth->finish =3D finish; - return 1; - } - return 0; -} - -/** - * Set the application data of an RSA_METHOD object - * - * @param meth The RSA_METHOD object - * @param app_data Application data - * @return 1 on success, 0 on error - */ -static inline int -RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data) -{ - if (meth) - { - meth->app_data =3D app_data; - return 1; - } - return 0; -} - -/** - * Get the application data of an RSA_METHOD object - * - * @param meth The RSA_METHOD object - * @return pointer to application data, may be NULL - */ -static inline void * -RSA_meth_get0_app_data(const RSA_METHOD *meth) -{ - return meth ? meth->app_data : NULL; -} - -/** - * Gets the number of bits of the order of an EC_GROUP - * - * @param group EC_GROUP object - * @return number of bits of group order. - */ -static inline int -EC_GROUP_order_bits(const EC_GROUP *group) -{ - BIGNUM *order =3D BN_new(); - EC_GROUP_get_order(group, order, NULL); - int bits =3D BN_num_bits(order); - BN_free(order); - return bits; -} - -/* SSLeay symbols have been renamed in OpenSSL 1.1 */ -#define OPENSSL_VERSION SSLEAY_VERSION -#define OpenSSL_version SSLeay_version - -/** Return the min SSL protocol version currently enabled in the context. - * If no valid version >=3D TLS1.0 is found, return 0. */ -static inline int -SSL_CTX_get_min_proto_version(SSL_CTX *ctx) -{ - long sslopt =3D SSL_CTX_get_options(ctx); - if (!(sslopt & SSL_OP_NO_TLSv1)) - { - return TLS1_VERSION; - } - if (!(sslopt & SSL_OP_NO_TLSv1_1)) - { - return TLS1_1_VERSION; - } - if (!(sslopt & SSL_OP_NO_TLSv1_2)) - { - return TLS1_2_VERSION; - } - return 0; -} - -/** Return the max SSL protocol version currently enabled in the context. - * If no valid version >=3D TLS1.0 is found, return 0. */ -static inline int -SSL_CTX_get_max_proto_version(SSL_CTX *ctx) -{ - long sslopt =3D SSL_CTX_get_options(ctx); - if (!(sslopt & SSL_OP_NO_TLSv1_2)) - { - return TLS1_2_VERSION; - } - if (!(sslopt & SSL_OP_NO_TLSv1_1)) - { - return TLS1_1_VERSION; - } - if (!(sslopt & SSL_OP_NO_TLSv1)) - { - return TLS1_VERSION; - } - return 0; -} - -/** Mimics SSL_CTX_set_min_proto_version for OpenSSL < 1.1 */ -static inline int -SSL_CTX_set_min_proto_version(SSL_CTX *ctx, long tls_ver_min) -{ - long sslopt =3D SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3; /* Never do < TLS 1= .0 */ - - if (tls_ver_min > TLS1_VERSION) - { - sslopt |=3D SSL_OP_NO_TLSv1; - } -#ifdef SSL_OP_NO_TLSv1_1 - if (tls_ver_min > TLS1_1_VERSION) - { - sslopt |=3D SSL_OP_NO_TLSv1_1; - } -#endif -#ifdef SSL_OP_NO_TLSv1_2 - if (tls_ver_min > TLS1_2_VERSION) - { - sslopt |=3D SSL_OP_NO_TLSv1_2; - } -#endif - SSL_CTX_set_options(ctx, sslopt); - - return 1; -} - -/** Mimics SSL_CTX_set_max_proto_version for OpenSSL < 1.1 */ -static inline int -SSL_CTX_set_max_proto_version(SSL_CTX *ctx, long tls_ver_max) -{ - long sslopt =3D 0; - - if (tls_ver_max < TLS1_VERSION) - { - sslopt |=3D SSL_OP_NO_TLSv1; - } -#ifdef SSL_OP_NO_TLSv1_1 - if (tls_ver_max < TLS1_1_VERSION) - { - sslopt |=3D SSL_OP_NO_TLSv1_1; - } -#endif -#ifdef SSL_OP_NO_TLSv1_2 - if (tls_ver_max < TLS1_2_VERSION) - { - sslopt |=3D SSL_OP_NO_TLSv1_2; - } -#endif - SSL_CTX_set_options(ctx, sslopt); - - return 1; -} -#endif /* if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(ENABLE_CRYPT= O_WOLFSSL) */ - /* Functionality missing in 1.1.1 */ #if OPENSSL_VERSION_NUMBER < 0x30000000L && !defined(OPENSSL_NO_EC) diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index 6efef4f..7e74f2f 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -84,13 +84,6 @@ void tls_init_lib(void) { -#if OPENSSL_VERSION_NUMBER < 0x10100000L - SSL_library_init(); -#ifndef ENABLE_SMALL - SSL_load_error_strings(); -#endif - OpenSSL_add_all_algorithms(); -#endif mydata_index =3D SSL_get_ex_new_index(0, "struct session *", NULL, NUL= L, NULL); ASSERT(mydata_index >=3D 0); } @@ -98,12 +91,6 @@ void tls_free_lib(void) { -#if OPENSSL_VERSION_NUMBER < 0x10100000L - EVP_cleanup(); -#ifndef ENABLE_SMALL - ERR_free_strings(); -#endif -#endif } void @@ -526,7 +513,8 @@ void tls_ctx_set_cert_profile(struct tls_root_ctx *ctx, const char *profile) { -#if OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(LIBRESSL_VERSION_NUMB= ER) +#if OPENSSL_VERSION_NUMBER > 0x10100000L \ + && (!defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER > 0x= 3060000fL) /* OpenSSL does not have certificate profiles, but a complex set of * callbacks that we could try to implement to achieve something simil= ar. * For now, use OpenSSL's security levels to achieve similar (but not = equal) @@ -555,7 +543,7 @@ #else /* if OPENSSL_VERSION_NUMBER > 0x10100000L */ if (profile) { - msg(M_WARN, "WARNING: OpenSSL 1.0.2 and LibreSSL do not support " + msg(M_WARN, "WARNING: OpenSSL 1.1.0 and LibreSSL do not support " "--tls-cert-profile, ignoring user-set profile: '%s'", profile= ); } #endif /* if OPENSSL_VERSION_NUMBER > 0x10100000L */ @@ -744,15 +732,6 @@ } else { -#if OPENSSL_VERSION_NUMBER < 0x10100000L - - /* OpenSSL 1.0.2 and newer can automatically handle ECDH parameter - * loading */ - SSL_CTX_set_ecdh_auto(ctx->ctx, 1); - - /* OpenSSL 1.1.0 and newer have always ecdh auto loading enabled, - * so do nothing */ -#endif return; } @@ -1348,7 +1327,7 @@ return 0; } -#if OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(OPENSSL_NO_EC) +#if !defined(OPENSSL_NO_EC) /* called when EC_KEY is destroyed */ static void @@ -1469,7 +1448,7 @@ EC_KEY_free(ec); return 0; } -#endif /* OPENSSL_VERSION_NUMBER > 1.1.0 dev && !defined(OPENSSL_NO_EC) */ +#endif /* !defined(OPENSSL_NO_EC) */ #endif /* ENABLE_MANAGEMENT && !HAVE_XKEY_PROVIDER */ #ifdef ENABLE_MANAGEMENT @@ -1509,7 +1488,7 @@ goto cleanup; } } -#if (OPENSSL_VERSION_NUMBER > 0x10100000L) && !defined(OPENSSL_NO_EC) +#if !defined(OPENSSL_NO_EC) #if OPENSSL_VERSION_NUMBER < 0x30000000L else if (EVP_PKEY_id(pkey) =3D=3D EVP_PKEY_EC) #else /* OPENSSL_VERSION_NUMBER < 0x30000000L */ @@ -1526,13 +1505,13 @@ crypto_msg(M_WARN, "management-external-key requires an RSA or EC = certificate"); goto cleanup; } -#else /* OPENSSL_VERSION_NUMBER > 1.1.0 dev && !defined(OPENSSL_NO_EC) */ +#else /* !defined(OPENSSL_NO_EC) */ else { crypto_msg(M_WARN, "management-external-key requires an RSA certif= icate"); goto cleanup; } -#endif /* OPENSSL_VERSION_NUMBER > 1.1.0 dev && !defined(OPENSSL_NO_EC) */ +#endif /* !defined(OPENSSL_NO_EC) */ #endif /* HAVE_XKEY_PROVIDER */ @@ -2166,7 +2145,7 @@ EVP_PKEY_free(pkey); } -#if (!defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >=3D 0x10= 10000fL) \ +#if !defined(LIBRESSL_VERSION_NUMBER) \ || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >=3D 0= x3090000fL) /** * Translate an OpenSSL NID into a more human readable name @@ -2222,7 +2201,7 @@ } #endif -#if (!defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >=3D 0x10= 10000fL) \ +#if !defined(LIBRESSL_VERSION_NUMBER) \ || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >=3D 0= x3090000fL) /* LibreSSL 3.7.x and 3.8.x implement this function but do not export = it * and fail linking with an unresolved symbol */ -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/559?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I90875311a4e4c403e77e30b609c1878cbaaaad45 Gerrit-Change-Number: 559 Gerrit-PatchSet: 10 Gerrit-Owner: plaisthos Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --1G3KspjCPME= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

Remove OpenSSL 1.0.2 support

With Cento= s 7/Red Hat Enterprise Linux 7 being EOL this June, the last
distributio= ns that still support OpenSSL 1.0.2 are finally EOL. This
means we no lo= nger need to support OpenSSL 1.0.2

Change-Id: I90875311a4e4c403e77e3= 0b609c1878cbaaaad45
Signed-off-by: Arne Schwabe <arne@...1227...><= br>Acked-by: Gert Doering <gert@...1296...>
Message-Id: <202405= 14141550.17544-1-gert@...1296...>
URL: https://www.mail-archive.com/o= penvpn-devel@lists.sourceforge.net/msg28665.html
Signed-off-by: Gert Doe= ring <gert@...1296...>
---
M Changes.rst
M INSTALL
M conf= igure.ac
M src/openvpn/crypto_openssl.c
M src/openvpn/openssl_compat.= h
M src/openvpn/ssl_openssl.c
6 files changed, 27 insertions(+), 693 = deletions(-)

diff --git a/Changes.rst b/Changes.rst
index fa0fb22..4b= c3bb3 100644
--- a/Changes.rst
+++ b/Change= s.rst
@@ -33,6 +33,10 @@
``--topology = net30`` to the config should fix the problem.
By defau= lt ``--topology`` is pushed from server to client.
=
+OpenSSL 1.0.2 support
+ Support for building= with OpenSSL 1.0.2 has been removed. The minimum
+ supported OpenSSL version is now 1.1.0.
+
Ove= rview of changes in 2.6
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

<= span>diff --git a/INSTALL b/INSTALL

index a63bab6..6007338 = 100644
--- a/INSTALL
+++ b/INSTALL@@ -66,7 +66,7 @@
(1) TUN and/or TAP driver to a= llow user-space programs to control
a virtual point-= to-point IP or Ethernet device.
See TUN/TAP Driver R= eferences section below for more info.
- (2a) OpenSSL library, necessary for encryption, version = 1.0.2 or higher
+ (2= a) OpenSSL library, necessary for encryption, version 1.1.0 or higher
required, available from http://www.openssl.org/ or
(2b) mbed TLS library, an alternative = for encryption, version 2.0 or higher
diff --git a/configur= e.ac b/configure.ac
index ce8b2b0..965ed1a 100644--- a/configure.ac
+++ b/configure.ac
@@ -888,7 +888,7 @@

# if the user did not explicitly s= pecify flags, try to autodetect
PKG_CHECK_MODULES(
[OPENSSL],
- [openssl >=3D 1.0.2],
+ [openssl >=3D 1.1.0],
[have_openssl= =3D"yes"],
[AC_MSG_WARN([OpenSSL not found by= pkg-config ${pkg_config_found}])] # If this fails, we will do another test= next
)
@@ -903,7 +903,7 @@
# If pkgconfig check failed or OPENSSL_CFLAGS/OPENSSL_LIBS env vars
# are used, check the version directly in the OpenSSL incl= ude file
if test "${have_openssl}" !=3D "y= es"; then
- AC_MS= G_CHECKING([additionally if OpenSSL is available and version >=3D 1.0.2]= )
+ AC_MSG_CHECKING(= [additionally if OpenSSL is available and version >=3D 1.1.0]) AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM( [[
@@ -911,7 +911,7 @@
]]= ,
[[
/* Version encoding: MNNFFP= PS - see opensslv.h for details */
-#if OPENSSL_VERSION_NUMBER < 0x10002000L
+#if OPENSSL_VERSION_NUMBER < 0x1010= 0000L
#error OpenSSL too old
#endif
]]
@@ -981,7 +981,7 @@
[= AC_MSG_ERROR([OpenSSL check for AES-256-GCM support failed])]
)


+ # All supported OpenSSL version (>=3D= 1.1.0)
# have this feature
have_export= _keying_material=3D"yes"

diff -= -git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.cindex 1649ab7..0473fad 100644
--- a/src/openvpn/cry= pto_openssl.c
+++ b/src/openvpn/crypto_openssl.c
= @@ -49,7 +49,7 @@
#include <openssl/rand.h>

#include <openssl/ssl.h>

<= span style=3D"color: hsl(0, 100%, 40%);">-#if (OPENSSL_VERSION_NUMBER >= =3D 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)

+#if !defined(LIBRESSL_VERSION_NUM= BER)

#include <openssl/kdf.h>
#endi= f
#if OPENSSL_VERSION_NUMBER >=3D 0x30000000L@@ -193,11 +193,7 @@
void
crypto_i= nit_lib(void)
{
-#if (OPENSSL_VERSION_NUMBER >=3D 0x10100000L)
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
-#else
- OPENSSL_config(NULL);
-#endif
/*
= * If you build the OpenSSL library and OpenVPN with
= * CRYPTO_MDEBUG, you will get a listing of OpenSSL
@@ -14= 01,7 +1397,7 @@

return ret; }
-#elif (OPEN= SSL_VERSION_NUMBER >=3D 0x10100000L) && !defined(LIBRESSL_VERSIO= N_NUMBER)
+#elif !def= ined(LIBRESSL_VERSION_NUMBER)
bool
ssl_tl= s1_PRF(const uint8_t *seed, int seed_len, const uint8_t *secret,
= int secret_len, uint8_t *output, int output_len)=
@@ -1447,7 +1443,7 @@
EVP_PKEY_CTX_free(pctx= );
return ret;
}
-#else /* if OPENSSL_VERSION_NUMBER >= =3D 0x10100000L */
+#= else /* if defined(LIBRESSL_VERSION_NUMBER) */
/*<= br> * Generate the hash required by for the \c tls1_PRF function.
*
@@ -1626,5 +1622,5 @@
= gc_free(&gc);
return ret;
}

-#endif /* if OPENSSL_VERS= ION_NUMBER >=3D 0x10100000L */
+#endif /* if LIBRESSL_VERSION_NUMBER */
#end= if /* ENABLE_CRYPTO_OPENSSL */
diff --git a/src/openvpn/ope= nssl_compat.h b/src/openvpn/openssl_compat.h
index c9fa719.= .95417b2 100644
--- a/src/openvpn/openssl_compat.h+++ b/src/openvpn/openssl_compat.h
@@ -50,8 +50,8 @= @
#define SSL_CTX_set1_groups SSL_CTX_set1_curves #endif

-/* Functionality missing in LibreSSL before 3.5 and OpenSSL 1.0= .2 */
-#if (OPENSSL_VER= SION_NUMBER < 0x10100000L || (defined(LIBRESSL_VERSION_NUMBER) &&= ; LIBRESSL_VERSION_NUMBER < 0x3050000fL)) && !defined(ENABLE_CRY= PTO_WOLFSSL)
+/* Func= tionality missing in LibreSSL before 3.5 */
+#if defined(LIBRESSL_VERSION_NUMBER) && LIB= RESSL_VERSION_NUMBER < 0x3050000fL
/**
= * Destroy a X509 object
*
@@ -71,659 +7= 1,14 @@
#define EVP_CTRL_AEAD_GET_TAG EVP_C= TRL_GCM_GET_TAG
#endif

-#if (OPENSSL_VERSION_NUMBER < 0x1010= 0000L || defined(LIBRESSL_VERSION_NUMBER)) && !defined(ENABLE_CRYPT= O_WOLFSSL)
+#if defin= ed(LIBRESSL_VERSION_NUMBER)
#define RSA_F_RSA_OSSL_PRIVATE= _ENCRYPT RSA_F_RSA_EAY_PRIVATE_ENCRYPT
#endif=

-#if (OPENS= SL_VERSION_NUMBER < 0x10100000L && !defined(ENABLE_CRYPTO_WOLFSS= L)) || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER= < 0x3050400fL)
+#= if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER <= 0x3050400fL
#define SSL_get_peer_tmp_key SSL_get_server_t= mp_key
#endif

-/* Functionality missing in 1.0.2 */
<= span style=3D"color: hsl(0, 100%, 40%);">-#if OPENSSL_VERSION_NUMBER < 0= x10100000L && !defined(ENABLE_CRYPTO_WOLFSSL)
-/**
- * Reset a message digest context
- *
- * @param ctx The message digest context
<= span style=3D"color: hsl(0, 100%, 40%);">- * @return 1 o= n success, 0 on error
-= */
-static inline int<= /span>
-EVP_MD_CTX_reset(EVP_M= D_CTX *ctx)
-{- EVP_MD_CTX_cleanup(ctx);
- return 1;-}
-
- * Free an exis= ting message digest context
- *
- * @param ctx= The message digest context
- */
-static inline void
= -EVP_MD_CTX_free(EVP_MD_CTX *ctx)
-{
- free= (ctx);
-}
-

-/**
= - * Allocate a new message digest object
- *
-= * @return A zero'ed message digest object- */
-static inline EVP_MD_CTX *
-EVP_MD_CTX_new(void)
-{
- EVP_MD_CTX *ctx =3D NULL;
- ALLOC_OBJ_CLEAR(ctx, EVP_MD_CTX);
- return ctx;
-}
-
-#define E= VP_CIPHER_CTX_reset EVP_CIPHER_CTX_init
-#define X509_get0_notBefore X509_get_notBefore
= -#define X509_get0_notAfter X509_= get_notAfter
--/**
- * Reset a HMAC context
- *
- * OpenSSL 1.1+ removes APIs HMAC_CTX_init() and HMAC_CTX_cleanup= ()
- * and replace them= with a single call that does a cleanup followed
- * by an init. A proper _reset() for OpenSSL <= ; 1.1 should perform
- = * a similar set of operations.
- *
- * It mean= s that before we kill a HMAC context, we'll have to cleanup
<= span style=3D"color: hsl(0, 100%, 40%);">- * again, as we probably have all= ocated a few resources when we forced

- * an init.
- *
- * @param ctx= The HMAC context
- * @return 1 on success, 0 on error- */
-static inline int
-HMAC_CTX_reset(HMAC_CTX *ctx)
-{
- HMAC_CTX_cleanup(ctx);
- HMAC_CTX_init(ctx);
- return 1;
-}
--/**
- * Cleanup and free an existing HMAC context
- *
- * @param ctx The HMAC cont= ext
- */
-static inline void

-HMAC_CTX_free(HMAC_CTX *ctx)
= -{
- HMAC_CTX_cleanup(ctx);
- free(ctx);
-}
= -
-/**
- * Allocate a new HMAC context object<= /span>
- *
- * @return A zero'= ed HMAC context object
= - */
-static inline HMA= C_CTX *
-HMAC_CTX_new(v= oid)
-{
- HMAC_CTX *ctx =3D NULL;
- ALLOC_OBJ_CLEAR(ctx, HMAC_C= TX);
- return ctx;
-}
-
-/**
- * Fetc= h the default password callback user data from the SSL context
- *

- * @param ctx SSL context
- * @return The p= assword callback user data
- */
-static inline= void *
-SSL_CTX_get_de= fault_passwd_cb_userdata(SSL_CTX *ctx)
-{
- = return ctx ? ctx->default_passwd_callback_userdata : NULL;
-}
-
-= /**
- * Fetch the defau= lt password callback from the SSL context
- *
= - * @param ctx SSL context
- * @return The password callback
- */
-static inline pem_password_cb *
<= span style=3D"color: hsl(0, 100%, 40%);">-SSL_CTX_get_default_passwd_cb(SSL= _CTX *ctx)

-{- return ctx ? ctx->defaul= t_passwd_callback : NULL;
-}
-
-/**
- * Get the public key from a X509 certificate- *
- * @param x X509 certificate
- * @return = The certificate public key
- */
-static inl= ine EVP_PKEY *
-X509_ge= t0_pubkey(const X509 *x)
- return (x &am= p;& x->cert_info && x->cert_info->key) ?
- x->cert_info->key-= >pkey : NULL;

-}
-
-/**
- * Fetch the X509 object stack from the X509 store
- *

- * @param store X509 object store<= br>- * @return = the X509 object stack
-= */
-static inline STAC= K_OF(X509_OBJECT)
-*X50= 9_STORE_get0_objects(X509_STORE *store)
-{
- = return store ? store->objs : NULL;
-}
-
-/**
- * Get the type of an X509 object<= br>- *
- * @param obj X509 object<= br>- * @return = The underlying object type
- */
-static inline= int
-X509_OBJECT_get_t= ype(const X509_OBJECT *obj)
-{
- return obj= ? obj->type : X509_LU_FAIL;
-}
--/**
- * Get the RSA object of a public key
<= span style=3D"color: hsl(0, 100%, 40%);">- *

- * @param pkey Public key object
- * @return = The underlying RSA object
- */
-static inl= ine RSA *
-EVP_PKEY_get= 0_RSA(EVP_PKEY *pkey)
-= {
- return (pkey &am= p;& pkey->type =3D=3D EVP_PKEY_RSA) ? pkey->pkey.rsa : NULL;
-}
-
-/**
- * Get the= EC_KEY object of a public key
- *
- * @param = pkey Public key object
- * @return The underlying EC_KEY object<= /span>
- */
-static inline EC_KEY *
-EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)

-{
- return (pkey && pkey->type = =3D=3D EVP_PKEY_EC) ? pkey->pkey.ec : NULL;
-}
-
-
-/**
- * Get the DSA object of a public key
- *
- * @param pkey Public key object
= - * @return Th= e underlying DSA object
- */
-static inline DS= A *
-EVP_PKEY_get0_DSA(= EVP_PKEY *pkey)
-{
- return (pkey &&= ; pkey->type =3D=3D EVP_PKEY_DSA) ? pkey->pkey.dsa : NULL;
= -}
-
-/**
- * Set the RSA f= lags
- *
- * @param rsa The RS= A object

- * @param fla= gs New flags value
- */
-static = inline void
-RSA_set_fl= ags(RSA *rsa, int flags)
- if (rsa)
- {
- rsa->flags =3D flags;- }
-}
-
-/**- * Get the RSA parameters

- *
- * @param rsa The RSA object
- * @param n = The @c n parameter
- * @param e The @c e parameter
- * @param d The @c d para= meter
- */
-static inline void

-RSA_get0_key(const RSA *rsa, const BI= GNUM **n,
- = const BIGNUM **e, const BIGNUM **d)
-{
- i= f (n !=3D NULL)
- {<= /span>
- *n =3D rsa ? r= sa->n : NULL;
- }=
- if (e !=3D NULL)<= /span>
- {
- *e =3D rsa ? rsa->e : NULL;=
- }
- if (d !=3D NULL)

- {
- *d =3D rsa ? rsa->d : NULL;
- }

-}
-
-/**
- * Set the RSA parameters
<= span style=3D"color: hsl(0, 100%, 40%);">- *
- * @param rsa The RSA object<= br>- * @param n = The @c n parameter
- *= @param e The @c e parameter
- * @param d The @c d parameter
- * @return = 1 on success, 0 on error
- */
-static i= nline int
-RSA_set0_key= (RSA *rsa, BIGNUM *n, BIGNUM *e, BIGNUM *d)
-{
- if ((rsa->n =3D=3D NULL && n =3D=3D NULL)
- || (rsa->e =3D=3D NULL &= ;& e =3D=3D NULL))
= - {
- return = 0;
- }
-

- if (n !=3D NULL)
- {
- BN_free(rsa->n);
- rsa->n =3D n;
- }
- i= f (e !=3D NULL)
- {<= /span>
- BN_free(rsa-&g= t;e);
- rsa->= e =3D e;
- }<= br>- if (d !=3D NULL)- {
- BN_free(rsa->d);
- rsa->d =3D d;
- }

-
= - return 1;
-}

-
-/**
- * Number of significant RSA bits
- *
- * @param rsa The RSA object ; shall not be NULL- * @return Th= e number of RSA bits or 0 on error
- */
-stati= c inline int
-RSA_bits(= const RSA *rsa)
-{
- const BIGNUM *n =3D NU= LL;
- RSA_get0_key(r= sa, &n, NULL, NULL);
-}
-
-/**
- * Get the DSA parameters
- *
- * @param dsa The DSA object
- * @param p The @= c p parameter

- * @para= m q The @c q parameter
- * @param g The @c g parameter<= br>- */
-static inline void
-DSA_get0_pqg(const DSA *dsa, const BIGNUM **p,
- const BIGNUM= **q, const BIGNUM **g)
-{
- if (p !=3D NUL= L)
- {
- *p =3D dsa ? dsa->p : NU= LL;

- }
- if (q !=3D NULL)

- {
- *q =3D dsa ? dsa->q : NULL;
- }
- if (g !=3D NULL)
- {
- *g =3D dsa ? dsa->g : NULL;
- }
-}
-
= -/**
- * Number of significant DSA bits
- *
- * @param rsa The DSA object ; shall not b= e NULL
- * @return = The number of DSA bits or 0 on error
- */
-static inline int
-DSA_bits(const DSA *dsa)
-{
- const = BIGNUM *p =3D NULL;
- = DSA_get0_pqg(dsa, &p, NULL, NULL);
- return p ? BN_num_bits(p) : 0;
-}
-
-/**

- * Allocate a new RSA metho= d object
- *
= - * @param name The= object name
- * @param= flags Configuration flags
- * @return A new RSA method object
- */
-static inline RSA_METHOD *
-RSA_meth_new(const char *name, int fla= gs)
-{
- RSA_METHOD *rsa_meth =3D NULL;
- ALLOC_OBJ_CLEAR(rsa_m= eth, RSA_METHOD);
- = rsa_meth->name =3D string_alloc(name, NULL);
- rsa_meth->flags =3D flags;
- return rsa_meth;

-}
-
-/**<= /span>
- * Free an existing RS= A_METHOD object
- *
- * @param meth = The RSA_METHOD object
- */
-static inline = void
-RSA_meth_free(RSA= _METHOD *meth)
-{
- if (meth)
- {

- /* OpenSSL defines meth->name to be a co= nst pointer, yet we
- = * feed it with an allocated string (from RSA_meth_new()).
= - * Thus we are allowed t= o free it here. In order to avoid a
- * "passing 'const char *' to parameter = of type 'void *' discards
- * qualifiers" warning, we force the pointer to be= a non-const value.
- = */
- free= ((char *)meth->name);
= - }
-}
-

-/**
= - * Set the public encoding function of an RSA_METHOD object
- *

- * @param meth The RSA_METHOD object
- * @param pub_enc = the public encoding function
- * @return 1 on success, 0 on error
<= span style=3D"color: hsl(0, 100%, 40%);">- */

-static inline int
-RSA_meth_set_pub_enc(RSA_METHOD *meth,
- int (*pub_enc)(in= t flen, const unsigned char *from,
- unsigned char *to, RSA *rs= a,
- = int padding))
-{
- if (met= h)
- {
- meth->rsa_pub_enc =3D pu= b_enc;

- return = 1;
- }
- return 0;
-}
-
-/**
- * Set the public decoding = function of an RSA_METHOD object
- *
- * @para= m meth The RSA_METHOD object
- * @param pub_dec the public decoding funct= ion
- * @return = 1 on success, 0 on error
- */
-stat= ic inline int
-RSA_meth= _set_pub_dec(RSA_METHOD *meth,
- int (*pub_dec)(int flen, const unsigned char = *from,
- = unsigned char *to, RSA *rsa,
- int padding= ))
-{
- if (meth)
- {
- meth->rsa_pub_dec =3D pub_dec;
- return 1;
- }
- return 0;
-}
-
-/**

- * Set the private encoding function of an RSA_METHOD o= bject
- *
- * @param meth The RS= A_METHOD object
- * @pa= ram priv_enc the private encoding function
- * @return 1 on success, = 0 on error
- */<= br>-static inline int
<= span style=3D"color: hsl(0, 100%, 40%);">-RSA_meth_set_priv_enc(RSA_METHOD = *meth,
- = int (*priv_enc)(int flen, const unsigned char *from,
- = unsigned char *to, RSA *rsa,
- int padding))
-{
- if (meth)
- {
- = meth->rsa_priv_enc =3D priv_enc;
- return 1;
- }
- = return 0;
-}
= -
-/**
- * Set the private decoding function of an RSA_METHOD object
= - *
- * @param meth The RSA_METHOD object<= /span>
- * @param priv_dec = the private decoding function
- * @return 1 on success, 0 on error=
- */
-static inline int
-RSA_meth_set_priv_dec(RSA_METHOD *meth,
= - int (*priv= _dec)(int flen, const unsigned char *from,
- unsigned char *t= o, RSA *rsa,
- = int padding))
-{
= - if (meth)
- {
- meth->rsa_pr= iv_dec =3D priv_dec;
- = return 1;
- }=
- return 0;<= br>-}
-
-/**
- * Set the in= it function of an RSA_METHOD object
- *
- * @p= aram meth The RSA_METHOD object
- * @param init the init function
- * @return = 1 on success, 0 on error
- */
-static inlin= e int
-RSA_meth_set_ini= t(RSA_METHOD *meth, int (*init)(RSA *rsa))
-{
= - if (meth)
- {
- meth->init = =3D init;
- retu= rn 1;
- }
= - return 0;
-}
-
-/**

- * Set the sign function= of an RSA_METHOD object
- * @param meth = The RSA_METHOD object
- * @param sign The sign function
- * @return 1 on suc= cess, 0 on error
- */
-static inline-int
-RSA_meth_set_sign(RSA_METHOD *meth,
- int (*sign)(int t= ype, const unsigned char *m,

- unsigned int m_length,
- unsigne= d char *sigret, unsigned int *siglen,
- const RSA *rsa))
-{
- meth->rsa_sign =3D sign;
- return 1;
-}
-
-/**
- * Set the finish function of an RS= A_METHOD object
- *

- * @param meth = The RSA_METHOD object
- * @param finish the finish function
- * @return 1 on success, = 0 on error
- */<= br>-static inline int
<= span style=3D"color: hsl(0, 100%, 40%);">-RSA_meth_set_finish(RSA_METHOD *m= eth, int (*finish)(RSA *rsa))
-{
- if (meth= )
- {
- meth->finish =3D finish;<= /span>
- return 1;

- }
- return 0;
-}
-
-/**
- * Set the application data of an = RSA_METHOD object
- *
- * @param meth = The RSA_METHOD object
- * @param app_data Application data
- * @return 1 on success, = 0 on error
- */<= br>-static inline int
<= span style=3D"color: hsl(0, 100%, 40%);">-RSA_meth_set0_app_data(RSA_METHOD= *meth, void *app_data)

-{
- if (meth)
- {
- meth->app_data =3D app_data;

- return 1;=
- }
- return 0;
-}
-
-/**
- * Get the application data of an R= SA_METHOD object
- *

- * @param meth = The RSA_METHOD object
- * @return pointer to application data, may be NULL<= /span>
- */
-static inline void *
-RSA_meth_get0_app_data(const RSA_METHOD *= meth)
-{
- return meth ? meth->app_data = : NULL;

-}
-
-/**
- * Gets the number of bits of the order of an EC_GROUP
- *
- * @param group EC_GROUP object
<= span style=3D"color: hsl(0, 100%, 40%);">- * @return n= umber of bits of group order.
- */
-static inl= ine int
-EC_GROUP_order= _bits(const EC_GROUP *group)
-{
- BIGNUM *o= rder =3D BN_new();
- = EC_GROUP_get_order(group, order, NULL);
- int bits =3D BN_num_bits(order);
- BN_free(order);
- return bits;
-}
-
-/* SSLeay symb= ols have been renamed in OpenSSL 1.1 */
-#define OPENSSL_VERSION SSLEAY_VERSION
-#define OpenSSL_version SSLeay_version
-
-/** Return the min SSL protocol version cur= rently enabled in the context.
- * If no valid version >=3D TLS1.0 is found, return 0. */
-static inline int-SSL_CTX_get_min_proto_version(= SSL_CTX *ctx)
-{=
- long sslopt =3D SSL_CTX_= get_options(ctx);
- = if (!(sslopt & SSL_OP_NO_TLSv1))
- {
- = return TLS1_VERSION;
- }
- if (!(= sslopt & SSL_OP_NO_TLSv1_1))
- {
- = return TLS1_1_VERSION;
- }
- if (!(ss= lopt & SSL_OP_NO_TLSv1_2))
- {
- = return TLS1_2_VERSION;
- }
- return 0;<= /span>
-}
-
-/** Return the max SSL protocol version currently enabled in th= e context.
- * If no v= alid version >=3D TLS1.0 is found, return 0. */
-static inline int
-SSL_CTX_get_max_proto_version(SSL_CTX *ctx)=
-{
- long sslopt =3D SSL_CTX_get_options(ctx);

- if (!(sslopt & S= SL_OP_NO_TLSv1_2))
- = {
- return TLS1= _2_VERSION;
- }
- if (!(sslopt & SSL= _OP_NO_TLSv1_1))
- {=
- return TLS1_1= _VERSION;
- }=
- if (!(sslopt & SSL_O= P_NO_TLSv1))
- {
- return TLS1_VERSI= ON;
- }
- return 0;

-}
-
-/** Mimi= cs SSL_CTX_set_min_proto_version for OpenSSL < 1.1 */
-static inline int
-SSL_CTX_set_min_proto_version(SSL_CTX *ctx,= long tls_ver_min)
-{
- long sslopt =3D SSL= _OP_NO_SSLv2 | SSL_OP_NO_SSLv3; /* Never do < TLS 1.0 */
-

- if (tls_ver_min > TLS1_VERSION)
- {
- sslopt |=3D SSL_OP_NO_TLSv1;
- }
-#ifdef SSL_OP_NO_TLSv1_1
- if (tls_ver_min > TLS1_1_VERSION)
- {

- sslopt |=3D SSL_OP_NO_TLSv1_1;
- }
-#endif
-#ifdef SSL_OP_NO_TLSv1_2
- if (tls_ver_min > TLS1_2_VERSION)
- {
- sslopt |=3D SSL_OP_NO_TLSv1_2;
- }
-#endif
- SSL_CTX_set_options(ctx, sslopt);
-
- = return 1;
-}-
-/** Mimics SSL_CTX_set_max_proto_version for OpenSSL= < 1.1 */
-static in= line int
-SSL_CTX_set_m= ax_proto_version(SSL_CTX *ctx, long tls_ver_max)
-{
- long sslopt =3D 0;
-
- if (tls_v= er_max < TLS1_VERSION)
- {
- sslo= pt |=3D SSL_OP_NO_TLSv1;
-#ifdef SSL_OP= _NO_TLSv1_1
- if (tl= s_ver_max < TLS1_1_VERSION)
- {
- = sslopt |=3D SSL_OP_NO_TLSv1_1;
- }
-#endif=
-#ifdef SSL_OP_NO_TLSv= 1_2
- if (tls_ver_ma= x < TLS1_2_VERSION)
= - {
- sslopt = |=3D SSL_OP_NO_TLSv1_2;
- }
-#endif<= br>- SSL_CTX_set_options(ctx, = sslopt);
-
- return 1;
-}
-#endif /* if OPENSSL_VERSION_NUMBER < 0x10100000L &&= ; !defined(ENABLE_CRYPTO_WOLFSSL) */
-
/* Functionality missing in 1.1.1 */

#if OPENSSL_VERSION_NUMBER < 0x30000000L && !defined= (OPENSSL_NO_EC)

diff --git a/src/openvpn/= ssl_openssl.c b/src/openvpn/ssl_openssl.c
index 6efef4f..7e= 74f2f 100644
--- a/src/openvpn/ssl_openssl.c
+++ b/src/openvpn/ssl_openssl.c
@@ -84,13 +84,6 @@=
void
tls_init_lib(void)
{

-#if OPENSSL_VERSION_NUMBER= < 0x10100000L
- = SSL_library_init();
-#i= fndef ENABLE_SMALL
- = SSL_load_error_strings();
-#endif
- OpenSS= L_add_all_algorithms();
-#endif
mydata_index =3D SSL_get_ex_new_index(0, &quo= t;struct session *", NULL, NULL, NULL);
ASSERT(my= data_index >=3D 0);
}
@@ -98,12 +91,6 @= @
void
tls_free_lib(void)
{
-#if OPENSSL_VERSIO= N_NUMBER < 0x10100000L
- EVP_cleanup();
= -#ifndef ENABLE_SMALL
-= ERR_free_strings();
-#endif
-#endif=
}

void
@@ -52= 6,7 +513,8 @@
void
tls_ctx_set_cert_profi= le(struct tls_root_ctx *ctx, const char *profile)
{=
-#if OPENSSL_VERSION_NUMBER &= gt; 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
+#if OPENSSL_VERSION_NUMBER > 0x= 10100000L \
+ &= ;& (!defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER > = 0x3060000fL)
/* OpenSSL does not have certificate prof= iles, but a complex set of
* callbacks that we could = try to implement to achieve something similar.
* For = now, use OpenSSL's security levels to achieve similar (but not equal)
@@ -555,7 +543,7 @@
#else /* if OPENSSL_VE= RSION_NUMBER > 0x10100000L */
if (profile) {
- = msg(M_WARN, "WARNING: OpenSSL 1.0.2 and LibreSSL do not support "= ;
+ msg(M_WARN= , "WARNING: OpenSSL 1.1.0 and LibreSSL do not support " "--tls-cert-profile, ignoring user-set profile: &#= 39;%s'", profile);
}
#endif = /* if OPENSSL_VERSION_NUMBER > 0x10100000L */
@@ -744,15= +732,6 @@
}
else
{

-#if OPENSSL_VE= RSION_NUMBER < 0x10100000L
-
- /* Op= enSSL 1.0.2 and newer can automatically handle ECDH parameter
- * loading */
- SSL_CTX_set_ecdh_auto(ctx-&= gt;ctx, 1);
-- /* OpenSSL 1.1.0 and ne= wer have always ecdh auto loading enabled,
- * so do nothing */
-#endif
return; }

@@ -1348,7 +1327,7 @@

return 0;
}

<= span style=3D"color: hsl(0, 100%, 40%);">-#if OPENSSL_VERSION_NUMBER > 0= x10100000L && !defined(OPENSSL_NO_EC)
+#if !defined(OPENSSL_NO_EC)

/* called when EC_KEY is destroyed */
static= void
@@ -1469,7 +1448,7 @@
EC_KEY_fre= e(ec);
return 0;
}
-#endif /* OPENSSL_VERSION_NUMBER > 1.= 1.0 dev && !defined(OPENSSL_NO_EC) */
+#endif /* !defined(OPENSSL_NO_EC) */
#endif /* ENABLE_MANAGEMENT && !HAVE_XKEY_PROVIDER */

#ifdef ENABLE_MANAGEMENT
@@ -150= 9,7 +1488,7 @@
goto cleanup;
= }
}
-#if (OPENSSL_VERSION_NUMBER > 0x10100000L) && !define= d(OPENSSL_NO_EC)
+#if= !defined(OPENSSL_NO_EC)
#if OPENSSL_VERSION_NUMBER < 0= x30000000L
else if (EVP_PKEY_id(pkey) =3D=3D EVP_PKEY_= EC)
#else /* OPENSSL_VERSION_NUMBER < 0x30000000L */
@@ -1526,13 +1505,13 @@
crypto_msg(M= _WARN, "management-external-key requires an RSA or EC certificate"= ;);
goto cleanup;
}-#else /* OPENSSL_VERSION_NUMBE= R > 1.1.0 dev && !defined(OPENSSL_NO_EC) */
+#else /* !defined(OPENSSL_NO_EC) */
else
{
cryp= to_msg(M_WARN, "management-external-key requires an RSA certificate&qu= ot;);
goto cleanup;
}<= br>-#endif /* OPENSSL_VERSION_NUM= BER > 1.1.0 dev && !defined(OPENSSL_NO_EC) */
+#endif /* !defined(OPENSSL_NO_EC) */

#endif /* HAVE_XKEY_PROVIDER */
@@ -2166,7 +2145,7 @@
EVP_PKE= Y_free(pkey);
}

-#if (!defined(LIBRESSL_VERSION_NUMBER) &&a= mp; OPENSSL_VERSION_NUMBER >=3D 0x1010000fL) \
+#if !defined(LIBRESSL_VERSION_NUMBER) \

|| (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VE= RSION_NUMBER >=3D 0x3090000fL)
/**
* = Translate an OpenSSL NID into a more human readable name
@@= -2222,7 +2201,7 @@
}
#endif
-#if (!define= d(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >=3D 0x1010= 000fL) \
+#if !define= d(LIBRESSL_VERSION_NUMBER) \
|| (defined(LIBRESSL_VERS= ION_NUMBER) && LIBRESSL_VERSION_NUMBER >=3D 0x3090000fL)<= br> /* LibreSSL 3.7.x and 3.8.x implement this function but do no= t export it
* and fail linking with an unresolved sym= bol */

To view, visit change 559. To unsubsc= ribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I90875311a4e4c403e77e30b609c= 1878cbaaaad45
Gerrit-Change-Number: 559
Gerrit-PatchSet: 10
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--1G3KspjCPME=--