Skip to contentSkip to conversation

Improve OpenSSL 3.0 support in OpenVPN 2.5

PATCH In review Arne Schwabe 2 participants 17 messages May 12, 2022 – May 13, 2022

lore
Share & tools
lore
#0 lore raw

cover Improve OpenSSL 3.0 support in OpenVPN 2.5

We already see distros shipping 2.5 with OpenSSL 3.0 and while it builds and works, there are number of problems. This patch addresses most of them while not backporting the full refactoring that also allows using ciphers and digests from providers that were not present in OpenSSL itself. Also the patches that allow a build and make check to suceed with OpenSSL 3.0 have been backported.

Most of the commits are cherry-picked from master with small changes were needed. The exception is the

From Changes.rst:

Limited OpenSSL 3.0 support
OpenSSL 3.0 support has been added. OpenSSL 3.0 support in 2.5 relies on the compatiblity layer and full OpenSSL 3.0 support is coming with OpenVPN 2.6. Only features that impact usage directly have been backported:

``--tls-cert-profile insecure`` has been added to allow selecting the lowest OpenSSL security level (not recommended, use only if you must).

OpenSSL 3.0 no longer supports the Blowfish (and other deprecated) algorithm by default and the new option ``--providers`` allows loading the legacy provider to renable these algorithms.

The OpenSSL engine feature ``--engine`` is not enabled by default anymore if OpenSSL 3.0 is detected.

Arne Schwabe (7):
Refactor early initialisation and uninitialisation into methods Allow loading of non default providers
Add ubuntu 22.04 to Github Actions
Add macos OpenSSL 3.0 and ASAN builds
Add --with-openssl-engine autoconf option (auto|yes|no) Fix allowing/showing unsupported ciphers and digests Remove dependency on BF-CBC existance from test_ncp

 .github/workflows/build.yaml         | 34 ++++++++++--
 Changes.rst                          | 17 ++++++
 configure.ac                         | 60 ++++++++++++++++-----
 doc/man-sections/generic-options.rst | 12 +++++
 src/openvpn/crypto_backend.h         | 15 ++++++
 src/openvpn/crypto_mbedtls.c         | 13 +++++
 src/openvpn/crypto_mbedtls.h         |  3 ++
 src/openvpn/crypto_openssl.c         | 81 ++++++++++++++++++++++++++--
 src/openvpn/crypto_openssl.h         | 11 ++++
 src/openvpn/openvpn.c                | 36 +++++++++++--
 src/openvpn/options.c                |  8 +++
 src/openvpn/options.h                |  9 ++++
 tests/unit_tests/openvpn/test_ncp.c  | 10 +++-
 13 files changed, 282 insertions(+), 27 deletions(-)
Signature · 1 line
2.32.0 (Apple Git-132)
#1 lore raw

PATCH 1/7 Refactor early initialisation and uninitialisation into methods

This put the early initialisation and uninitialisation that needs to happen between option parsing and post processing into small methods.

Cherry-pick of 97056dbf9 as prerequirement for the provider patch

---
 src/openvpn/openvpn.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
src/openvpn/openvpn.c +18 -5
index a21b21e23..e03d25450 100644
@@ -105,6 +105,20 @@ tunnel_point_to_point(struct context *c)
 
 #undef PROCESS_SIGNAL_P2P
 
+void init_early(struct context *c)
+{
+    net_ctx_init(c, &c->net_ctx);
+
+    /* init verbosity and mute levels */
+    init_verb_mute(c, IVM_LEVEL_1);
+
+}
+
+static void uninit_early(struct context *c)
+{
+    net_ctx_free(&c->net_ctx);
+}
+
 
 /**************************************************************************/
 /**
@@ -193,10 +207,9 @@ openvpn_main(int argc, char *argv[])
             open_plugins(&c, true, OPENVPN_PLUGIN_INIT_PRE_CONFIG_PARSE);
 #endif
 
-            net_ctx_init(&c, &c.net_ctx);
-
-            /* init verbosity and mute levels */
-            init_verb_mute(&c, IVM_LEVEL_1);
+            /* Early initialisation that need to happen before option
+             * post processing and other early startup but after parsing */
+            init_early(&c);
 
             /* set dev options */
             init_options_dev(&c.options);
@@ -308,7 +321,7 @@ openvpn_main(int argc, char *argv[])
             env_set_destroy(c.es);
             uninit_options(&c.options);
             gc_reset(&c.gc);
-            net_ctx_free(&c.net_ctx);
+            uninit_early(&c);
         }
         while (c.sig->signal_received == SIGHUP);
     }
Signature · 1 line
2.32.0 (Apple Git-132)
#3 lore raw

PATCH 2/7 Allow loading of non default providers

In reply to Arne Schwabe

This allows OpenVPN to load non-default providers. This is mainly useful for loading the legacy provider with --providers legacy default

Cherry-pick of 08081aa0a153 to release/2.5. Changes.rst has been adjust to better fit the changes in 2.5.

---
 Changes.rst                          | 14 +++++++++++++
 doc/man-sections/generic-options.rst | 12 +++++++++++
 src/openvpn/crypto_backend.h         | 15 ++++++++++++++
 src/openvpn/crypto_mbedtls.c         | 13 ++++++++++++
 src/openvpn/crypto_mbedtls.h         |  3 +++
 src/openvpn/crypto_openssl.c         | 31 ++++++++++++++++++++++++++++
 src/openvpn/crypto_openssl.h         | 11 ++++++++++
 src/openvpn/openvpn.c                | 15 +++++++++++++-
 src/openvpn/options.c                |  8 +++++++
 src/openvpn/options.h                |  9 ++++++++
 10 files changed, 130 insertions(+), 1 deletion(-)
Changes.rst +14 -0
index 45d2c3f39..884c122a9 100644
@@ -14,6 +14,20 @@ New features
 
 - upgrade pkcs11-helper to release 1.28.4
 
+- Limited OpenSSL 3.0 support
+    OpenSSL 3.0 support has been added. OpenSSL 3.0 support in 2.5 relies
+    on the compatiblity layer and full OpenSSL 3.0 support is coming with
+    OpenVPN 2.6. Only features that impact usage directly have been
+    backported:
+
+    ``--tls-cert-profile insecure``  has been added to allow selecting the
+    lowest  OpenSSL security level (not recommended, use only if you must).
+
+    OpenSSL 3.0 no longer supports the Blowfish (and other deprecated)
+    algorithm by default and the new option ``--providers`` allows loading
+    the legacy provider to renable these algorithms.
+
+
 Bugfixes
 --------
 - CVE-2022-0547
doc/man-sections/generic-options.rst +12 -0
index d5f08839b..18085f9bd 100644
@@ -252,6 +252,18 @@ which mode OpenVPN is configured as.
   This option solves the problem by persisting keys across :code:`SIGUSR1`
   resets, so they don't need to be re-read.
 
+--providers providers
+  Load the list of (OpenSSL) providers. This is mainly useful for using an
+  external provider for key management like tpm2-openssl or to load the
+  legacy provider with
+
+  ::
+
+      --providers legacy default
+
+  Behaviour of changing this option between SIGHUP might not be well behaving.
+  If you need to change/add/remove this option, fully restart OpenVPN.
+
 --remap-usr1 signal
   Control whether internally or externally generated :code:`SIGUSR1` signals
   are remapped to :code:`SIGHUP` (restart without persisting state) or
src/openvpn/crypto_backend.h +15 -0
index b5a122eee..a9bb38ed2 100644
@@ -78,6 +78,21 @@ void crypto_clear_error(void);
  */
 void crypto_init_lib_engine(const char *engine_name);
 
+
+/**
+ * Load the given (OpenSSL) providers
+ * @param provider name of providers to load
+ * @return reference to the loaded provider
+ */
+provider_t *crypto_load_provider(const char *provider);
+
+/**
+ * Unloads the given (OpenSSL) provider
+ * @param provname  name of the provider to unload
+ * @param provider  pointer to the provider to unload
+ */
+void crypto_unload_provider(const char *provname, provider_t *provider);
+
 #ifdef DMALLOC
 /*
  * OpenSSL memory debugging.  If dmalloc debugging is enabled, tell
src/openvpn/crypto_mbedtls.c +13 -0
index 1da99d147..000815209 100644
@@ -69,6 +69,19 @@ crypto_init_lib_engine(const char *engine_name)
         "available");
 }
 
+provider_t *crypto_load_provider(const char *provider)
+{
+    if (provider)
+    {
+        msg(M_WARN, "Note: mbed TLS provider functionality is not available");
+    }
+    return NULL;
+}
+
+void crypto_unload_provider(const char *provname, provider_t *provider)
+{
+}
+
 /*
  *
  * Functions related to the core crypto library
src/openvpn/crypto_mbedtls.h +3 -0
index 816e1397a..14614a12d 100644
@@ -48,6 +48,9 @@ typedef mbedtls_md_context_t md_ctx_t;
 /** Generic HMAC %context. */
 typedef mbedtls_md_context_t hmac_ctx_t;
 
+/* Use a dummy type for the provider */
+typedef void provider_t;
+
 /** Maximum length of an IV */
 #define OPENVPN_MAX_IV_LENGTH   MBEDTLS_MAX_IV_LENGTH
 
src/openvpn/crypto_openssl.c +31 -0
index 0908e9aa1..beeaee4b7 100644
@@ -51,6 +51,10 @@
 #include <openssl/rand.h>
 #include <openssl/ssl.h>
 
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+#include <openssl/provider.h>
+#endif
+
 #if defined(_WIN32) && defined(OPENSSL_NO_EC)
 #error Windows build with OPENSSL_NO_EC: disabling EC key is not supported.
 #endif
@@ -145,6 +149,33 @@ crypto_init_lib_engine(const char *engine_name)
 #endif
 }
 
+provider_t *
+crypto_load_provider(const char *provider)
+{
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+    /* Load providers into the default (NULL) library context */
+    OSSL_PROVIDER *prov = OSSL_PROVIDER_load(NULL, provider);
+    if (!prov)
+    {
+        crypto_msg(M_FATAL, "failed to load provider '%s'", provider);
+    }
+    return prov;
+#else  /* OPENSSL_VERSION_NUMBER >= 0x30000000L */
+    msg(M_WARN, "Note: OpenSSL provider functionality is not available");
+    return NULL;
+#endif
+}
+
+void crypto_unload_provider(const char *provname, provider_t *provider)
+{
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+    if (!OSSL_PROVIDER_unload(provider))
+    {
+        crypto_msg(M_FATAL, "failed to unload provider '%s'", provname);
+    }
+#endif
+}
+
 /*
  *
  * Functions related to the core crypto library
src/openvpn/crypto_openssl.h +11 -0
index ecc66fbfd..9bb58adae 100644
@@ -33,6 +33,10 @@
 #include <openssl/hmac.h>
 #include <openssl/md5.h>
 #include <openssl/sha.h>
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+#include <openssl/provider.h>
+#endif
+
 
 /** Generic cipher key type %context. */
 typedef EVP_CIPHER cipher_kt_t;
@@ -49,6 +53,13 @@ typedef EVP_MD_CTX md_ctx_t;
 /** Generic HMAC %context. */
 typedef HMAC_CTX hmac_ctx_t;
 
+#if OPENSSL_VERSION_NUMBER < 0x30000000L
+/* Use a dummy type for the provider */
+typedef void provider_t;
+#else
+typedef OSSL_PROVIDER provider_t;
+#endif
+
 /** Maximum length of an IV */
 #define OPENVPN_MAX_IV_LENGTH   EVP_MAX_IV_LENGTH
 
src/openvpn/openvpn.c +14 -1
index e03d25450..1cd8f1b30 100644
@@ -112,14 +112,27 @@ void init_early(struct context *c)
     /* init verbosity and mute levels */
     init_verb_mute(c, IVM_LEVEL_1);
 
+    /* Initialise OpenSSL provider, this needs to be initialised this
+    * early since option post-processing and also openssl info
+    * printing depends on it */
+    for (int j=1; j < MAX_PARMS && c->options.providers.names[j]; j++)
+    {
+        c->options.providers.providers[j] =
+            crypto_load_provider(c->options.providers.names[j]);
+    }
 }
 
 static void uninit_early(struct context *c)
 {
     net_ctx_free(&c->net_ctx);
+    for (int j=1; j < MAX_PARMS && c->options.providers.providers[j]; j++)
+    {
+        crypto_unload_provider(c->options.providers.names[j],
+                               c->options.providers.providers[j]);
+    }
+    net_ctx_free(&c->net_ctx);
 }
 
-
 /**************************************************************************/
 /**
  * OpenVPN's main init-run-cleanup loop.
src/openvpn/options.c +8 -0
index e0b273bdd..f6ef02ae8 100644
@@ -602,6 +602,7 @@ static const char usage_message[] =
     "                : Use --show-tls to see a list of supported TLS ciphers (suites).\n"
     "--tls-cert-profile p : Set the allowed certificate crypto algorithm profile\n"
     "                  (default=legacy).\n"
+    "--providers l   : A list l of OpenSSL providers to load.\n"
     "--tls-timeout n : Packet retransmit timeout on TLS control channel\n"
     "                  if no ACK from remote within n seconds (default=%d).\n"
     "--reneg-bytes n : Renegotiate data chan. key after n bytes sent and recvd.\n"
@@ -8129,6 +8130,13 @@ add_option(struct options *options,
         options->keysize = keysize;
     }
 #endif
+    else if (streq(p[0], "providers") && p[1])
+    {
+        for (size_t j = 1; j < MAX_PARMS && p[j] != NULL;j++)
+        {
+            options->providers.names[j] = p[j];
+        }
+    }
 #ifdef ENABLE_PREDICTION_RESISTANCE
     else if (streq(p[0], "use-prediction-resistance") && !p[1])
     {
src/openvpn/options.h +9 -0
index 251660fdc..372209042 100644
@@ -176,6 +176,14 @@ struct remote_list
     struct remote_entry *array[CONNECTION_LIST_SIZE];
 };
 
+struct provider_list
+{
+    /* Names of the providers */
+    const char *names[MAX_PARMS];
+    /* Pointers to the loaded providers to unload them */
+    provider_t *providers[MAX_PARMS];
+};
+
 enum vlan_acceptable_frames
 {
     VLAN_ONLY_TAGGED,
@@ -519,6 +527,7 @@ struct options
     const char *prng_hash;
     int prng_nonce_secret_len;
     const char *engine;
+    struct provider_list providers;
     bool replay;
     bool mute_replay_warnings;
     int replay_window;
Signature · 1 line
2.32.0 (Apple Git-132)
#5 lore raw

PATCH 3/7 Add ubuntu 22.04 to Github Actions

In reply to Arne Schwabe

This adds Ubuntu 22.04 to the Github actions. mbed TLS in 22.04 is still old enough (2.28) to build with OpenVPN and GPL licensed.

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg24299.html

---
 .github/workflows/build.yaml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
.github/workflows/build.yaml +5 -1
index fb53fb8bd..4926c1f95 100644
@@ -130,7 +130,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        os: [ubuntu-18.04, ubuntu-20.04]
+        os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04]
         sslpkg: [libmbedtls-dev]
         ssllib: [mbedtls]
         libname: [mbed TLS]
@@ -148,6 +148,10 @@ jobs:
             sslpkg: "libssl-dev"
             libname: OpenSSL 1.1.1
             ssllib: openssl
+          - os: ubuntu-22.04
+            sslpkg: "libssl-dev"
+            libname: OpenSSL 3.0.2
+            ssllib: openssl
           - os: ubuntu-20.04
             sslpkg: "libssl-dev"
             libname: OpenSSL 1.1.1
Signature · 1 line
2.32.0 (Apple Git-132)
#7 lore raw

PATCH 4/7 Add macos OpenSSL 3.0 and ASAN builds

In reply to Arne Schwabe

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg23018.html

---
 .github/workflows/build.yaml | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)
.github/workflows/build.yaml +25 -3
index 4926c1f95..3bdf2aa9f 100644
@@ -224,15 +224,37 @@ jobs:
 
   macos:
     runs-on: macos-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        ossl: [ 1.1, 3 ]
+        build: [ normal, asan ]
+        include:
+          - build: asan
+            cflags: "-fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"
+            ldflags: -fsanitize=address
+            # Our build system ignores LDFLAGS for plugins
+            configureflags: --disable-plugin-auth-pam  --disable-plugin-down-root
+          - build: normal
+            cflags: "-O2 -g"
+            ldflags: ""
+            configureflags: ""
+
+    name: "macOS - OpenSSL ${{matrix.ossl}} - ${{matrix.build}}"
+    env:
+      CFLAGS: ${{ matrix.cflags }}
+      LDFLAGS: ${{ matrix.ldflags }}
+      OPENSSL_CFLAGS: -I/usr/local/opt/openssl@${{matrix.ossl}}/include
+      OPENSSL_LIBS: "-L/usr/local/opt/openssl@${{matrix.ossl}}/lib -lcrypto -lssl"
     steps:
+      - name: Install dependencies
+        run: brew install [email protected]... [email protected]... lzo lz4 man2html cmocka libtool automake autoconf
       - name: Checkout OpenVPN
         uses: actions/[email protected]...
-      - name: Install dependencies
-        run: brew install openssl lzo lz4 man2html cmocka libtool automake autoconf
       - name: autoconf
         run: autoreconf -fvi
       - name: configure
-        run: OPENSSL_CFLAGS=-I/usr/local/opt/[email protected].../include  OPENSSL_LIBS="-L/usr/local/opt/[email protected].../lib -lcrypto -lssl" ./configure
+        run: ./configure ${{matrix.configureflags}}
       - name: make all
         run: make -j4
       - name: make check
Signature · 1 line
2.32.0 (Apple Git-132)
#9 lore raw

PATCH 5/7 Add --with-openssl-engine autoconf option (auto|yes|no)

In reply to Arne Schwabe

This is a cherry-pick to release2.5 from 0df2261da. The OpenSSL engine tests fail otherwise and it is good to have the same behaviour as in master/2.6

This allows to select engine support at configure time. For OpenSSL 1.1 the default is not changed and we detect if engine support is available.

Engine support is deprecated in OpenSSL 3.0 and for OpenSSL 3.0 the default is to disable engine support as engine support is deprecated and generates compiler warnings which in turn also break -Werror.

By using --with-openssl-engine=no or --with-openssl-engine=yes engine support can be forced on or off. If it is enabled but not detected an error will be thown.

This commit cleans up the configure logic a bit and removes the ENGINE_cleanup checks as we can just assume that it will be also available as macro or function if the other engine functions are available. Before the cleanup we would only check for the existance of engine.h if ENGINE_cleanup was not found.

---
 Changes.rst  |  3 +++
 configure.ac | 60 ++++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 50 insertions(+), 13 deletions(-)
Changes.rst +3 -0
index 884c122a9..d15ffbb87 100644
@@ -27,6 +27,9 @@ New features
     algorithm by default and the new option ``--providers`` allows loading
     the legacy provider to renable these algorithms.
 
+    The OpenSSL engine feature ``--engine`` is not enabled by default
+    anymore if OpenSSL 3.0 is detected.
+
 
 Bugfixes
 --------
configure.ac +47 -13

75 lines not on this page · raw message

Signature · 1 line
2.32.0 (Apple Git-132)
#11 lore raw

PATCH 6/7 Fix allowing/showing unsupported ciphers and digests

In reply to Arne Schwabe

This is a minimal version to hide the non-supported ciphers in these show-cipher/show-digests listings. It also adds code to the kt_md_get/ kt_cipher_get functions to error out early instead of getting an ugly backtrace with OpenSSL errors later when actually trying to use the ciphers.

This allows make check to work again on with OpenSSL 3.0.

The changes are kept minimal to avoid pulling in all the other refactoring for OpenSSL 3.0.

This commit is partly cherry-picked from ab3f32b9.

---
 src/openvpn/crypto_openssl.c | 50 +++++++++++++++++++++++++++++++++---
 1 file changed, 47 insertions(+), 3 deletions(-)
src/openvpn/crypto_openssl.c +47 -3
index beeaee4b7..ad6c9353a 100644
@@ -339,7 +339,11 @@ show_available_ciphers(void)
                        || cipher_kt_mode_aead(cipher)
                        ))
         {
-            cipher_list[num_ciphers++] = cipher;
+            /* Check explicit availibility (for OpenSSL 3.0) */
+            if (cipher_kt_get(cipher_kt_name(cipher)))
+            {
+                cipher_list[num_ciphers++] = cipher;
+            }
         }
         if (num_ciphers == (sizeof(cipher_list)/sizeof(*cipher_list)))
         {
@@ -371,6 +375,13 @@ show_available_ciphers(void)
     printf("\n");
 }
 
+void
+print_digest(EVP_MD *digest, void *unused)
+{
+    printf("%s %d bit digest size\n", EVP_MD_name(digest),
+           EVP_MD_size(digest) * 8);
+}
+
 void
 show_available_digests(void)
 {
@@ -384,16 +395,22 @@ show_available_digests(void)
            "the --auth option.\n\n");
 #endif
 
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+    EVP_MD_do_all_provided(NULL, print_digest, NULL);
+#else
     for (nid = 0; nid < 10000; ++nid)
     {
+
         const EVP_MD *digest = EVP_get_digestbynid(nid);
         if (digest)
         {
-            printf("%s %d bit digest size\n",
-                   OBJ_nid2sn(nid), EVP_MD_size(digest) * 8);
+            /* We cast the const away so we can keep the function prototype
+             * compatible with EVP_MD_do_all_provided */
+            print_digest((EVP_MD *)digest, NULL);
         }
     }
     printf("\n");
+#endif
 }
 
 void
@@ -624,6 +641,19 @@ cipher_kt_get(const char *ciphername)
     ciphername = translate_cipher_name_from_openvpn(ciphername);
     cipher = EVP_get_cipherbyname(ciphername);
 
+    /* This is a workaround for OpenSSL 3.0 to infer if the cipher is valid
+     * without doing all the refactoring that OpenVPN 2.6 has. This will
+     * not support custom algorithm from providers but at least ignore
+     * algorithms that are not available without providers (legacy) */
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+    EVP_CIPHER *tmpcipher = EVP_CIPHER_fetch(NULL, ciphername, NULL);
+    if (!tmpcipher)
+    {
+        cipher = NULL;
+    }
+    EVP_CIPHER_free(tmpcipher);
+#endif
+
     if (NULL == cipher)
     {
         crypto_msg(D_LOW, "Cipher algorithm '%s' not found", ciphername);
@@ -924,6 +954,20 @@ md_kt_get(const char *digest)
     const EVP_MD *md = NULL;
     ASSERT(digest);
     md = EVP_get_digestbyname(digest);
+
+    /* This is a workaround for OpenSSL 3.0 to infer if the digest is valid
+     * without doing all the refactoring that OpenVPN 2.6 has. This will
+     * not support custom algorithm from providers but at least ignore
+     * algorithms that are not available without providers (legacy) */
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+    EVP_MD *tmpmd = EVP_MD_fetch(NULL, digest, NULL);
+    if (!tmpmd)
+    {
+        md = NULL;
+    }
+    EVP_MD_free(tmpmd);
+#endif
+
     if (!md)
     {
         crypto_msg(M_FATAL, "Message hash algorithm '%s' not found", digest);
Signature · 1 line
2.32.0 (Apple Git-132)
#13 lore raw

PATCH 7/7 Remove dependency on BF-CBC existance from test_ncp

In reply to Arne Schwabe

The test_check_ncp_ciphers_list test assumed that BF-CBC is always available, which is no longer the case with OpenSSL 3.0. Rewrite the test to not rely on BF-CBC to be available.

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg23003.html

---
 tests/unit_tests/openvpn/test_ncp.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tests/unit_tests/openvpn/test_ncp.c +8 -2
index e38a5738e..d4164ef7a 100644
@@ -42,6 +42,7 @@
 /* Defines for use in the tests and the mock parse_line() */
 
 const char *bf_chacha = "BF-CBC:CHACHA20-POLY1305";
+const char *aes_chacha = "AES-128-CBC:CHACHA20-POLY1305";
 const char *aes_ciphers = "AES-256-GCM:AES-128-GCM";
 
 static void
@@ -57,6 +58,11 @@ test_check_ncp_ciphers_list(void **state)
 
     assert_string_equal(mutate_ncp_cipher_list(aes_ciphers, &gc), aes_ciphers);
 
+    if (have_chacha && have_blowfish)
+    {
+        assert_string_equal(mutate_ncp_cipher_list(aes_chacha, &gc), aes_chacha);
+    }
+
     if (have_chacha && have_blowfish)
     {
         assert_string_equal(mutate_ncp_cipher_list(bf_chacha, &gc), bf_chacha);
@@ -73,8 +79,8 @@ test_check_ncp_ciphers_list(void **state)
     bool have_chacha_mixed_case = cipher_kt_get("ChaCha20-Poly1305");
     if (have_chacha_mixed_case)
     {
-        assert_string_equal(mutate_ncp_cipher_list("BF-CBC:ChaCha20-Poly1305", &gc),
-                            bf_chacha);
+        assert_string_equal(mutate_ncp_cipher_list("AES-128-CBC:ChaCha20-Poly1305", &gc),
+                            aes_chacha);
     }
 
     assert_ptr_equal(mutate_ncp_cipher_list("vollbit", &gc), NULL);
Signature · 1 line
2.32.0 (Apple Git-132)
#14 lore raw

Re: [Openvpn-devel] [PATCH 7/7] Remove dependency on BF-CBC existance from test_ncp

Hi,

Quoted 3 lines · Arne Schwabe

The test_check_ncp_ciphers_list test assumed that BF-CBC is always available, which is no longer the case with OpenSSL 3.0. Rewrite the test to not rely on BF-CBC to be available.

This should be a cherry-pick from c07f95f3cacd, but "something went wrong"

tests/unit_tests/openvpn/test_ncp.c test_check_ncp_ciphers_list(void **state) · line 64

Quoted 9 lines

static void

tests/unit_tests/openvpn/test_ncp.c +4 -0
@@ -57,6 +58,11 @@ test_check_ncp_ciphers_list(void **state)
 
     assert_string_equal(mutate_ncp_cipher_list(aes_ciphers, &gc), aes_ciphers);
 
+    if (have_chacha && have_blowfish)
+    {
+        assert_string_equal(mutate_ncp_cipher_list(aes_chacha, &gc), aes_chacha);
+    }

In c07f95f3cacd, the first if() is only "if (have_chacha)", and that seems to make more sense since that test does not depend on BF...

tests/unit_tests/openvpn/test_ncp.c test_check_ncp_ciphers_list(void **state) · line 67

Quoted 3 lines
tests/unit_tests/openvpn/test_ncp.c +1 -0
+
     if (have_chacha && have_blowfish)
     {

... only this one does...

can I have a 7/7 v2, please? :-)

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
Acked-by on v1 1/7
#2 lore raw

[Openvpn-devel] [PATCH applied] Re: Refactor early initialisation and uninitialisation into methods

In reply to Arne Schwabe

Trivial. Usually we wouldn't do refactoring in 2.5, but we decided we want (must have, *sigh*) better OpenSSL support because Linux distributions have started shipping "openvpn 2.5.x with openssl 3.0.x", and that is not a good experience without this patchset.

"make check" tested on FreeBSD with 3.0.x - fails in the expected places (engine test, no BF-CBC, no support for MD5/SHA1 certs)

Testing cipher BF-CBC... FAILED
Testing cipher DES-OFB... FAILED

Your patch has been applied to the release/2.5 branch.

commit 3f25bf7f7c1f32c2d3ef5b52443c97553a6c8977

Author: Arne Schwabe
Date:   Thu May 12 14:14:23 2022 +0200
     Refactor early initialisation and uninitialisation into methods

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg24328.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

Acked-by on v1 2/7
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Allow loading of non default providers

In reply to Arne Schwabe

This makes client tests using old certs (SHA1) or ciphers (BF-CBC) succeed again, provided "--providers legacy default" and "tls-cert-profile insecure" is added - where appropriate.

"make check" still fails (with 3.0.x), as "openvpn --show-ciphers" still shows everything, no matter if loaded or not. This is addressed in 6/7.

Moved the "Changes.rst" addition to "changes in 2.5.7" :-)

Your patch has been applied to the release/2.5 branch.

commit aef0e595132bd75b0a089e0536c7f910667f1c07

Author: Arne Schwabe
Date:   Thu May 12 14:14:24 2022 +0200
     Allow loading of non default providers

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg24327.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

Acked-by on v1 3/7
#6 lore raw

[Openvpn-devel] [PATCH applied] Re: Add ubuntu 22.04 to Github Actions

In reply to Arne Schwabe

Same patch as in master. No code changes, just adding github tests.

Your patch has been applied to the release/2.5 branch.

commit 0fb03c8c2333805eff9eda3cc10b2c82e617bee5

Author: Arne Schwabe
Date:   Thu May 12 14:14:25 2022 +0200
     Add ubuntu 22.04 to Github Actions

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg24329.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

Acked-by on v1 4/7
#8 lore raw

[Openvpn-devel] [PATCH applied] Re: Add macos OpenSSL 3.0 and ASAN builds

In reply to Arne Schwabe

Same patch as in master. No code changes, just adding github tests.

Your patch has been applied to the release/2.5 branch.

commit dea694099ff223feb63199bd0ca7afd74504711d

Author: Arne Schwabe
Date:   Thu May 12 14:14:26 2022 +0200
     Add macos OpenSSL 3.0 and ASAN builds

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg24330.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

Acked-by on v1 5/7
#10 lore raw

[Openvpn-devel] [PATCH applied] Re: Add --with-openssl-engine autoconf option (auto|yes|no)

In reply to Arne Schwabe

This repairs the first part of "make check" for ossl 3.0 builds (... by skipping the failing engine test). The cipher loopback still fails.

Moved the Changes.rst hunk to the 2.5.7 section I introduced with 2/7 :-)

Your patch has been applied to the release/2.5 branch.

commit c5d61b345e21860b2357206848535a8452754ad8

Author: Arne Schwabe
Date:   Thu May 12 14:14:27 2022 +0200
     Add --with-openssl-engine autoconf option (auto|yes|no)

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg24332.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

Acked-by on v1 6/7
#12 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix allowing/showing unsupported ciphers and digests

In reply to Arne Schwabe

Code is close enough to the master version, and it nicely does what it says ("openvpn --providers legacy --show-ciphers" vs. "--show-ciphers").

While this fixes the "cipher loopback test", it now breaks tls_crypt_testdriver, as that one expects BF-CBC to be universally available...

Unsupported cipher in --data-ciphers: BF-CBC
Unsupported cipher in --data-ciphers: BF-CBC
[ ERROR ] --- Test failed with exception: Segmentation fault(11)

.. to be fixed in 7/7.

(Breakage only in 3.0.x builds, of course, 1.1.x builds are fine)

Fixed one spurious newline, and another uncrustify complaint introduced by crypto_unload_provider().

Your patch has been applied to the release/2.5 branch.

commit 3690939126cf84b166157bad96e724caea61346d

Author: Arne Schwabe
Date:   Thu May 12 14:14:28 2022 +0200
     Fix allowing/showing unsupported ciphers and digests

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg24334.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#15 lore raw

PATCH v2 7/7 Remove dependency on BF-CBC existance from test_ncp

In reply to Arne Schwabe

The test_check_ncp_ciphers_list test assumed that BF-CBC is always available, which is no longer the case with OpenSSL 3.0. Rewrite the test to not rely on BF-CBC to be available.

This is a cherry-pick from c07f95f3

Patch V2: manually fix if condition. Somehow the git cherry-pick ended up
with a broken if condition.

---
 tests/unit_tests/openvpn/test_ncp.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tests/unit_tests/openvpn/test_ncp.c +8 -2
index e38a5738e..4337f6df7 100644
@@ -42,6 +42,7 @@
 /* Defines for use in the tests and the mock parse_line() */
 
 const char *bf_chacha = "BF-CBC:CHACHA20-POLY1305";
+const char *aes_chacha = "AES-128-CBC:CHACHA20-POLY1305";
 const char *aes_ciphers = "AES-256-GCM:AES-128-GCM";
 
 static void
@@ -57,6 +58,11 @@ test_check_ncp_ciphers_list(void **state)
 
     assert_string_equal(mutate_ncp_cipher_list(aes_ciphers, &gc), aes_ciphers);
 
+    if (have_chacha)
+    {
+        assert_string_equal(mutate_ncp_cipher_list(aes_chacha, &gc), aes_chacha);
+    }
+
     if (have_chacha && have_blowfish)
     {
         assert_string_equal(mutate_ncp_cipher_list(bf_chacha, &gc), bf_chacha);
@@ -73,8 +79,8 @@ test_check_ncp_ciphers_list(void **state)
     bool have_chacha_mixed_case = cipher_kt_get("ChaCha20-Poly1305");
     if (have_chacha_mixed_case)
     {
-        assert_string_equal(mutate_ncp_cipher_list("BF-CBC:ChaCha20-Poly1305", &gc),
-                            bf_chacha);
+        assert_string_equal(mutate_ncp_cipher_list("AES-128-CBC:ChaCha20-Poly1305", &gc),
+                            aes_chacha);
     }
 
     assert_ptr_equal(mutate_ncp_cipher_list("vollbit", &gc), NULL);
Signature · 1 line
2.32.0 (Apple Git-132)
Acked-by on v2 7/7
#16 lore raw

[Openvpn-devel] [PATCH applied] Re: Remove dependency on BF-CBC existance from test_ncp

Funny how "git cherry-pick" can sometimes do correct-looking-but-different stuff... now the code matches what is in the master commit.

Plus, it passes "make check" with 3.0.x builds :-)

Your patch has been applied to the release/2.5 branch.

commit 263436fdb06cc2364f9667bc1adead70aeb93ecc

Author: Arne Schwabe
Date:   Fri May 13 10:36:35 2022 +0200
     Remove dependency on BF-CBC existance from test_ncp

     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg24346.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering