Skip to contentSkip to conversation

Add support for tls-ciphersuites for TLS 1.3

PATCH Superseded Arne Schwabe 3 participants 3 messages Sep 26, 2018 – Sep 28, 2018

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add support for tls-ciphersuites for TLS 1.3

OpenSSL 1.1.1 introduces a seperate list for TLS 1.3 ciphers. As these interfaces are meant to be user facing or not exposed at all and we expose the tls-cipher interface, we should also expose tls-cipherlist.

Combining both settings into tls-cipher would add a lot of glue logic that needs to be maintained and is error prone. On top of that, users should not set either settings unless absolutely required.

OpenSSL's own s_client/s_server also expose both settings and I believe most other software will too:

-cipher val Specify TLSv1.2 and below cipher list to be used
-ciphersuites val Specify TLSv1.3 ciphersuites to be used

For mbed TLS only the future can tell if we will see a combined or also two seperate lists.

---
 doc/openvpn.8             |  19 ++++-
 src/openvpn/options.c     |   7 ++
 src/openvpn/options.h     |   1 +
 src/openvpn/ssl.c         |   3 +-
 src/openvpn/ssl_backend.h |  13 ++-
 src/openvpn/ssl_mbedtls.c |  12 +++
 src/openvpn/ssl_openssl.c | 167 +++++++++++++++++++++++---------------
 7 files changed, 151 insertions(+), 71 deletions(-)
doc/openvpn.8 +17 -2
index 15a10296..0b44a29d 100644
@@ -5001,11 +5001,13 @@ determines the derivation of the tunnel session keys.
 .\"*********************************************************
 .TP
 .B \-\-tls\-cipher l
+.TQ
+.B \-\-tls\-ciphersuites l
 A list
 .B l
 of allowable TLS ciphers delimited by a colon (":").
 
-This setting can be used to ensure that certain cipher suites are used (or
+These setting can be used to ensure that certain cipher suites are used (or
 not used) for the TLS connection.  OpenVPN uses TLS to secure the control
 channel, over which the keys that are used to protect the actual VPN traffic
 are exchanged.
@@ -5014,13 +5016,24 @@ The supplied list of ciphers is (after potential OpenSSL/IANA name translation)
 simply supplied to the crypto library.  Please see the OpenSSL and/or mbed TLS
 documentation for details on the cipher list interpretation.
 
+For OpenSSL the
+.B \-\-tls-cipher
+is used for TLS 1.2 and below. For TLS 1.3 and up
+the
+.B \-\-tls\-ciphersuites
+setting is used. mbed TLS has no TLS 1.3 support yet and only the
+.B \-\-tls-cipher
+setting is used.
+
 Use
 .B \-\-show\-tls
 to see a list of TLS ciphers supported by your crypto library.
 
 Warning!
 .B \-\-tls\-cipher
-is an expert feature, which \- if used correcly \- can improve the security of
+and
+.B \-\-tls\-ciphersuites
+are expert features, which \- if used correcly \- can improve the security of
 your VPN connection.  But it is also easy to unwittingly use it to carefully
 align a gun with your foot, or just break your connection.  Use with care!
 
@@ -5028,6 +5041,8 @@ The default for \-\-tls\-cipher is to use mbed TLS's default cipher list
 when using mbed TLS or
 "DEFAULT:!EXP:!LOW:!MEDIUM:!kDH:!kECDH:!DSS:!PSK:!SRP:!kRSA" when using
 OpenSSL.
+
+The default for \-\-tls\-ciphersuites is to use the crypto library's default.
 .\"*********************************************************
 .TP
 .B \-\-tls\-cert\-profile profile
src/openvpn/options.c +7 -0
index 03550c1e..a574c9f9 100644
@@ -1766,6 +1766,7 @@ show_settings(const struct options *o)
 #endif
     SHOW_STR(cipher_list);
     SHOW_STR(tls_cert_profile);
+    SHOW_STR(cipher_list_tls13);
     SHOW_STR(tls_verify);
     SHOW_STR(tls_export_cert);
     SHOW_INT(verify_x509_type);
@@ -2759,6 +2760,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec
         MUST_BE_UNDEF(pkcs12_file);
 #endif
         MUST_BE_UNDEF(cipher_list);
+        MUST_BE_UNDEF(cipher_list_tls13);
         MUST_BE_UNDEF(tls_cert_profile);
         MUST_BE_UNDEF(tls_verify);
         MUST_BE_UNDEF(tls_export_cert);
@@ -7948,6 +7950,11 @@ add_option(struct options *options,
         VERIFY_PERMISSION(OPT_P_GENERAL);
         options->tls_cert_profile = p[1];
     }
+    else if (streq(p[0], "tls-ciphersuites") && p[1] && !p[2])
+    {
+      VERIFY_PERMISSION(OPT_P_GENERAL);
+      options->cipher_list_tls13 = p[1];
+    }
     else if (streq(p[0], "crl-verify") && p[1] && ((p[2] && streq(p[2], "dir"))
                                                    || (p[2] && streq(p[1], INLINE_FILE_TAG) ) || !p[2]) && !p[3])
     {
src/openvpn/options.h +1 -0
index 4c3bc4fb..3e7ef4f8 100644
@@ -508,6 +508,7 @@ struct options
     const char *priv_key_file;
     const char *pkcs12_file;
     const char *cipher_list;
+    const char *cipher_list_tls13;
     const char *tls_cert_profile;
     const char *ecdh_curve;
     const char *tls_verify;
src/openvpn/ssl.c +2 -1
index e5e4aac2..616c2696 100644
@@ -626,9 +626,10 @@ init_ssl(const struct options *options, struct tls_root_ctx *new_ctx)
     tls_ctx_set_cert_profile(new_ctx, options->tls_cert_profile);
 
     /* Allowable ciphers */
-    /* Since @SECLEVEL also influces loading of certificates, set the
+    /* Since @SECLEVEL also influences loading of certificates, set the
      * cipher restrictions before loading certificates */
     tls_ctx_restrict_ciphers(new_ctx, options->cipher_list);
+    tls_ctx_restrict_ciphers_tls13(new_ctx, options->cipher_list_tls13);
 
     if (!tls_ctx_set_options(new_ctx, options->ssl_flags))
     {
src/openvpn/ssl_backend.h +12 -1
index 5023c02a..0995bb4c 100644
@@ -169,7 +169,8 @@ bool tls_ctx_initialised(struct tls_root_ctx *ctx);
 bool tls_ctx_set_options(struct tls_root_ctx *ctx, unsigned int ssl_flags);
 
 /**
- * Restrict the list of ciphers that can be used within the TLS context.
+ * Restrict the list of ciphers that can be used within the TLS context for TLS 1.2
+ * and below
  *
  * @param ctx           TLS context to restrict, must be valid.
  * @param ciphers       String containing : delimited cipher names, or NULL to use
@@ -177,6 +178,16 @@ bool tls_ctx_set_options(struct tls_root_ctx *ctx, unsigned int ssl_flags);
  */
 void tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers);
 
+/**
+ * Restrict the list of ciphers that can be used within the TLS context for TLS 1.3
+ * and higher
+ *
+ * @param ctx           TLS context to restrict, must be valid.
+ * @param ciphers       String containing : delimited cipher names, or NULL to use
+ *                                      sane defaults.
+ */
+void tls_ctx_restrict_ciphers_tls13(struct tls_root_ctx *ctx, const char *ciphers);
+
 /**
  * Set the TLS certificate profile.  The profile defines which crypto
  * algorithms may be used in the supplied certificate.
src/openvpn/ssl_mbedtls.c +12 -0
index e4850cb6..7c578a90 100644
@@ -222,6 +222,18 @@ tls_translate_cipher_name(const char *cipher_name)
     return pair->iana_name;
 }
 
+void
+tls_ctx_restrict_ciphers_tls13(struct tls_root_ctx *ctx, const char *ciphers)
+{
+  if (ciphers == NULL)
+  {
+    /* Nothing to do, return without warning message */
+    return;
+  }
+
+  msg(M_WARN, "mbed TLS does not support setting tls-ciphersuites. Ignoring TLS 1.3 cipher list: %s", ciphers);
+}
+
 void
 tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers)
 {
src/openvpn/ssl_openssl.c +100 -67

183 lines not on this page · raw message

Signature · 1 line
2.19.0
#1 lore raw

Hi Arne,

I haven't looked at the code, only at strings for now, and I'd like to pick a few nits.

Am 26.09.18 um 15:44 schrieb Arne Schwabe:

Quoted 10 lines

OpenSSL 1.1.1 introduces a seperate list for TLS 1.3 ciphers. As these interfaces are meant to be user facing or not exposed at all and we expose the tls-cipher interface, we should also expose tls-cipherlist. [...]

index 15a10296..0b44a29d 100644

doc/openvpn.8 +0 -0
@@ -5001,11 +5001,13 @@ determines the derivation of the tunnel session keys.
 .\"*********************************************************

doc/openvpn.8 determines the derivation of the tunnel session keys. · line 5010

Quoted 10 lines
doc/openvpn.8 +3 -1
 .TP
 .B \-\-tls\-cipher l
+.TQ
+.B \-\-tls\-ciphersuites l
 A list
 .B l
 of allowable TLS ciphers delimited by a colon (":").
 
-This setting can be used to ensure that certain cipher suites are used (or
+These setting can be used to ensure that certain cipher suites are used (or

These setting_s_ ...

doc/openvpn.8 The supplied list of ciphers is (after potential OpenSSL/IANA name translation) · line 5019

Quoted 8 lines
doc/openvpn.8 +1 -0
 not used) for the TLS connection.  OpenVPN uses TLS to secure the control
 channel, over which the keys that are used to protect the actual VPN traffic
 are exchanged.
@@ -5014,13 +5016,24 @@ The supplied list of ciphers is (after potential OpenSSL/IANA name translation)
 simply supplied to the crypto library.  Please see the OpenSSL and/or mbed TLS
 documentation for details on the cipher list interpretation.
 
+For OpenSSL the

add a comma before "the"

doc/openvpn.8 The supplied list of ciphers is (after potential OpenSSL/IANA name translation) · line 5021

Quoted 2 lines
doc/openvpn.8 +2 -0
+.B \-\-tls-cipher
+is used for TLS 1.2 and below. For TLS 1.3 and up

add a comma at the end.

Quoted 7 lines
doc/openvpn.8 +6 -0
+the
+.B \-\-tls\-ciphersuites
+setting is used. mbed TLS has no TLS 1.3 support yet and only the
+.B \-\-tls-cipher
+setting is used.
+
 Use

doc/openvpn.8 The supplied list of ciphers is (after potential OpenSSL/IANA name translation) · line 5037

Quoted 10 lines
doc/openvpn.8 +3 -1
 .B \-\-show\-tls
 to see a list of TLS ciphers supported by your crypto library.
 
 Warning!
 .B \-\-tls\-cipher
-is an expert feature, which \- if used correcly \- can improve the security of
+and
+.B \-\-tls\-ciphersuites
+are expert features, which \- if used correcly \- can improve the security of
 your VPN connection.  But it is also easy to unwittingly use it to carefully

...use _them_...

doc/openvpn.8 The supplied list of ciphers is (after potential OpenSSL/IANA name translation)

Quoted 3 lines
doc/openvpn.8 +3 -0
+  msg(M_WARN, "mbed TLS does not support setting tls-ciphersuites. Ignoring TLS 1.3 cipher list: %s", ciphers);
+}
+

Is the blank between mbed and TLS right?

Cheers,
Matthias

#2 lore raw

On 27/09/18 22:20, Matthias Andree wrote:
[...]

Quoted 5 lines

src/openvpn/ssl_mbedtls.c tls_translate_cipher_name(const char *cipher_name) · line 236

Quoted 3 lines
src/openvpn/ssl_mbedtls.c +3 -0
+  msg(M_WARN, "mbed TLS does not support setting tls-ciphersuites. Ignoring TLS 1.3 cipher list: %s", ciphers);
+}
+

Is the blank between mbed and TLS right?

Looks so, when seeing what they do on the official web pages:

<https://tls.mbed.org/>

Seems pretty consistent there.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc