Skip to contentSkip to conversation

Deprecate non TLS mode in OpenVPN

PATCH Superseded Arne Schwabe 5 participants 23 messages Mar 25, 2021 – Apr 3, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Deprecate non TLS mode in OpenVPN

The non-TLS mode is a relict from OpenVPN 1.x or 2.0. When tls mode was introduce the advantages of TLS over non-tls were small but tls mode evolved to include a lot more features. (NCP, multipeer, AEAD ciphers to name a few).

Today VPN that use --secret are mainly used because of its relative easy to setup and requiring to setup a PKI. This shortcoming of TLS mode should be addressed now with the peer-fingerprint option.

---
 doc/man-sections/protocol-options.rst |  2 +-
 src/openvpn/options.c                 | 12 +++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
doc/man-sections/protocol-options.rst +1 -1
index 01789e58..4b6928c6 100644
@@ -235,7 +235,7 @@ configured in a compatible way between both the local and remote side.
   disables cipher negotiation.
 
 --secret args
-  Enable Static Key encryption mode (non-TLS). Use pre-shared secret
+  **DEPRECATED** Enable Static Key encryption mode (non-TLS). Use pre-shared secret
   ``file`` which was generated with ``--genkey``.
 
   Valid syntaxes:
src/openvpn/options.c +11 -1
index e52679f0..5b559edf 100644
@@ -514,7 +514,7 @@ static const char usage_message[] =
     "\n"
     "Data Channel Encryption Options (must be compatible between peers):\n"
     "(These options are meaningful for both Static Key & TLS-mode)\n"
-    "--secret f [d]  : Enable Static Key encryption mode (non-TLS).\n"
+    "--secret f [d]  : (DEPRECATED) Enable Static Key encryption mode (non-TLS).\n"
     "                  Use shared secret file f, generate with --genkey.\n"
     "                  The optional d parameter controls key directionality.\n"
     "                  If d is specified, use separate keys for each\n"
@@ -2564,6 +2564,15 @@ options_postprocess_verify_ce(const struct options *options,
         msg(M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
     }
 
+    if (!options->tls_server || !options->tls_client)
+    {
+        msg(M_INFO, "DEPRECATION: No tls-client or tls-server option in "
+                    "configuration detected. OpenVPN 2.7 will remove the "
+                    "functionality to run a VPN without TLS. "
+                    "See the examples section in the manual page for "
+                    "examples of a similar quick setup with peer-fingerprint.");
+    }
+
     if (options->ssl_flags & (SSLF_CLIENT_CERT_NOT_REQUIRED|SSLF_CLIENT_CERT_OPTIONAL))
     {
         msg(M_WARN, "WARNING: POTENTIALLY DANGEROUS OPTION "
@@ -7868,6 +7877,7 @@ add_option(struct options *options,
     }
     else if (streq(p[0], "secret") && p[1] && !p[3])
     {
+        msg(M_WARN, "DEPRECATED OPTION: The option --secret is deprecated. ");
         VERIFY_PERMISSION(OPT_P_GENERAL|OPT_P_INLINE);
         options->shared_secret_file = p[1];
         options->shared_secret_file_inline = is_inline;
Signature · 1 line
2.30.1
#1 lore raw

PATCH 2/2 Remove deprecated option '--keysize'

This option has been deprecated in OpenVPN 2.4 and the ciphers that allow using this option fall all into the SWEET32 category of ciphers with 64 bit block size.

---
 config-msvc.h                |  1 -
 configure.ac                 |  2 +-
 src/openvpn/crypto.c         |  6 +-----
 src/openvpn/crypto.h         |  4 +---
 src/openvpn/crypto_openssl.c |  4 ++--
 src/openvpn/init.c           |  5 ++---
 src/openvpn/options.c        | 33 ++-------------------------------
 src/openvpn/options.h        |  2 --
 src/openvpn/ssl.c            |  7 +------
 9 files changed, 10 insertions(+), 54 deletions(-)
config-msvc.h +0 -1
index e430ca96..d0aa4438 100644
@@ -49,7 +49,6 @@
 #define HAVE_CHSIZE 1
 #define HAVE_CPP_VARARG_MACRO_ISO 1
 #define HAVE_CTIME 1
-#define HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH 1
 #define HAVE_IN_PKTINFO 1
 #define HAVE_MEMSET 1
 #define HAVE_PUTENV 1
configure.ac +1 -1
index 428bebed..bd592b3f 100644
@@ -881,7 +881,7 @@ if test "${with_crypto_library}" = "openssl"; then
 		)
 	fi
 
-	AC_CHECK_FUNCS([SSL_CTX_new EVP_CIPHER_CTX_set_key_length],
+	AC_CHECK_FUNCS([SSL_CTX_new],
 				   ,
 				   [AC_MSG_ERROR([openssl check failed])]
 	)
src/openvpn/crypto.c +1 -5
index 3a0bfbec..b042514b 100644
@@ -739,7 +739,7 @@ warn_insecure_key_type(const char *ciphername, const cipher_kt_t *cipher)
  */
 void
 init_key_type(struct key_type *kt, const char *ciphername,
-              const char *authname, int keysize, bool tls_mode, bool warn)
+              const char *authname, bool tls_mode, bool warn)
 {
     bool aead_cipher = false;
 
@@ -756,10 +756,6 @@ init_key_type(struct key_type *kt, const char *ciphername,
         }
 
         kt->cipher_length = cipher_kt_key_size(kt->cipher);
-        if (keysize > 0 && keysize <= MAX_CIPHER_KEY_LENGTH)
-        {
-            kt->cipher_length = keysize;
-        }
 
         /* check legal cipher mode */
         aead_cipher = cipher_kt_mode_aead(kt->cipher);
src/openvpn/crypto.h +1 -3
index 1ad669ce..b8128c7f 100644
@@ -301,14 +301,12 @@ int read_key(struct key *key, const struct key_type *kt, struct buffer *buf);
  * @param kt          The struct key_type to initialize
  * @param ciphername  The name of the cipher to use
  * @param authname    The name of the HMAC digest to use
- * @param keysize     The length of the cipher key to use, in bytes.  Only valid
- *                    for ciphers that support variable length keys.
  * @param tls_mode    Specifies whether we are running in TLS mode, which allows
  *                    more ciphers than static key mode.
  * @param warn        Print warnings when null cipher / auth is used.
  */
 void init_key_type(struct key_type *kt, const char *ciphername,
-                   const char *authname, int keysize, bool tls_mode, bool warn);
+                   const char *authname, bool tls_mode, bool warn);
 
 /*
  * Key context functions
src/openvpn/crypto_openssl.c +2 -2
index 573beaed..34decbb0 100644
@@ -776,12 +776,12 @@ cipher_ctx_init(EVP_CIPHER_CTX *ctx, const uint8_t *key, int key_len,
     {
         crypto_msg(M_FATAL, "EVP cipher init #1");
     }
-#ifdef HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH
+    /* This serves as a check that the keylen is the correct as this fails
+     * when key_len and the fixed size of cipher disagree */
     if (!EVP_CIPHER_CTX_set_key_length(ctx, key_len))
     {
         crypto_msg(M_FATAL, "EVP set key size");
     }
-#endif
     if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, enc))
     {
         crypto_msg(M_FATAL, "EVP cipher init #2");
src/openvpn/init.c +2 -3
index 132d47e4..336da941 100644
@@ -2599,7 +2599,7 @@ do_init_crypto_static(struct context *c, const unsigned int flags)
     {
         /* Get cipher & hash algorithms */
         init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname,
-                      options->keysize, options->test_crypto, true);
+                      options->test_crypto, true);
 
         /* Read cipher and hmac keys from shared secret file */
         crypto_read_openvpn_key(&c->c1.ks.key_type, &c->c1.ks.static_key,
@@ -2751,7 +2751,7 @@ do_init_crypto_tls_c1(struct context *c)
              || options->enable_ncp_fallback;
         /* Get cipher & hash algorithms */
         init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname,
-                      options->keysize, true, warn);
+                      true, warn);
 
         /* Initialize PRNG with config-specified digest */
         prng_init(options->prng_hash, options->prng_nonce_secret_len);
@@ -4515,7 +4515,6 @@ inherit_context_child(struct context *dest,
     /* inherit pre-NCP ciphers */
     dest->options.ciphername = src->options.ciphername;
     dest->options.authname = src->options.authname;
-    dest->options.keysize = src->options.keysize;
 
     /* inherit auth-token */
     dest->c1.ks.auth_token_key = src->c1.ks.auth_token_key;
src/openvpn/options.c +2 -31
index 5b559edf..7948f4a5 100644
@@ -531,10 +531,6 @@ static const char usage_message[] =
     "--ncp-disable   : (DEPRECATED) Disable cipher negotiation.\n"
     "--prng alg [nsl] : For PRNG, use digest algorithm alg, and\n"
     "                   nonce_secret_len=nsl.  Set alg=none to disable PRNG.\n"
-#ifdef HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH
-    "--keysize n     : (DEPRECATED) Size of cipher key in bits (optional).\n"
-    "                  If unspecified, defaults to cipher-specific default.\n"
-#endif
 #ifndef ENABLE_CRYPTO_MBEDTLS
     "--engine [name] : Enable OpenSSL hardware crypto engine functionality.\n"
 #endif
@@ -1733,7 +1729,6 @@ show_settings(const struct options *o)
     SHOW_STR(authname);
     SHOW_STR(prng_hash);
     SHOW_INT(prng_nonce_secret_len);
-    SHOW_INT(keysize);
 #ifndef ENABLE_CRYPTO_MBEDTLS
     SHOW_BOOL(engine);
 #endif /* ENABLE_CRYPTO_MBEDTLS */
@@ -2540,11 +2535,6 @@ options_postprocess_verify_ce(const struct options *options,
         }
     }
 
-    if (options->keysize)
-    {
-        msg(M_WARN, "WARNING: --keysize is DEPRECATED and will be removed in OpenVPN 2.6");
-    }
-
     /*
      * Check consistency of replay options
      */
@@ -3619,7 +3609,6 @@ pre_pull_save(struct options *o)
         /* NCP related options that can be overwritten by a push */
         o->pre_pull->ciphername = o->ciphername;
         o->pre_pull->authname = o->authname;
-        o->pre_pull->keysize = o->keysize;
 
         /* Ping related options should be reset to the config values on reconnect */
         o->pre_pull->ping_rec_timeout = o->ping_rec_timeout;
@@ -3675,7 +3664,6 @@ pre_pull_restore(struct options *o, struct gc_arena *gc)
 
         o->ciphername = pp->ciphername;
         o->authname = pp->authname;
-        o->keysize = pp->keysize;
 
         o->ping_rec_timeout = pp->ping_rec_timeout;
         o->ping_rec_timeout_action = pp->ping_rec_timeout_action;
@@ -3704,8 +3692,7 @@ calc_options_string_link_mtu(const struct options *o, const struct frame *frame)
     {
         struct frame fake_frame = *frame;
         struct key_type fake_kt;
-        init_key_type(&fake_kt, o->ciphername, o->authname, o->keysize, true,
-                      false);
+        init_key_type(&fake_kt, o->ciphername, o->authname, true, false);
         frame_remove_from_extra_frame(&fake_frame, crypto_max_overhead());
         crypto_adjust_frame_parameters(&fake_frame, &fake_kt, o->replay,
                                        cipher_kt_mode_ofb_cfb(fake_kt.cipher));
@@ -3876,8 +3863,7 @@ options_string(const struct options *o,
                + (TLS_SERVER == true)
                <= 1);
 
-        init_key_type(&kt, o->ciphername, o->authname, o->keysize, true,
-                      false);
+        init_key_type(&kt, o->ciphername, o->authname, true, false);
         /* Only announce the cipher to our peer if we are willing to
          * support it */
         const char *ciphername = cipher_kt_name(kt.cipher);
@@ -8087,21 +8073,6 @@ add_option(struct options *options,
         }
     }
 #endif /* ENABLE_CRYPTO_MBEDTLS */
-#ifdef HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH
-    else if (streq(p[0], "keysize") && p[1] && !p[2])
-    {
-        int keysize;
-
-        VERIFY_PERMISSION(OPT_P_NCP);
-        keysize = atoi(p[1]) / 8;
-        if (keysize < 0 || keysize > MAX_CIPHER_KEY_LENGTH)
-        {
-            msg(msglevel, "Bad keysize: %s", p[1]);
-            goto err;
-        }
-        options->keysize = keysize;
-    }
-#endif
 #ifdef ENABLE_PREDICTION_RESISTANCE
     else if (streq(p[0], "use-prediction-resistance") && !p[1])
     {
src/openvpn/options.h +0 -2
index d8e91fbc..5e924e1b 100644
@@ -77,7 +77,6 @@ struct options_pre_pull
 
     const char* ciphername;
     const char* authname;
-    int keysize;
 
     int ping_send_timeout;
     int ping_rec_timeout;
@@ -521,7 +520,6 @@ struct options
     bool ncp_enabled;
     const char *ncp_ciphers;
     const char *authname;
-    int keysize;
     const char *prng_hash;
     int prng_nonce_secret_len;
     const char *engine;
src/openvpn/ssl.c +1 -6
index 0daf19ad..d288d207 100644
@@ -1874,11 +1874,6 @@ tls_session_update_crypto_params(struct tls_session *session,
     {
         msg(D_HANDSHAKE, "Data Channel: using negotiated cipher '%s'",
             options->ciphername);
-        if (options->keysize)
-        {
-            msg(D_HANDSHAKE, "NCP: overriding user-set keysize with default");
-            options->keysize = 0;
-        }
     }
     else
     {
@@ -1889,7 +1884,7 @@ tls_session_update_crypto_params(struct tls_session *session,
     }
 
     init_key_type(&session->opt->key_type, options->ciphername,
-                  options->authname, options->keysize, true, true);
+                  options->authname, true, true);
 
     bool packet_id_long_form = cipher_kt_mode_ofb_cfb(session->opt->key_type.cipher);
     session->opt->crypto_flags &= ~(CO_PACKET_ID_LONG_FORM);
Signature · 1 line
2.30.1
#12 lore raw

Hi,

Quoted 2 lines · tincanteksup

I made this change to the wiki:
https://community.openvpn.net/openvpn/wiki/DeprecatedOptions?action=diff&version=45

I had this discussion with "Pippin_" in #openvpn-meeting:

The change you made is wrong. That part of the wikipage talks about moving the --genkey argument "secret" from being a standalone "--secret" to "--gen key secret".

It is unrelated to the "non-TLS mode --secret" that Arne is talking about in this PATCH.

That change (that was *Actually* made in 2.4) was exactly to remove this ambiguity.

Since 2.4, you specifu the "secret" argument of "--genkey" by using the "secret" subargument instead of passing the ambiguous "--secret".

For this reason I believe that this change on the wiki should be reverted.

Regards,

Signature · 1 line
Antonio Quartulli
#13 lore raw

Hi,

Quoted 2 lines · Antonio Quartulli

That change (that was *Actually* made in 2.4) was exactly to remove this ambiguity.

Forgive my hasty reply. This combination of option is actually not-supported since 2.5 (in 2.4 we probably only introduced the deprecation warning).

Regards,

Signature · 1 line
Antonio Quartulli
#14 lore raw

Hi,

Quoted 9 lines · Antonio Quartulli

Hi,

Quoted 2 lines · Antonio Quartulli

That change (that was *Actually* made in 2.4) was exactly to remove this ambiguity.

Forgive my hasty reply. This combination of option is actually not-supported since 2.5 (in 2.4 we probably only introduced the deprecation warning).

I think I know what you mean.

Deprecating --secret to be --genkey secret is on the wiki. But the change *has* been made in 2.5 not pending for 2.7

Deprecating non-TLS mode VPNs is not on the wiki.

Deprecate non-TLS mode in 2.5
To be removed in 2.7
Replaced by peer-fingerprint option.

If that is correct then I can add "non-TLS mode" to the wiki. Clear up the mess^D^D^D^D ambiguity ..

How does that sound ?
R

#15 lore raw

Hi,

Quoted 9 lines · tincanteksup

Hi,

Quoted 6 lines · Antonio Quartulli

Hi,

Quoted 2 lines · Antonio Quartulli

That change (that was *Actually* made in 2.4) was exactly to remove this ambiguity.

Quoted 8 lines
Quoted 3 lines

Forgive my hasty reply. This combination of option is actually not-supported since 2.5 (in 2.4 we probably only introduced the deprecation warning).

I think I know what you mean.

Deprecating --secret to be --genkey secret is on the wiki. But the change *has* been made in 2.5 not pending for 2.7

correct.

Quoted 4 lines

Deprecating non-TLS mode VPNs is not on the wiki.

Deprecate non-TLS mode in 2.5

this depends on where the patch will be merged. I guess we have to wait for that.

Quoted 1 line

To be removed in 2.7

correct

Quoted 1 line

Replaced by peer-fingerprint option.

not replaced as drop-in, but users of --secret should look at --peer-fingerprint, yes.

Quoted 3 lines

If that is correct then I can add "non-TLS mode" to the wiki. Clear up the mess^D^D^D^D ambiguity ..

I would suggest to wait for the patch to be merged first. But the summary sounds right.

Cheers,

Signature · 1 line
Antonio Quartulli
#16 lore raw
In reply to Arne Schwabe

Am 25.03.21 um 01:01 schrieb Arne Schwabe:

Quoted 10 lines

The non-TLS mode is a relict from OpenVPN 1.x or 2.0. When tls mode was introduce the advantages of TLS over non-tls were small but tls mode evolved to include a lot more features. (NCP, multipeer, AEAD ciphers to name a few).

Today VPN that use --secret are mainly used because of its relative easy to setup and requiring to setup a PKI. This shortcoming of TLS mode should be addressed now with the peer-fingerprint option.

NAK.

Arne,

I find the reasons you present to withdraw the symmetric non-TLS mode too weak to justify its deprecation or removal. Yes, TLS-based configurations may be more feature-rich, but those are not mandatory and we should not paternalize the users here. Is there a considerable technical debt to keeping the --secret option?  WireGuard seems to be becoming quite popular and it provides low-ceremony setups - just as openvpn --secret does.

And to make a blunt point, it's not useless just because it's old, else we should nuke DNS and SMTP.

Regards,
Matthias

#17 lore raw

Hi,

Quoted 8 lines · Matthias Andree

I find the reasons you present to withdraw the symmetric non-TLS mode too weak to justify its deprecation or removal. Yes, TLS-based configurations may be more feature-rich, but those are not mandatory and we should not paternalize the users here. Is there a considerable technical debt to keeping the --secret option?  WireGuard seems to be becoming quite popular and it provides low-ceremony setups - just as openvpn --secret does.

The new --peer-fingerprint option offers a similar "quick setup" feature that old users of --secret may want to switch to.

Quoted 2 lines

And to make a blunt point, it's not useless just because it's old, else we should nuke DNS and SMTP.

It's not about being old. It's about being insecure.

With --secret (i.e. PSK encryption) there is no key renegotiation/rotation. This means IVs will be eventually re-used, which translates to encryption losing part of its strength.

This is unacceptable and users should be prevented from hitting this situation.

Regards,

Signature · 1 line
Antonio Quartulli
#18 lore raw

Am 25.03.21 um 20:57 schrieb Antonio Quartulli:

Quoted 16 lines

Hi,

Quoted 8 lines · Matthias Andree

I find the reasons you present to withdraw the symmetric non-TLS mode too weak to justify its deprecation or removal. Yes, TLS-based configurations may be more feature-rich, but those are not mandatory and we should not paternalize the users here. Is there a considerable technical debt to keeping the --secret option?  WireGuard seems to be becoming quite popular and it provides low-ceremony setups - just as openvpn --secret does.

The new --peer-fingerprint option offers a similar "quick setup" feature that old users of --secret may want to switch to.

Quoted 2 lines

And to make a blunt point, it's not useless just because it's old, else we should nuke DNS and SMTP.

Quoted 8 lines

It's not about being old. It's about being insecure.

With --secret (i.e. PSK encryption) there is no key renegotiation/rotation. This means IVs will be eventually re-used, which translates to encryption losing part of its strength.

This is unacceptable and users should be prevented from hitting this situation.

OK, I withdraw my NAK.

#19 lore raw
In reply to Arne Schwabe

Hi,

Quoted 10 lines · Arne Schwabe

The non-TLS mode is a relict from OpenVPN 1.x or 2.0. When tls mode was introduce the advantages of TLS over non-tls were small but tls mode evolved to include a lot more features. (NCP, multipeer, AEAD ciphers to name a few).

Today VPN that use --secret are mainly used because of its relative easy to setup and requiring to setup a PKI. This shortcoming of TLS mode should be addressed now with the peer-fingerprint option.

As per the discussion that sparked in this thread, I would suggest articulating the commit message a bit more to highlight the security concerns about using --secret and why it's a good idea to get rid of it.

The rest looks good to me.

Cheers,

Quoted 56 lines
---
 doc/man-sections/protocol-options.rst |  2 +-
 src/openvpn/options.c                 | 12 +++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
doc/man-sections/protocol-options.rst +1 -1
index 01789e58..4b6928c6 100644
@@ -235,7 +235,7 @@ configured in a compatible way between both the local and remote side.
   disables cipher negotiation.
 
 --secret args
-  Enable Static Key encryption mode (non-TLS). Use pre-shared secret
+  **DEPRECATED** Enable Static Key encryption mode (non-TLS). Use pre-shared secret
   ``file`` which was generated with ``--genkey``.
 
   Valid syntaxes:
src/openvpn/options.c +11 -1
index e52679f0..5b559edf 100644
@@ -514,7 +514,7 @@ static const char usage_message[] =
     "\n"
     "Data Channel Encryption Options (must be compatible between peers):\n"
     "(These options are meaningful for both Static Key & TLS-mode)\n"
-    "--secret f [d]  : Enable Static Key encryption mode (non-TLS).\n"
+    "--secret f [d]  : (DEPRECATED) Enable Static Key encryption mode (non-TLS).\n"
     "                  Use shared secret file f, generate with --genkey.\n"
     "                  The optional d parameter controls key directionality.\n"
     "                  If d is specified, use separate keys for each\n"
@@ -2564,6 +2564,15 @@ options_postprocess_verify_ce(const struct options *options,
         msg(M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
     }
 
+    if (!options->tls_server || !options->tls_client)
+    {
+        msg(M_INFO, "DEPRECATION: No tls-client or tls-server option in "
+                    "configuration detected. OpenVPN 2.7 will remove the "
+                    "functionality to run a VPN without TLS. "
+                    "See the examples section in the manual page for "
+                    "examples of a similar quick setup with peer-fingerprint.");
+    }
+
     if (options->ssl_flags & (SSLF_CLIENT_CERT_NOT_REQUIRED|SSLF_CLIENT_CERT_OPTIONAL))
     {
         msg(M_WARN, "WARNING: POTENTIALLY DANGEROUS OPTION "
@@ -7868,6 +7877,7 @@ add_option(struct options *options,
     }
     else if (streq(p[0], "secret") && p[1] && !p[3])
     {
+        msg(M_WARN, "DEPRECATED OPTION: The option --secret is deprecated. ");
         VERIFY_PERMISSION(OPT_P_GENERAL|OPT_P_INLINE);
         options->shared_secret_file = p[1];
         options->shared_secret_file_inline = is_inline;
Signature · 1 line
Antonio Quartulli
#2 lore raw

Re: [Openvpn-devel] [PATCH 2/2] Remove deprecated option '--keysize'

In reply to Arne Schwabe

Hi,

Quoted 91 lines · Arne Schwabe

This option has been deprecated in OpenVPN 2.4 and the ciphers that allow using this option fall all into the SWEET32 category of ciphers with 64 bit block size.

---
 config-msvc.h                |  1 -
 configure.ac                 |  2 +-
 src/openvpn/crypto.c         |  6 +-----
 src/openvpn/crypto.h         |  4 +---
 src/openvpn/crypto_openssl.c |  4 ++--
 src/openvpn/init.c           |  5 ++---
 src/openvpn/options.c        | 33 ++-------------------------------
 src/openvpn/options.h        |  2 --
 src/openvpn/ssl.c            |  7 +------
 9 files changed, 10 insertions(+), 54 deletions(-)
config-msvc.h +0 -1
index e430ca96..d0aa4438 100644
@@ -49,7 +49,6 @@
 #define HAVE_CHSIZE 1
 #define HAVE_CPP_VARARG_MACRO_ISO 1
 #define HAVE_CTIME 1
-#define HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH 1
 #define HAVE_IN_PKTINFO 1
 #define HAVE_MEMSET 1
 #define HAVE_PUTENV 1
configure.ac +1 -1
index 428bebed..bd592b3f 100644
@@ -881,7 +881,7 @@ if test "${with_crypto_library}" = "openssl"; then
 		)
 	fi
 
-	AC_CHECK_FUNCS([SSL_CTX_new EVP_CIPHER_CTX_set_key_length],
+	AC_CHECK_FUNCS([SSL_CTX_new],
 				   ,
 				   [AC_MSG_ERROR([openssl check failed])]
 	)
src/openvpn/crypto.c +1 -5
index 3a0bfbec..b042514b 100644
@@ -739,7 +739,7 @@ warn_insecure_key_type(const char *ciphername, const cipher_kt_t *cipher)
  */
 void
 init_key_type(struct key_type *kt, const char *ciphername,
-              const char *authname, int keysize, bool tls_mode, bool warn)
+              const char *authname, bool tls_mode, bool warn)
 {
     bool aead_cipher = false;
 
@@ -756,10 +756,6 @@ init_key_type(struct key_type *kt, const char *ciphername,
         }
 
         kt->cipher_length = cipher_kt_key_size(kt->cipher);
-        if (keysize > 0 && keysize <= MAX_CIPHER_KEY_LENGTH)
-        {
-            kt->cipher_length = keysize;
-        }
 
         /* check legal cipher mode */
         aead_cipher = cipher_kt_mode_aead(kt->cipher);
src/openvpn/crypto.h +1 -3
index 1ad669ce..b8128c7f 100644
@@ -301,14 +301,12 @@ int read_key(struct key *key, const struct key_type *kt, struct buffer *buf);
  * @param kt          The struct key_type to initialize
  * @param ciphername  The name of the cipher to use
  * @param authname    The name of the HMAC digest to use
- * @param keysize     The length of the cipher key to use, in bytes.  Only valid
- *                    for ciphers that support variable length keys.
  * @param tls_mode    Specifies whether we are running in TLS mode, which allows
  *                    more ciphers than static key mode.
  * @param warn        Print warnings when null cipher / auth is used.
  */
 void init_key_type(struct key_type *kt, const char *ciphername,
-                   const char *authname, int keysize, bool tls_mode, bool warn);
+                   const char *authname, bool tls_mode, bool warn);
 
 /*
  * Key context functions
src/openvpn/crypto_openssl.c +0 -0
index 573beaed..34decbb0 100644

src/openvpn/crypto_openssl.c cipher_ctx_init(EVP_CIPHER_CTX *ctx, const uint8_t *key, int key_len, · line 781

Quoted 7 lines
src/openvpn/crypto_openssl.c +2 -1
@@ -776,12 +776,12 @@ cipher_ctx_init(EVP_CIPHER_CTX *ctx, const uint8_t *key, int key_len,
     {
         crypto_msg(M_FATAL, "EVP cipher init #1");
     }
-#ifdef HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH
+    /* This serves as a check that the keylen is the correct as this fails
+     * when key_len and the fixed size of cipher disagree */
     if (!EVP_CIPHER_CTX_set_key_length(ctx, key_len))

Are you sure we need to keep this check?

key_len is basically kt->cipher_length, which (after his patch) is assigned by the SSL library itself after having initialized the cipher.

At a first glance, the rest looks good to me.

Cheers,

Quoted 176 lines
src/openvpn/crypto_openssl.c +0 -1
     {
         crypto_msg(M_FATAL, "EVP set key size");
     }
-#endif
     if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, enc))
     {
         crypto_msg(M_FATAL, "EVP cipher init #2");
src/openvpn/init.c +2 -3
index 132d47e4..336da941 100644
@@ -2599,7 +2599,7 @@ do_init_crypto_static(struct context *c, const unsigned int flags)
     {
         /* Get cipher & hash algorithms */
         init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname,
-                      options->keysize, options->test_crypto, true);
+                      options->test_crypto, true);
 
         /* Read cipher and hmac keys from shared secret file */
         crypto_read_openvpn_key(&c->c1.ks.key_type, &c->c1.ks.static_key,
@@ -2751,7 +2751,7 @@ do_init_crypto_tls_c1(struct context *c)
              || options->enable_ncp_fallback;
         /* Get cipher & hash algorithms */
         init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname,
-                      options->keysize, true, warn);
+                      true, warn);
 
         /* Initialize PRNG with config-specified digest */
         prng_init(options->prng_hash, options->prng_nonce_secret_len);
@@ -4515,7 +4515,6 @@ inherit_context_child(struct context *dest,
     /* inherit pre-NCP ciphers */
     dest->options.ciphername = src->options.ciphername;
     dest->options.authname = src->options.authname;
-    dest->options.keysize = src->options.keysize;
 
     /* inherit auth-token */
     dest->c1.ks.auth_token_key = src->c1.ks.auth_token_key;
src/openvpn/options.c +2 -31
index 5b559edf..7948f4a5 100644
@@ -531,10 +531,6 @@ static const char usage_message[] =
     "--ncp-disable   : (DEPRECATED) Disable cipher negotiation.\n"
     "--prng alg [nsl] : For PRNG, use digest algorithm alg, and\n"
     "                   nonce_secret_len=nsl.  Set alg=none to disable PRNG.\n"
-#ifdef HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH
-    "--keysize n     : (DEPRECATED) Size of cipher key in bits (optional).\n"
-    "                  If unspecified, defaults to cipher-specific default.\n"
-#endif
 #ifndef ENABLE_CRYPTO_MBEDTLS
     "--engine [name] : Enable OpenSSL hardware crypto engine functionality.\n"
 #endif
@@ -1733,7 +1729,6 @@ show_settings(const struct options *o)
     SHOW_STR(authname);
     SHOW_STR(prng_hash);
     SHOW_INT(prng_nonce_secret_len);
-    SHOW_INT(keysize);
 #ifndef ENABLE_CRYPTO_MBEDTLS
     SHOW_BOOL(engine);
 #endif /* ENABLE_CRYPTO_MBEDTLS */
@@ -2540,11 +2535,6 @@ options_postprocess_verify_ce(const struct options *options,
         }
     }
 
-    if (options->keysize)
-    {
-        msg(M_WARN, "WARNING: --keysize is DEPRECATED and will be removed in OpenVPN 2.6");
-    }
-
     /*
      * Check consistency of replay options
      */
@@ -3619,7 +3609,6 @@ pre_pull_save(struct options *o)
         /* NCP related options that can be overwritten by a push */
         o->pre_pull->ciphername = o->ciphername;
         o->pre_pull->authname = o->authname;
-        o->pre_pull->keysize = o->keysize;
 
         /* Ping related options should be reset to the config values on reconnect */
         o->pre_pull->ping_rec_timeout = o->ping_rec_timeout;
@@ -3675,7 +3664,6 @@ pre_pull_restore(struct options *o, struct gc_arena *gc)
 
         o->ciphername = pp->ciphername;
         o->authname = pp->authname;
-        o->keysize = pp->keysize;
 
         o->ping_rec_timeout = pp->ping_rec_timeout;
         o->ping_rec_timeout_action = pp->ping_rec_timeout_action;
@@ -3704,8 +3692,7 @@ calc_options_string_link_mtu(const struct options *o, const struct frame *frame)
     {
         struct frame fake_frame = *frame;
         struct key_type fake_kt;
-        init_key_type(&fake_kt, o->ciphername, o->authname, o->keysize, true,
-                      false);
+        init_key_type(&fake_kt, o->ciphername, o->authname, true, false);
         frame_remove_from_extra_frame(&fake_frame, crypto_max_overhead());
         crypto_adjust_frame_parameters(&fake_frame, &fake_kt, o->replay,
                                        cipher_kt_mode_ofb_cfb(fake_kt.cipher));
@@ -3876,8 +3863,7 @@ options_string(const struct options *o,
                + (TLS_SERVER == true)
                <= 1);
 
-        init_key_type(&kt, o->ciphername, o->authname, o->keysize, true,
-                      false);
+        init_key_type(&kt, o->ciphername, o->authname, true, false);
         /* Only announce the cipher to our peer if we are willing to
          * support it */
         const char *ciphername = cipher_kt_name(kt.cipher);
@@ -8087,21 +8073,6 @@ add_option(struct options *options,
         }
     }
 #endif /* ENABLE_CRYPTO_MBEDTLS */
-#ifdef HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH
-    else if (streq(p[0], "keysize") && p[1] && !p[2])
-    {
-        int keysize;
-
-        VERIFY_PERMISSION(OPT_P_NCP);
-        keysize = atoi(p[1]) / 8;
-        if (keysize < 0 || keysize > MAX_CIPHER_KEY_LENGTH)
-        {
-            msg(msglevel, "Bad keysize: %s", p[1]);
-            goto err;
-        }
-        options->keysize = keysize;
-    }
-#endif
 #ifdef ENABLE_PREDICTION_RESISTANCE
     else if (streq(p[0], "use-prediction-resistance") && !p[1])
     {
src/openvpn/options.h +0 -2
index d8e91fbc..5e924e1b 100644
@@ -77,7 +77,6 @@ struct options_pre_pull
 
     const char* ciphername;
     const char* authname;
-    int keysize;
 
     int ping_send_timeout;
     int ping_rec_timeout;
@@ -521,7 +520,6 @@ struct options
     bool ncp_enabled;
     const char *ncp_ciphers;
     const char *authname;
-    int keysize;
     const char *prng_hash;
     int prng_nonce_secret_len;
     const char *engine;
src/openvpn/ssl.c +1 -6
index 0daf19ad..d288d207 100644
@@ -1874,11 +1874,6 @@ tls_session_update_crypto_params(struct tls_session *session,
     {
         msg(D_HANDSHAKE, "Data Channel: using negotiated cipher '%s'",
             options->ciphername);
-        if (options->keysize)
-        {
-            msg(D_HANDSHAKE, "NCP: overriding user-set keysize with default");
-            options->keysize = 0;
-        }
     }
     else
     {
@@ -1889,7 +1884,7 @@ tls_session_update_crypto_params(struct tls_session *session,
     }
 
     init_key_type(&session->opt->key_type, options->ciphername,
-                  options->authname, options->keysize, true, true);
+                  options->authname, true, true);
 
     bool packet_id_long_form = cipher_kt_mode_ofb_cfb(session->opt->key_type.cipher);
     session->opt->crypto_flags &= ~(CO_PACKET_ID_LONG_FORM);
Signature · 1 line
Antonio Quartulli
#3 lore raw

Re: [Openvpn-devel] [PATCH 2/2] Remove deprecated option '--keysize'

Hi,

Quoted 6 lines · Antonio Quartulli

src/openvpn/crypto_openssl.c cipher_ctx_init(EVP_CIPHER_CTX *ctx, const uint8_t *key, int key_len, · line 781

Quoted 4 lines
src/openvpn/crypto_openssl.c +2 -1
-#ifdef HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH
+    /* This serves as a check that the keylen is the correct as this fails
+     * when key_len and the fixed size of cipher disagree */
     if (!EVP_CIPHER_CTX_set_key_length(ctx, key_len))

Are you sure we need to keep this check?

Indeed, that also got me wondering (and is the reason why I didn't just ack-and-merge it right away :-) - but I was waiting for someone else to understand and ACK this)

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]...
#20 lore raw
In reply to Arne Schwabe

Hi,

Quoted 4 lines · Arne Schwabe

The non-TLS mode is a relict from OpenVPN 1.x or 2.0. When tls mode was introduce the advantages of TLS over non-tls were small but tls mode evolved to include a lot more features. (NCP, multipeer, AEAD ciphers to name a few).

I think the most prominent benefit is "use of a session key which is independent of the shared secret", so perfect forward secrecy even if the secret is lost. The "features" are a nice benefit, but PFS is the truly important part, no?

Quoted 3 lines

Today VPN that use --secret are mainly used because of its relative easy to setup and requiring to setup a PKI. This shortcoming of TLS mode should be addressed now with the peer-fingerprint option.

This is fine, I'd say.

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]...
#4 lore raw

Re: [Openvpn-devel] [PATCH 2/2] Remove deprecated option '--keysize'

In reply to Gert Doering

Am 26.03.21 um 07:58 schrieb Gert Doering:

Quoted 8 lines

Hi,

Quoted 5 lines · Antonio Quartulli
Quoted 4 lines
src/openvpn/crypto_openssl.c +2 -1
-#ifdef HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH
+    /* This serves as a check that the keylen is the correct as this fails
+     * when key_len and the fixed size of cipher disagree */
     if (!EVP_CIPHER_CTX_set_key_length(ctx, key_len))
Quoted 6 lines
Quoted 1 line

Are you sure we need to keep this check?

Indeed, that also got me wondering (and is the reason why I didn't just ack-and-merge it right away :-) - but I was waiting for someone else to understand and ACK this)

The reason I kept it that it doesn't hurt but fails if something fishy happend in cipher handling. For mbed TLS the check is more useful as it doesn't set the keylen before doing this check.

Arne

#5 lore raw

Re: [Openvpn-devel] [PATCH 2/2] Remove deprecated option '--keysize'

Hi,

Quoted 11 lines · Arne Schwabe

Am 26.03.21 um 07:58 schrieb Gert Doering:

Quoted 10 lines

Hi,

Quoted 6 lines · Antonio Quartulli

src/openvpn/crypto_openssl.c cipher_ctx_init(EVP_CIPHER_CTX *ctx, const uint8_t *key, int key_len, · line 781

Quoted 4 lines
src/openvpn/crypto_openssl.c +2 -1
-#ifdef HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH
+    /* This serves as a check that the keylen is the correct as this fails
+     * when key_len and the fixed size of cipher disagree */
     if (!EVP_CIPHER_CTX_set_key_length(ctx, key_len))

Are you sure we need to keep this check?

Quoted 9 lines
Quoted 4 lines

Indeed, that also got me wondering (and is the reason why I didn't just ack-and-merge it right away :-) - but I was waiting for someone else to understand and ACK this)

The reason I kept it that it doesn't hurt but fails if something fishy happend in cipher handling. For mbed TLS the check is more useful as it doesn't set the keylen before doing this check.

I'd dare to say that if we don't trust OpenSSL in returning a meaningful key length, I am not sure why we should trust it when calling EVP_CIPHER_CTX_set_key_length.

If OpenSSL went cocoon, more calls will fail for sure.

This said, if you really wanna stick with EVP_CIPHER_CTX_set_key_length, I presume you should add it back to the configure.ac and you should also add again the ifdef around the invocation? Or that's not needed in this case?

Regarding mbedtls I am not sure how it is related to calling EVP_CIPHER_CTX_set_key_length.

Cheers!

Signature · 1 line
Antonio Quartulli
#21 lore raw

PATCH v2 1/1 Deprecate non TLS mode in OpenVPN

In reply to Arne Schwabe

The non-TLS mode is a relict from OpenVPN 1.x or 2.0. When tls mode was introduce the advantages of TLS over non-tls were small but tls mode evolved to include a lot more features. (NCP, multipeer, AEAD ciphers to name a few).

Today VPN that use --secret are mainly used because of its relative easy to setup and requiring to setup a PKI. This shortcoming of TLS mode should be addressed now with the peer-fingerprint option.

But the biggest reason to deprecate --secret is that the use of a fixed pre-shared key and lack of any of session key. No forward secrecy is possible and any VPN traffic can be decrypted later should the --secret by anyone who can get the session key. The cryptography overall used here was okay when --secret was introduced but is not acceptable by today's standard anymore.

Patch V2: Improve commit message

---
 doc/man-sections/protocol-options.rst |  2 +-
 src/openvpn/options.c                 | 12 +++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
doc/man-sections/protocol-options.rst +1 -1
index e9d5d63d4..bb08fa3ef 100644
@@ -226,7 +226,7 @@ configured in a compatible way between both the local and remote side.
   disables cipher negotiation.
 
 --secret args
-  Enable Static Key encryption mode (non-TLS). Use pre-shared secret
+  **DEPRECATED** Enable Static Key encryption mode (non-TLS). Use pre-shared secret
   ``file`` which was generated with ``--genkey``.
 
   Valid syntaxes:
src/openvpn/options.c +11 -1
index 51bd56c2b..4ef8924f5 100644
@@ -514,7 +514,7 @@ static const char usage_message[] =
     "\n"
     "Data Channel Encryption Options (must be compatible between peers):\n"
     "(These options are meaningful for both Static Key & TLS-mode)\n"
-    "--secret f [d]  : Enable Static Key encryption mode (non-TLS).\n"
+    "--secret f [d]  : (DEPRECATED) Enable Static Key encryption mode (non-TLS).\n"
     "                  Use shared secret file f, generate with --genkey.\n"
     "                  The optional d parameter controls key directionality.\n"
     "                  If d is specified, use separate keys for each\n"
@@ -2564,6 +2564,15 @@ options_postprocess_verify_ce(const struct options *options,
         msg(M_USAGE, "specify only one of --tls-server, --tls-client, or --secret");
     }
 
+    if (!options->tls_server || !options->tls_client)
+    {
+        msg(M_INFO, "DEPRECATION: No tls-client or tls-server option in "
+                    "configuration detected. OpenVPN 2.7 will remove the "
+                    "functionality to run a VPN without TLS. "
+                    "See the examples section in the manual page for "
+                    "examples of a similar quick setup with peer-fingerprint.");
+    }
+
     if (options->ssl_flags & (SSLF_CLIENT_CERT_NOT_REQUIRED|SSLF_CLIENT_CERT_OPTIONAL))
     {
         msg(M_WARN, "WARNING: POTENTIALLY DANGEROUS OPTION "
@@ -7862,6 +7871,7 @@ add_option(struct options *options,
     }
     else if (streq(p[0], "secret") && p[1] && !p[3])
     {
+        msg(M_WARN, "DEPRECATED OPTION: The option --secret is deprecated.");
         VERIFY_PERMISSION(OPT_P_GENERAL|OPT_P_INLINE);
         options->shared_secret_file = p[1];
         options->shared_secret_file_inline = is_inline;
Signature · 1 line
2.30.1
#6 lore raw

Re: [Openvpn-devel] [PATCH 2/2] Remove deprecated option '--keysize'

In reply to Antonio Quartulli
Quoted 5 lines

Regarding mbedtls I am not sure how it is related to calling EVP_CIPHER_CTX_set_key_length.

That was probably misleading. I wanted to say that the mbed variant of this function actually still has a more useful check in this function. So I wanted to keep both checks rather than to remove both.

Arne

#7 lore raw

PATCH v2 1/1 Remove deprecated option '--keysize'

In reply to Arne Schwabe

This option has been deprecated in OpenVPN 2.4 and the ciphers that allow using this option fall all into the SWEET32 category of ciphers with 64 bit block size.

Patch V2: Remove superflous check in OpenSSL codepath to check keysize

---
 config-msvc.h                |  1 -
 configure.ac                 |  2 +-
 src/openvpn/crypto.c         |  6 +-----
 src/openvpn/crypto.h         |  4 +---
 src/openvpn/crypto_openssl.c | 12 ++----------
 src/openvpn/init.c           |  5 ++---
 src/openvpn/options.c        | 33 ++-------------------------------
 src/openvpn/options.h        |  2 --
 src/openvpn/ssl.c            |  7 +------
 9 files changed, 10 insertions(+), 62 deletions(-)
config-msvc.h +0 -1
index 4db9efae2..aea2628be 100644
@@ -48,7 +48,6 @@
 #define HAVE_CHDIR 1
 #define HAVE_CHSIZE 1
 #define HAVE_CTIME 1
-#define HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH 1
 #define HAVE_IN_PKTINFO 1
 #define HAVE_MEMSET 1
 #define HAVE_PUTENV 1
configure.ac +1 -1
index 3cb9fc2fc..7bc6c7b90 100644
@@ -878,7 +878,7 @@ if test "${with_crypto_library}" = "openssl"; then
 		)
 	fi
 
-	AC_CHECK_FUNCS([SSL_CTX_new EVP_CIPHER_CTX_set_key_length],
+	AC_CHECK_FUNCS([SSL_CTX_new],
 				   ,
 				   [AC_MSG_ERROR([openssl check failed])]
 	)
src/openvpn/crypto.c +1 -5
index 3a0bfbec4..b042514bf 100644
@@ -739,7 +739,7 @@ warn_insecure_key_type(const char *ciphername, const cipher_kt_t *cipher)
  */
 void
 init_key_type(struct key_type *kt, const char *ciphername,
-              const char *authname, int keysize, bool tls_mode, bool warn)
+              const char *authname, bool tls_mode, bool warn)
 {
     bool aead_cipher = false;
 
@@ -756,10 +756,6 @@ init_key_type(struct key_type *kt, const char *ciphername,
         }
 
         kt->cipher_length = cipher_kt_key_size(kt->cipher);
-        if (keysize > 0 && keysize <= MAX_CIPHER_KEY_LENGTH)
-        {
-            kt->cipher_length = keysize;
-        }
 
         /* check legal cipher mode */
         aead_cipher = cipher_kt_mode_aead(kt->cipher);
src/openvpn/crypto.h +1 -3
index 1ad669ce1..b8128c7f1 100644
@@ -301,14 +301,12 @@ int read_key(struct key *key, const struct key_type *kt, struct buffer *buf);
  * @param kt          The struct key_type to initialize
  * @param ciphername  The name of the cipher to use
  * @param authname    The name of the HMAC digest to use
- * @param keysize     The length of the cipher key to use, in bytes.  Only valid
- *                    for ciphers that support variable length keys.
  * @param tls_mode    Specifies whether we are running in TLS mode, which allows
  *                    more ciphers than static key mode.
  * @param warn        Print warnings when null cipher / auth is used.
  */
 void init_key_type(struct key_type *kt, const char *ciphername,
-                   const char *authname, int keysize, bool tls_mode, bool warn);
+                   const char *authname, bool tls_mode, bool warn);
 
 /*
  * Key context functions
src/openvpn/crypto_openssl.c +2 -10
index 573beaed7..f3e86863e 100644
@@ -292,10 +292,8 @@ show_available_ciphers(void)
 #ifndef ENABLE_SMALL
     printf("The following ciphers and cipher modes are available for use\n"
            "with " PACKAGE_NAME ".  Each cipher shown below may be used as a\n"
-           "parameter to the --data-ciphers (or --cipher) option.  The\n"
-           "default key size is shown as well as whether or not it can be\n"
-           "changed with the --keysize directive.  Using a GCM or CBC mode\n"
-           "is recommended.  In static key mode only CBC mode is allowed.\n\n");
+           "parameter to the --data-ciphers (or --cipher) option. In static \n"
+           "key mode only CBC mode is allowed.\n\n");
 #endif
 
     for (nid = 0; nid < 10000; ++nid)
@@ -776,12 +774,6 @@ cipher_ctx_init(EVP_CIPHER_CTX *ctx, const uint8_t *key, int key_len,
     {
         crypto_msg(M_FATAL, "EVP cipher init #1");
     }
-#ifdef HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH
-    if (!EVP_CIPHER_CTX_set_key_length(ctx, key_len))
-    {
-        crypto_msg(M_FATAL, "EVP set key size");
-    }
-#endif
     if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, enc))
     {
         crypto_msg(M_FATAL, "EVP cipher init #2");
src/openvpn/init.c +2 -3
index 132d47e4e..336da9414 100644
@@ -2599,7 +2599,7 @@ do_init_crypto_static(struct context *c, const unsigned int flags)
     {
         /* Get cipher & hash algorithms */
         init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname,
-                      options->keysize, options->test_crypto, true);
+                      options->test_crypto, true);
 
         /* Read cipher and hmac keys from shared secret file */
         crypto_read_openvpn_key(&c->c1.ks.key_type, &c->c1.ks.static_key,
@@ -2751,7 +2751,7 @@ do_init_crypto_tls_c1(struct context *c)
              || options->enable_ncp_fallback;
         /* Get cipher & hash algorithms */
         init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname,
-                      options->keysize, true, warn);
+                      true, warn);
 
         /* Initialize PRNG with config-specified digest */
         prng_init(options->prng_hash, options->prng_nonce_secret_len);
@@ -4515,7 +4515,6 @@ inherit_context_child(struct context *dest,
     /* inherit pre-NCP ciphers */
     dest->options.ciphername = src->options.ciphername;
     dest->options.authname = src->options.authname;
-    dest->options.keysize = src->options.keysize;
 
     /* inherit auth-token */
     dest->c1.ks.auth_token_key = src->c1.ks.auth_token_key;
src/openvpn/options.c +2 -31
index 142da0618..6c9cd9c3a 100644
@@ -531,10 +531,6 @@ static const char usage_message[] =
     "--ncp-disable   : (DEPRECATED) Disable cipher negotiation.\n"
     "--prng alg [nsl] : For PRNG, use digest algorithm alg, and\n"
     "                   nonce_secret_len=nsl.  Set alg=none to disable PRNG.\n"
-#ifdef HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH
-    "--keysize n     : (DEPRECATED) Size of cipher key in bits (optional).\n"
-    "                  If unspecified, defaults to cipher-specific default.\n"
-#endif
 #ifndef ENABLE_CRYPTO_MBEDTLS
     "--engine [name] : Enable OpenSSL hardware crypto engine functionality.\n"
 #endif
@@ -1733,7 +1729,6 @@ show_settings(const struct options *o)
     SHOW_STR(authname);
     SHOW_STR(prng_hash);
     SHOW_INT(prng_nonce_secret_len);
-    SHOW_INT(keysize);
 #ifndef ENABLE_CRYPTO_MBEDTLS
     SHOW_BOOL(engine);
 #endif /* ENABLE_CRYPTO_MBEDTLS */
@@ -2540,11 +2535,6 @@ options_postprocess_verify_ce(const struct options *options,
         }
     }
 
-    if (options->keysize)
-    {
-        msg(M_WARN, "WARNING: --keysize is DEPRECATED and will be removed in OpenVPN 2.6");
-    }
-
     /*
      * Check consistency of replay options
      */
@@ -3619,7 +3609,6 @@ pre_pull_save(struct options *o)
         /* NCP related options that can be overwritten by a push */
         o->pre_pull->ciphername = o->ciphername;
         o->pre_pull->authname = o->authname;
-        o->pre_pull->keysize = o->keysize;
 
         /* Ping related options should be reset to the config values on reconnect */
         o->pre_pull->ping_rec_timeout = o->ping_rec_timeout;
@@ -3675,7 +3664,6 @@ pre_pull_restore(struct options *o, struct gc_arena *gc)
 
         o->ciphername = pp->ciphername;
         o->authname = pp->authname;
-        o->keysize = pp->keysize;
 
         o->ping_rec_timeout = pp->ping_rec_timeout;
         o->ping_rec_timeout_action = pp->ping_rec_timeout_action;
@@ -3704,8 +3692,7 @@ calc_options_string_link_mtu(const struct options *o, const struct frame *frame)
     {
         struct frame fake_frame = *frame;
         struct key_type fake_kt;
-        init_key_type(&fake_kt, o->ciphername, o->authname, o->keysize, true,
-                      false);
+        init_key_type(&fake_kt, o->ciphername, o->authname, true, false);
         frame_remove_from_extra_frame(&fake_frame, crypto_max_overhead());
         crypto_adjust_frame_parameters(&fake_frame, &fake_kt, o->replay,
                                        cipher_kt_mode_ofb_cfb(fake_kt.cipher));
@@ -3876,8 +3863,7 @@ options_string(const struct options *o,
                + (TLS_SERVER == true)
                <= 1);
 
-        init_key_type(&kt, o->ciphername, o->authname, o->keysize, true,
-                      false);
+        init_key_type(&kt, o->ciphername, o->authname, true, false);
         /* Only announce the cipher to our peer if we are willing to
          * support it */
         const char *ciphername = cipher_kt_name(kt.cipher);
@@ -8087,21 +8073,6 @@ add_option(struct options *options,
         }
     }
 #endif /* ENABLE_CRYPTO_MBEDTLS */
-#ifdef HAVE_EVP_CIPHER_CTX_SET_KEY_LENGTH
-    else if (streq(p[0], "keysize") && p[1] && !p[2])
-    {
-        int keysize;
-
-        VERIFY_PERMISSION(OPT_P_NCP);
-        keysize = atoi(p[1]) / 8;
-        if (keysize < 0 || keysize > MAX_CIPHER_KEY_LENGTH)
-        {
-            msg(msglevel, "Bad keysize: %s", p[1]);
-            goto err;
-        }
-        options->keysize = keysize;
-    }
-#endif
 #ifdef ENABLE_PREDICTION_RESISTANCE
     else if (streq(p[0], "use-prediction-resistance") && !p[1])
     {
src/openvpn/options.h +0 -2
index d8e91fbc3..5e924e1b3 100644
@@ -77,7 +77,6 @@ struct options_pre_pull
 
     const char* ciphername;
     const char* authname;
-    int keysize;
 
     int ping_send_timeout;
     int ping_rec_timeout;
@@ -521,7 +520,6 @@ struct options
     bool ncp_enabled;
     const char *ncp_ciphers;
     const char *authname;
-    int keysize;
     const char *prng_hash;
     int prng_nonce_secret_len;
     const char *engine;
src/openvpn/ssl.c +1 -6
index 23b55f3bd..b58207a56 100644
@@ -1872,11 +1872,6 @@ tls_session_update_crypto_params(struct tls_session *session,
     {
         msg(D_HANDSHAKE, "Data Channel: using negotiated cipher '%s'",
             options->ciphername);
-        if (options->keysize)
-        {
-            msg(D_HANDSHAKE, "NCP: overriding user-set keysize with default");
-            options->keysize = 0;
-        }
     }
     else
     {
@@ -1887,7 +1882,7 @@ tls_session_update_crypto_params(struct tls_session *session,
     }
 
     init_key_type(&session->opt->key_type, options->ciphername,
-                  options->authname, options->keysize, true, true);
+                  options->authname, true, true);
 
     bool packet_id_long_form = cipher_kt_mode_ofb_cfb(session->opt->key_type.cipher);
     session->opt->crypto_flags &= ~(CO_PACKET_ID_LONG_FORM);
Signature · 1 line
2.30.1
Acked-by on v2 1/1
#8 lore raw

Re: [Openvpn-devel] [PATCH v2] Remove deprecated option '--keysize'

Hi,

Quoted 5 lines · Arne Schwabe

This option has been deprecated in OpenVPN 2.4 and the ciphers that allow using this option fall all into the SWEET32 category of ciphers with 64 bit block size.

Patch V2: Remove superflous check in OpenSSL codepath to check keysize

Thanks for removing the extra check.

Quoted 2 lines

Compile tested on Linux against:
* OpenSSL 1.1.1
* OpenSSL 1.0.1
* OpenSSL 1.0.2
* mbedTLS 2.26.0
* mbedTLS 2.20.0
* mbedTLS 2.10.0

Windows+OpenSSL-1.1.1 compiled too (mingw).

Basic connection tests (master vs master and master vs 2.5) performed with OpenSSL 1.1.1 and mbedTLS 2.26.0 on Linux.

Signature · 1 line
Antonio Quartulli
#9 lore raw

Re: [Openvpn-devel] [PATCH v2] Remove deprecated option '--keysize'

Quoted 3 lines · Antonio Quartulli

Compile tested on Linux against:
* OpenSSL 1.1.1
* OpenSSL 1.0.1

this was meant to be 1.1.0

Quoted 4 lines

* OpenSSL 1.0.2
* mbedTLS 2.26.0
* mbedTLS 2.20.0
* mbedTLS 2.10.0

Cheers,

Signature · 1 line
Antonio Quartulli
Acked-by on v2 1/1
#22 lore raw
In reply to Arne Schwabe

The code change is simple enough to review. My p2p tests now complain to me in large letters that I should not be doing this (but still work fine).

I have spent a bit of time on the commit message and I hope I made it even more clear.

I have added a note to Changes.rst

Your patch has been applied to the master branch.

commit b72b5ff5e80135e85acc54b807797947528f1963

Author: Arne Schwabe
Date:   Sun Mar 28 11:05:30 2021 +0200
     Deprecate non TLS mode in OpenVPN

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

--
kind regards,

Gert Doering

#10 lore raw

[Openvpn-devel] [PATCH applied] Re: Remove deprecated option '--keysize'

In reply to Arne Schwabe

Your patch has been applied to the master branch.

I had conflicts in init.c and options.c due to the previously-merged "TLS libraries without BF-CBC" patch, but that was trivially resolved (3 calls to "init_key_type()", remove the keysize option from all of them). To be sure I didn't break anything, client-side tested with mbedtls and OpenSSL.

commit 961db602592cf9021b116fd555a8b09577d04683

Author: Arne Schwabe
Date:   Thu Apr 1 14:37:51 2021 +0200
     Remove deprecated option '--keysize'

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

--
kind regards,

Gert Doering