Skip to contentSkip to conversation

Allow running a default configuration with TLS libraries without BF-CBC

PATCH In review Arne Schwabe 3 participants 3 messages Jun 3, 2022 – Jun 15, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow running a default configuration with TLS libraries without BF-CBC

Modern TLS libraries might drop Blowfish by default or distributions might disable Blowfish in OpenSSL/mbed TLS. We still signal OCC options with BF-CBC compatible strings. To avoid requiring BF-CBC for this, special this one usage of BF-CBC enough to avoid a hard requirement on Blowfish in the default configuration.

This patch is cherry-picked from 79ff3f79 and the missing ciphername = "none"; has been added in the OCC code.

---
 src/openvpn/crypto_backend.h |  2 ++
 src/openvpn/init.c           | 37 +++++++++++++++++++++------
 src/openvpn/options.c        | 48 +++++++++++++++++++++++++++++++-----
 3 files changed, 73 insertions(+), 14 deletions(-)
src/openvpn/crypto_backend.h +2 -0
index a9bb38ed2..aebda3d65 100644
@@ -256,6 +256,8 @@ const cipher_kt_t *cipher_kt_get(const char *ciphername);
  * The returned name is normalised to the OpenVPN config name in case the
  * name differs from the name used by the crypto library.
  *
+ * Returns [null-cipher] in case the cipher_kt is NULL.
+ *
  * @param cipher_kt     Static cipher parameters
  *
  * @return a statically allocated string describing the cipher.
src/openvpn/init.c +29 -8
index da4d60afa..f1550e620 100644
@@ -2764,14 +2764,35 @@ do_init_crypto_tls_c1(struct context *c)
 #endif /* if P2MP */
         }
 
-        /* Do not warn if we only have BF-CBC in options->ciphername
-         * because it is still the default cipher */
-        bool warn = !streq(options->ciphername, "BF-CBC")
-             || options->enable_ncp_fallback;
-        /* Get cipher & hash algorithms */
-        init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname,
-                      options->keysize, true, warn);
-
+       /*
+        * BF-CBC is allowed to be used only when explicitly configured
+        * as NCP-fallback or when NCP has been disabled or explicitly
+        * allowed in the in ncp_ciphers list.
+        * In all other cases do not attempt to initialize BF-CBC as it
+        * may not even be supported by the underlying SSL library.
+        *
+        * Therefore, the key structure has to be initialized when:
+        * - any non-BF-CBC cipher was selected; or
+        * - BF-CBC is selected and NCP is disabled (explicit request to
+        *   use the BF-CBC cipher); or
+        * - BF-CBC is selected, NCP is enabled and fallback is enabled
+        *   (BF-CBC will be the fallback).
+        * - BF-CBC is in data-ciphers and we negotiate to use BF-CBC:
+        *   If the negotiated cipher and options->ciphername are the
+        *   same we do not reinit the cipher
+        *
+        * Note that BF-CBC will still be part of the OCC string to retain
+        * backwards compatibility with older clients.
+        */
+        if (!streq(options->ciphername, "BF-CBC") || !options->ncp_enabled
+            || (options->ncp_enabled && tls_item_in_cipher_list("BF-CBC", options->ncp_ciphers))
+            || options->enable_ncp_fallback)
+        {
+            /* Do not warn if the if the cipher is used only in OCC */
+            bool warn = !options->ncp_enabled || options->enable_ncp_fallback;
+            init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname,
+                          options->keysize, true, warn);
+        }
         /* Initialize PRNG with config-specified digest */
         prng_init(options->prng_hash, options->prng_nonce_secret_len);
 
src/openvpn/options.c +42 -6

69 lines not on this page · raw message

Signature · 1 line
2.32.0 (Apple Git-132)
Acked-by on v1 1/1
#1 lore raw

Stared at code, and tested with a 2.5+ossl3.0.x build - without the patch, it would fail before even trying to connect to the server (unless --providers legacy default is set):

2022-06-09 12:00:50 library versions: OpenSSL 3.0.3 3 May 2022, LZO 2.10
2022-06-09 12:00:50 Cipher BF-CBC not supported
2022-06-09 12:00:50 Exiting due to fatal error

With the patch, it connects fine, negotiates AES-256-GCM, and passes all t_client tests (to "master" servers") without having to resort to "--providers legacy".

Connecting to a legacy server (2.3 or 2.4/2.5 with --disable-ncp, or restricting ciphers to BF-CBC for whatever other reasons) will try to fallback to BF-CBC, and fail - unsurprisingly, but fixable with --providers legacy.

NOTE: uncrustify complained to me that "options.c" got modified and was not uncrustify clean before -> so I included these whitespace changes (not many, and only trivial stuff) in this commit.

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

commit 15bf49797130917d85837abd3e8c1fb0e9b528b7

Author: Arne Schwabe
Date:   Fri Jun 3 11:52:19 2022 +0200
     Allow running a default configuration with TLS libraries without BF-CBC

     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]/msg24456.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#2 lore raw
In reply to Arne Schwabe
Quoted 9 lines · Arne Schwabe

Modern TLS libraries might drop Blowfish by default or distributions might disable Blowfish in OpenSSL/mbed TLS. We still signal OCC options with BF-CBC compatible strings. To avoid requiring BF-CBC for this, special this one usage of BF-CBC enough to avoid a hard requirement on Blowfish in the default configuration.

This patch is cherry-picked from 79ff3f79 and the missing ciphername = "none"; has been added in the OCC code.

Quoted 6 lines
---
  src/openvpn/crypto_backend.h |  2 ++
  src/openvpn/init.c           | 37 +++++++++++++++++++++------
  src/openvpn/options.c        | 48 +++++++++++++++++++++++++++++++-----
  3 files changed, 73 insertions(+), 14 deletions(-)

Just for the record. This patch has been included into Fedora 36 and EPEL-9 builds, released as openvpn-2.5.7-2.

Fedora 36 users has reported that this patch resolves issues which surfaced when upgrading to openvpn-2.5.7-1.

A few references:

<https://bodhi.fedoraproject.org/updates/FEDORA-2022-8ca0f56650>
<https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2022-dd161a4d75>
<https://bugzilla.redhat.com/show_bug.cgi?id=2092800>
<https://bugzilla.redhat.com/show_bug.cgi?id=2093069>

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc