Change in openvpn[release/2.6]: Backport mbed TLS 3 support to OpenVPN 2.6
A message that is not in the archive (sent off-list or not yet received): gerrit.1700494503000.Icb4ae73741dc84ef0ff7ef72721cc12b999f4d03@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/404?usp=email
to review the following change.
Change subject: Backport mbed TLS 3 support to OpenVPN 2.6
......................................................................
Backport mbed TLS 3 support to OpenVPN 2.6
Based on commits
- ace7a4f1c271550bb8ad276663e045ab97a46f16
- f53f06316dbb804128fc5cbee1d8edb274ce81df
- efad93d049c318a3bd9ea5956c6ac8237b8d6d70
- b5faf1b2e90fd44c5137a2b8f3da98c7ae482fc1
---
M README.mbedtls
M config.h.cmake.in
M configure.ac
M src/openvpn/Makefile.am
M src/openvpn/crypto_mbedtls.c
A src/openvpn/mbedtls_compat.h
M src/openvpn/options.c
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_verify_mbedtls.c
9 files changed, 422 insertions(+), 115 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/04/404/1
README.mbedtls +11 -8
@@ -1,13 +1,13 @@ -This version of OpenVPN has mbed TLS support. To enable follow the following -instructions: +This version of OpenVPN has mbed TLS support. To enable, follow the +instructions below: -To Build and Install, +To build and install, ./configure --with-crypto-library=mbedtls make make install -This version depends on mbed TLS 2.0 (and requires at least 2.0.0). +This version requires mbed TLS version >= 2.0.0 or >= 3.2.1. *************************************************************************
@@ -16,7 +16,8 @@ As of mbed TLS 2.17, it can be licensed *only* under the Apache v2.0 license. That license is incompatible with OpenVPN's GPLv2. -If you wish to distribute OpenVPN linked with mbed TLS, there are two options: +We are currently in the process of resolving this problem, but for now, if you +wish to distribute OpenVPN linked with mbed TLS, there are two options: * Ensure that your case falls under the system library exception in GPLv2, or
@@ -24,9 +25,6 @@ that may be licensed under GPLv2. Unfortunately, this version is unsupported and won't receive any more updates. -If nothing changes about the license situation, mbed TLS support may be -deprecated in a future release of OpenVPN. - ************************************************************************* Due to limitations in the mbed TLS library, the following features are missing
@@ -42,3 +40,8 @@ * X.509 subject line has a different format than the OpenSSL subject line * X.509 certificate export does not work * X.509 certificate tracking + +************************************************************************* + +Mbed TLS 3 has implemented (parts of) the TLS 1.3 protocol, but we have disabled +support in OpenVPN because the TLS-Exporter function is not yet implemented.
config.h.cmake.in +4 -1
@@ -387,7 +387,10 @@ #undef HAVE_VSNPRINTF /* we always assume a recent mbed TLS version */ -#define HAVE_CTR_DRBG_UPDATE_RET 1 +#define HAVE_MBEDTLS_PSA_CRYPTO_H 1 +#define HAVE_MBEDTLS_SSL_TLS_PRF 1 +#define HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB 1 +#define HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET 1 /* Path to ifconfig tool */ #define IFCONFIG_PATH "@IFCONFIG_PATH@"
configure.ac +27 -5
@@ -1019,13 +1019,19 @@ #include <mbedtls/version.h> ]], [[ -#if MBEDTLS_VERSION_NUMBER < 0x02000000 || MBEDTLS_VERSION_NUMBER >= 0x03000000 +#if MBEDTLS_VERSION_NUMBER < 0x02000000 || (MBEDTLS_VERSION_NUMBER >= 0x03000000 && MBEDTLS_VERSION_NUMBER < 0x03020100) #error invalid version #endif ]] )], [AC_MSG_RESULT([ok])], - [AC_MSG_ERROR([mbed TLS 2.y.z required])] + [AC_MSG_ERROR([mbed TLS version >= 2.0.0 or >= 3.2.1 required])] + ) + + AC_CHECK_HEADER( + psa/crypto.h, + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_PSA_CRYPTO_H], [0], [no])] ) AC_CHECK_FUNCS(
@@ -1037,16 +1043,32 @@ [AC_MSG_ERROR([mbed TLS check for AEAD support failed])] ) + AC_CHECK_FUNC( + [mbedtls_ssl_tls_prf], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [0], [no])] + ) + have_export_keying_material="yes" AC_CHECK_FUNC( [mbedtls_ssl_conf_export_keys_ext_cb], - , - [have_export_keying_material="no"] + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [0], [no])] ) + if test "x$ac_cv_func_mbedtls_ssl_conf_export_keys_ext_cb" != xyes; then + AC_CHECK_FUNC( + [mbedtls_ssl_set_export_keys_cb], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [1], [yes])], + [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [0], [no])] + ) + if test "x$ac_cv_func_mbedtls_ssl_set_export_keys_cb" != xyes; then + have_export_keying_material="no" + fi + fi AC_CHECK_FUNC( [mbedtls_ctr_drbg_update_ret], - AC_DEFINE([HAVE_CTR_DRBG_UPDATE_RET], [1], + AC_DEFINE([HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET], [1], [Use mbedtls_ctr_drbg_update_ret from mbed TLS]), )
src/openvpn/Makefile.am +1 -0
@@ -82,6 +82,7 @@ ovpn_dco_win.h \ platform.c platform.h \ console.c console.h console_builtin.c console_systemd.c \ + mbedtls_compat.h \ mroute.c mroute.h \ mss.c mss.h \ mstats.c mstats.h \
src/openvpn/crypto_mbedtls.c +45 -31
217 lines not on this page · raw message
src/openvpn/mbedtls_compat.h new file +189 -0
189 lines not on this page · raw message
src/openvpn/options.c +7 -0
@@ -653,8 +653,10 @@ "--verify-x509-name name: Accept connections only from a host with X509 subject\n" " DN name. The remote host must also pass all other tests\n" " of verification.\n" +#ifndef ENABLE_CRYPTO_MBEDTLS "--ns-cert-type t: (DEPRECATED) Require that peer certificate was signed with \n" " an explicit nsCertType designation t = 'client' | 'server'.\n" +#endif "--x509-track x : Save peer X509 attribute x in environment for use by\n" " plugins and management interface.\n"#ifdef HAVE_EXPORT_KEYING_MATERIAL
@@ -9051,6 +9053,10 @@ }else if (streq (p[0 ],"ns-cert-type" ) && p[1 ] && !p[2 ]) { +#ifdef ENABLE_CRYPTO_MBEDTLS +msg (msglevel,"--ns-cert-type is not available with mbedtls." ); + goto err; +#else VERIFY_PERMISSION (OPT_P_GENERAL );if (streq (p[1 ],"server" )) {
@@ -9065,6 +9071,7 @@msg (msglevel,"--ns-cert-type must be 'client' or 'server'" ); goto err; } +#endif /* ENABLE_CRYPTO_MBEDTLS */ }else if (streq (p[0 ],"remote-cert-ku" )) {
src/openvpn/ssl_mbedtls.c +132 -53
337 lines not on this page · raw message
src/openvpn/ssl_verify_mbedtls.c +6 -17
@@ -35,6 +35,7 @@#if defined(ENABLE_CRYPTO_MBEDTLS )#include "crypto_mbedtls.h" +#include "mbedtls_compat.h" #include "ssl_verify.h" #include <mbedtls/asn1.h> #include <mbedtls/error.h>
@@ -432,6 +433,8 @@ } } +/* Dummy function because Netscape certificate types are not supported in OpenVPN with mbedtls. +* Returns SUCCESS if usage is NS_CERT_CHECK_NONE, FAILURE otherwise. */ result_t x509_verify_ns_cert_type (mbedtls_x509_crt *cert,const int usage) {
@@ -439,18 +442,6 @@ {return SUCCESS ; } -if (usage ==NS_CERT_CHECK_CLIENT ) - { -return ((cert->ext_types &MBEDTLS_X509_EXT_NS_CERT_TYPE ) - && (cert->ns_cert_type &MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT )) ? -SUCCESS :FAILURE ; - } -if (usage ==NS_CERT_CHECK_SERVER ) - { -return ((cert->ext_types &MBEDTLS_X509_EXT_NS_CERT_TYPE ) - && (cert->ns_cert_type &MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER )) ? -SUCCESS :FAILURE ; - }return FAILURE ; }
@@ -461,7 +452,7 @@ {msg (D_HANDSHAKE ,"Validating certificate key usage" ); -if (!(cert->ext_types &MBEDTLS_X509_EXT_KEY_USAGE )) +if (!mbedtls_x509_crt_has_ext_type (cert,MBEDTLS_X509_EXT_KEY_USAGE )) {msg (D_TLS_ERRORS ,"ERROR: Certificate does not have key usage extension" );
@@ -486,9 +477,7 @@if (fFound !=SUCCESS ) { -msg (D_TLS_ERRORS , -"ERROR: Certificate has key usage %04x, expected one of:" , - cert->key_usage); +msg (D_TLS_ERRORS ,"ERROR: Certificate has invalid key usage, expected one of:" );for (size_t i =0 ; i < expected_len && expected_ku[i]; i++) {msg (D_TLS_ERRORS ," * %04x" , expected_ku[i]);
@@ -503,7 +492,7 @@ {result_t fFound =FAILURE ; -if (!(cert->ext_types &MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE )) +if (!mbedtls_x509_crt_has_ext_type (cert,MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE )) {msg (D_HANDSHAKE ,"Certificate does not have extended key usage extension" ); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/404?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Icb4ae73741dc84ef0ff7ef72721cc12b999f4d03
Gerrit-Change-Number: 404
Gerrit-PatchSet: 1
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Hi,
Quoted 10 lines · MaxF (Code Review)
Change subject: Backport mbed TLS 3 support to OpenVPN 2.6
......................................................................Backport mbed TLS 3 support to OpenVPN 2.6
Based on commits
-ace7a4f1c271550bb8ad276663e045ab97a46f16
-f53f06316dbb804128fc5cbee1d8edb274ce81df
-efad93d049c318a3bd9ea5956c6ac8237b8d6d70
-b5faf1b2e90fd44c5137a2b8f3da98c7ae482fc1
So, after discussion with Arne how to proceed, we decided to not apply this patch from gerrit "as is", but to do explicit cherry-picking of these 4 commits - so git history directly tracks which bits came from where.
This brings now 4 new commits in release/2.6:
commit 001950d14eefe60fd71b6a7091161b0546ff5a9e (HEAD -> release/2.6)
Author: Max Fillinger <[email protected]...> Date: Fri Nov 17 10:14:01 2023 +0100
Enable key export with mbed TLS 3.x.y
(cherry picked from commit b5faf1b2e90fd44c5137a2b8f3da98c7ae482fc1)
commit 7fa534dbb81c7e3d526a2e9110f35d11de26105c
Author: Max Fillinger <[email protected]...> Date: Wed Nov 15 16:17:40 2023 +0100
Disable TLS 1.3 support with mbed TLS
(cherry picked from commit efad93d049c318a3bd9ea5956c6ac8237b8d6d70)
commit 1aa2995ebc06a2b8d6df48eb63eb15482fd07865
Author: Max Fillinger <[email protected]...> Date: Wed Oct 25 14:19:28 2023 +0200
Update README.mbedtls
(cherry picked from commit f53f06316dbb804128fc5cbee1d8edb274ce81df)commit 2942ef5d405413d990d1fc2fa06976bcdd24742e
Author: Max Fillinger <[email protected]...> Date: Wed Oct 25 14:18:30 2023 +0200
Add support for mbedtls 3.X.Y
(cherry picked from commit ace7a4f1c271550bb8ad276663e045ab97a46f16)
I have tested the resulting source tree with mbedTLS 2.28.6 (FreeBSD package default) and 3.5.1 (latest 3.x, build from source) - t_client only, but that should be sufficient - and the result is satisfactory
OpenVPN 2.6.8 [git:release/2.6/001950d14eefe60f] amd64-unknown-freebsd13.2 [SSL (mbed TLS)] [LZO] [LZ4] [MH/RECVDA] [AEAD] built on Jan 17 2024 library versions: mbed TLS 3.5.1, LZO 2.10
Test sets succeeded: 1 1a 1b 1c 1d 1e 2 2a 2b 2c 2d 2e 2f 3 4 4a 4b 5 6 8 8a 9 9a 9b 9x. ./t_lpback.sh: tests passed: 21 failed: 0
(that is the test result with 2.28.6 - with 3.5.1, all tests involving BF-CBC fail, as that is no longer a supported cipher, but everything else passes just fine)
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]...Attention is currently required from: MaxF, flichtenheld.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/404?usp=email )
Change subject: Backport mbed TLS 3 support to OpenVPN 2.6
......................................................................
Patch Set 3:
(1 comment)
Patchset:
PS3:
So this is just the same as the cherry-pick of the four mentioned commits in the commit message and those apply without problems. @[email protected]... can we just do a cherry pick of those 4 commits? That would make it also clearer in the commit history that this is exactly the same as in master.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/404?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Icb4ae73741dc84ef0ff7ef72721cc12b999f4d03
Gerrit-Change-Number: 404
Gerrit-PatchSet: 3
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Wed, 13 Dec 2023 14:51:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: MaxF, flichtenheld.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/404?usp=email )
Change subject: Backport mbed TLS 3 support to OpenVPN 2.6
......................................................................
Patch Set 3: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/404?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Icb4ae73741dc84ef0ff7ef72721cc12b999f4d03
Gerrit-Change-Number: 404
Gerrit-PatchSet: 3
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Wed, 17 Jan 2024 16:03:53 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: MaxF, flichtenheld.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/404?usp=email )
Change subject: Backport mbed TLS 3 support to OpenVPN 2.6
......................................................................
Patch Set 3:
(1 comment)
Patchset:
PS3:
So this works nicely but I think we should cherry pick these commits instead of the squashed together commit.
We might also want to cherry pick 8656b85c which fixes cmake building but needs a small conflict resolution.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/404?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Icb4ae73741dc84ef0ff7ef72721cc12b999f4d03
Gerrit-Change-Number: 404
Gerrit-PatchSet: 3
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Wed, 17 Jan 2024 16:04:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: MaxF, flichtenheld.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/404?usp=email )
Change subject: Backport mbed TLS 3 support to OpenVPN 2.6
......................................................................
Patch Set 3:
(1 comment)
Patchset:
PS3:
as suggested, merged as 4 individual cherry-picks, and replied on the openvpn-devel@ list.
Now, how to teach gerrit that this is done?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/404?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Icb4ae73741dc84ef0ff7ef72721cc12b999f4d03
Gerrit-Change-Number: 404
Gerrit-PatchSet: 3
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Wed, 17 Jan 2024 21:24:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
plaisthos has abandoned this change. ( http://gerrit.openvpn.net/c/openvpn/+/404?usp=email )
Change subject: Backport mbed TLS 3 support to OpenVPN 2.6
......................................................................
Abandoned
Cherry picked as individiual commits.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/404?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Icb4ae73741dc84ef0ff7ef72721cc12b999f4d03
Gerrit-Change-Number: 404
Gerrit-PatchSet: 3
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: abandon