From: "MaxF (Code Review)" Date: Thu, 22 May 2025 18:18:04 +0000 References: Reply-To: max@...2606..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="R5Zf2t9krFg="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Remove HAVE_EXPORT_KEYING_MATERIAL macro List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --R5Zf2t9krFg= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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/+/1043?usp=3Demail to review the following change. Change subject: Remove HAVE_EXPORT_KEYING_MATERIAL macro ...................................................................... Remove HAVE_EXPORT_KEYING_MATERIAL macro This was always defined in all supported versions of OpenSSL and WolfSSL. EKM should be available in supported mbed TLS versions, too. This commit includes some style changes required by uncrustify. Change-Id: Icbfffae877f8eca8d94721a4d54e140c50d4a550 --- M config.h.cmake.in M configure.ac M src/openvpn/init.c M src/openvpn/multi.c M src/openvpn/options.c M src/openvpn/options.h M src/openvpn/ssl.c M src/openvpn/ssl_mbedtls.c M src/openvpn/ssl_mbedtls.h M src/openvpn/ssl_ncp.c 10 files changed, 10 insertions(+), 67 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/43/1043/1 diff --git a/config.h.cmake.in b/config.h.cmake.in index 5164ce3..5df0ac8 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -120,9 +120,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_ERR_H -/* Crypto library supports keying material exporter */ -#define HAVE_EXPORT_KEYING_MATERIAL 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_FCNTL_H diff --git a/configure.ac b/configure.ac index 75367e8..1b908e6 100644 --- a/configure.ac +++ b/configure.ac @@ -988,10 +988,6 @@ [AC_MSG_ERROR([OpenSSL check for AES-256-GCM support failed])] ) - # All supported OpenSSL versions (>=3D 1.1.0) - # have this feature - have_export_keying_material=3D"yes" - CFLAGS=3D"${saved_CFLAGS}" LIBS=3D"${saved_LIBS}" @@ -1064,7 +1060,6 @@ [AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [0], [no])] ) - have_export_keying_material=3D"yes" AC_CHECK_FUNC( [mbedtls_ssl_conf_export_keys_ext_cb], [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [1], [yes])], @@ -1077,7 +1072,7 @@ [AC_DEFINE([HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB], [0], [no])] ) if test "x$ac_cv_func_mbedtls_ssl_set_export_keys_cb" !=3D xyes; then - have_export_keying_material=3D"no" + AC_MSG_ERROR(This version of mbed TLS has no support for exporting key = material.) fi fi @@ -1132,17 +1127,12 @@ ) AC_CHECK_HEADER([wolfssl/options.h],,[AC_MSG_ERROR([wolfSSL header wolfss= l/options.h not found!])]) - # wolfSSL signal EKM support - have_export_keying_material=3D"yes" - if test "${enable_wolfssl_options_h}" =3D "yes"; then AC_DEFINE([EXTERNAL_OPTS_OPENVPN], [1], [Include options.h from wolfSSL = library]) else AC_DEFINE([WOLFSSL_USER_SETTINGS], [1], [Use custom user_settings.h file= for wolfSSL library]) fi - have_export_keying_material=3D"yes" - CFLAGS=3D"${saved_CFLAGS}" LIBS=3D"${saved_LIBS}" @@ -1346,12 +1336,6 @@ test "${enable_dns_updown_by_default}" =3D "yes" && AC_DEFINE([ENABLE_DNS_= UPDOWN_BY_DEFAULT], [1], [Enable dns-updown hook by default]) test "${enable_ntlm}" =3D "yes" && AC_DEFINE([ENABLE_NTLM], [1], [Enable N= TLMv2 proxy support]) test "${enable_crypto_ofb_cfb}" =3D "yes" && AC_DEFINE([ENABLE_OFB_CFB_MOD= E], [1], [Enable OFB and CFB cipher modes]) -if test "${have_export_keying_material}" =3D "yes"; then - AC_DEFINE( - [HAVE_EXPORT_KEYING_MATERIAL], [1], - [Crypto library supports keying material exporter] - ) -fi OPTIONAL_CRYPTO_CFLAGS=3D"${OPTIONAL_CRYPTO_CFLAGS} ${CRYPTO_CFLAGS}" OPTIONAL_CRYPTO_LIBS=3D"${OPTIONAL_CRYPTO_LIBS} ${CRYPTO_LIBS}" diff --git a/src/openvpn/init.c b/src/openvpn/init.c index e0ba255..15eacab 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -3483,7 +3483,6 @@ to.comp_options =3D options->comp; #endif -#ifdef HAVE_EXPORT_KEYING_MATERIAL if (options->keying_material_exporter_label) { to.ekm_size =3D options->keying_material_exporter_length; @@ -3499,7 +3498,6 @@ { to.ekm_size =3D 0; } -#endif /* HAVE_EXPORT_KEYING_MATERIAL */ /* TLS handshake authentication (--tls-auth) */ if (options->ce.tls_auth_file) diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 80dd0c0..a5eee01 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -1837,7 +1837,6 @@ c->c2.push_request_received =3D true; } -#ifdef HAVE_EXPORT_KEYING_MATERIAL if (proto & IV_PROTO_TLS_KEY_EXPORT) { o->imported_protocol_flags |=3D CO_USE_TLS_KEY_MATERIAL_EXPORT; @@ -1856,7 +1855,6 @@ { o->imported_protocol_flags |=3D CO_USE_DYNAMIC_TLS_CRYPT; } -#endif if (proto & IV_PROTO_CC_EXIT_NOTIFY) { diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 6672b5c..831eeb0 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -664,10 +664,8 @@ #endif "--x509-track x : Save peer X509 attribute x in environment for use b= y\n" " plugins and management interface.\n" -#ifdef HAVE_EXPORT_KEYING_MATERIAL "--keying-material-exporter label len : Save Exported Keying Material = (RFC5705)\n" " of len bytes (min. 16 bytes) using label in environ= ment for use by plugins.\n" -#endif "--remote-cert-ku v ... : Require that the peer certificate was signed= with\n" " explicit key usage, you can specify more than one v= alue.\n" " value should be given in hex format.\n" @@ -2394,9 +2392,9 @@ } #define MUST_BE_UNDEF(parm, parm_name) \ - if (options->parm !=3D defaults.parm) { msg(M_USAGE, use_err, parm_nam= e); } + if (options->parm !=3D defaults.parm) { msg(M_USAGE, use_err, parm= _name); } #define MUST_BE_FALSE(condition, parm_name) \ - if (condition) { msg(M_USAGE, use_err, parm_name); } + if (condition) { msg(M_USAGE, use_err, parm_name); } static void options_postprocess_verify_ce(const struct options *options, @@ -2644,7 +2642,7 @@ const char use_err[] =3D "--%s cannot be used with --mode server."; #define USAGE_VALID_SERVER_PROTOS "--mode server currently only supports "= \ - "--proto values of udp, tcp-server, tcp4-server, or tcp6-server" + "--proto values of udp, tcp-server, tcp4-server, or tcp6-server" #ifdef TARGET_ANDROID msg(M_FATAL, "--mode server not supported on Android"); #endif @@ -3594,10 +3592,6 @@ "calculation anymore or your security policy (e.g. FIPS 140-2)= " "forbids it. Connections will only work with peers running " "OpenVPN 2.6.0 or higher)"); -#ifndef HAVE_EXPORT_KEYING_MATERIAL - msg(M_FATAL, "Keying Material Exporters (RFC 5705) not available e= ither. " - "No way to generate data channel keys left."); -#endif if (o->mode =3D=3D MODE_SERVER) { msg(M_WARN, "Automatically enabling option " @@ -5499,11 +5493,11 @@ } #define VERIFY_PERMISSION(mask) { = \ - if (!verify_permission(p[0], file, line, (mask), permission_mask, = \ - option_types_found, msglevel, options, is_i= nline)) \ - { = \ - goto err; = \ - } = \ + if (!verify_permission(p[0], file, line, (mask), permission_ma= sk, \ + option_types_found, msglevel, options, = is_inline)) \ + { = \ + goto err; = \ + } = \ } static bool @@ -8663,13 +8657,11 @@ /* NCP only option that is pushed by the server to enable EKM, * should not be used by normal users in config files*/ VERIFY_PERMISSION(OPT_P_NCP) -#ifdef HAVE_EXPORT_KEYING_MATERIAL if (streq(p[1], "tls-ekm")) { options->imported_protocol_flags |=3D CO_USE_TLS_KEY_MATERIAL_= EXPORT; } else -#endif { msg(msglevel, "Unknown key-derivation method %s", p[1]); } @@ -8686,7 +8678,6 @@ { options->imported_protocol_flags |=3D CO_USE_CC_EXIT_NOTIF= Y; } -#ifdef HAVE_EXPORT_KEYING_MATERIAL else if (streq(p[j], "tls-ekm")) { options->imported_protocol_flags |=3D CO_USE_TLS_KEY_MATER= IAL_EXPORT; @@ -8695,7 +8686,6 @@ { options->imported_protocol_flags |=3D CO_USE_DYNAMIC_TLS_C= RYPT; } -#endif else if (streq(p[j], "aead-epoch")) { options->imported_protocol_flags |=3D CO_EPOCH_DATA_KEY_FO= RMAT; @@ -9452,7 +9442,6 @@ options->use_peer_id =3D true; options->peer_id =3D atoi_warn(p[1], msglevel); } -#ifdef HAVE_EXPORT_KEYING_MATERIAL else if (streq(p[0], "keying-material-exporter") && p[1] && p[2]) { int ekm_length =3D positive_atoi(p[2], msglevel); @@ -9479,7 +9468,6 @@ options->keying_material_exporter_label =3D p[1]; options->keying_material_exporter_length =3D ekm_length; } -#endif /* HAVE_EXPORT_KEYING_MATERIAL */ else if (streq(p[0], "allow-recursive-routing") && !p[1]) { VERIFY_PERMISSION(OPT_P_GENERAL); diff --git a/src/openvpn/options.h b/src/openvpn/options.h index 8d1ef6c..b0b8d96 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -701,11 +701,9 @@ bool use_peer_id; uint32_t peer_id; -#ifdef HAVE_EXPORT_KEYING_MATERIAL /* Keying Material Exporters [RFC 5705] */ const char *keying_material_exporter_label; int keying_material_exporter_length; -#endif /* force using TLS key material export for data channel key generation= */ bool force_key_material_export; diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index fd299ef..5ecf42b 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -2034,10 +2034,8 @@ buf_printf(&out, "IV_CIPHERS=3D%s\n", session->opt->config_ncp_cip= hers); -#ifdef HAVE_EXPORT_KEYING_MATERIAL iv_proto |=3D IV_PROTO_TLS_KEY_EXPORT; iv_proto |=3D IV_PROTO_DYN_TLS_CRYPT; -#endif buf_printf(&out, "IV_PROTO=3D%d\n", iv_proto); diff --git a/src/openvpn/ssl_mbedtls.c b/src/openvpn/ssl_mbedtls.c index ec3135a..6474f80 100644 --- a/src/openvpn/ssl_mbedtls.c +++ b/src/openvpn/ssl_mbedtls.c @@ -174,8 +174,6 @@ return ctx->initialised; } -#ifdef HAVE_EXPORT_KEYING_MATERIAL - #if HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB /* * Key export callback for older versions of mbed TLS, to be used with @@ -254,7 +252,7 @@ cache->tls_prf_type =3D tls_prf_type; } #else /* if HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB */ -#error either HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB or HAVE_MBEDTLS_SSL= _SET_EXPORT_KEYS_CB must be defined when HAVE_EXPORT_KEYING_MATERIAL is def= ined +#error either mbedtls_ssl_conf_export_keys_ext_cb or mbedtls_ssl_set_expor= t_keys_cb must be available in mbed TLS #endif /* HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB */ bool @@ -289,16 +287,6 @@ return false; } } -#else /* ifdef HAVE_EXPORT_KEYING_MATERIAL */ -bool -key_state_export_keying_material(struct tls_session *session, - const char *label, size_t label_size, - void *ekm, size_t ekm_size) -{ - /* Dummy function to avoid ifdefs in the common code */ - return false; -} -#endif /* HAVE_EXPORT_KEYING_MATERIAL */ bool tls_ctx_set_options(struct tls_root_ctx *ctx, unsigned int ssl_flags) diff --git a/src/openvpn/ssl_mbedtls.h b/src/openvpn/ssl_mbedtls.h index ec30bb5..9ebb2ce 100644 --- a/src/openvpn/ssl_mbedtls.h +++ b/src/openvpn/ssl_mbedtls.h @@ -85,7 +85,6 @@ void *sign_ctx; }; -#ifdef HAVE_EXPORT_KEYING_MATERIAL /** struct to cache TLS secrets for keying material exporter (RFC 5705). * The constants (64 and 48) are inherent to TLS version and * the whole keying material export will likely change when they change */ @@ -94,9 +93,6 @@ mbedtls_tls_prf_types tls_prf_type; unsigned char master_secret[48]; }; -#else /* ifdef HAVE_EXPORT_KEYING_MATERIAL */ -struct tls_key_cache { }; -#endif /** * Structure that wraps the TLS context. Contents differ depending on the diff --git a/src/openvpn/ssl_ncp.c b/src/openvpn/ssl_ncp.c index ead91da..a9cd470 100644 --- a/src/openvpn/ssl_ncp.c +++ b/src/openvpn/ssl_ncp.c @@ -446,7 +446,6 @@ session->opt->crypto_flags &=3D ~CO_EPOCH_DATA_KEY_FORMAT; } -#if defined(HAVE_EXPORT_KEYING_MATERIAL) if (iv_proto_peer & IV_PROTO_TLS_KEY_EXPORT) { session->opt->crypto_flags |=3D CO_USE_TLS_KEY_MATERIAL_EXPORT; @@ -479,7 +478,6 @@ { session->opt->crypto_flags |=3D CO_USE_DYNAMIC_TLS_CRYPT; } -#endif /* if defined(HAVE_EXPORT_KEYING_MATERIAL) */ } void -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1043?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Icbfffae877f8eca8d94721a4d54e140c50d4a550 Gerrit-Change-Number: 1043 Gerrit-PatchSet: 1 Gerrit-Owner: MaxF Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --R5Zf2t9krFg= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

MaxF would like plaisthos and flichtenheld to review th= is change.

V= iew Change

Remove HAVE_EXPORT_KEYING_MATERIAL macro

This was alw= ays defined in all supported versions of OpenSSL and
WolfSSL. EKM should= be available in supported mbed TLS versions, too.

This commit inclu= des some style changes required by uncrustify.

Change-Id: Icbfffae87= 7f8eca8d94721a4d54e140c50d4a550
---
M config.h.cmake.in
M configur= e.ac
M src/openvpn/init.c
M src/openvpn/multi.c
M src/openvpn/opti= ons.c
M src/openvpn/options.h
M src/openvpn/ssl.c
M src/openvpn/ss= l_mbedtls.c
M src/openvpn/ssl_mbedtls.h
M src/openvpn/ssl_ncp.c
10= files changed, 10 insertions(+), 67 deletions(-)

git pull ssh:=
//gerrit.openvpn.net:29418/openvpn refs/changes/43/1043/1
diff --=
git a/config.h.cmake.in b/config.h.cmake.in
index 5164ce3..= 5df0ac8 100644
--- a/config.h.cmake.in
+++ = b/config.h.cmake.in
@@ -120,9 +120,6 @@
/*= Define to 1 if you have the <err.h> header file. */
= #cmakedefine HAVE_ERR_H

-/* Crypto library supports keying material exporter */=
-#define HAVE_EXPORT_K= EYING_MATERIAL 1
-
/* Define to 1 if you have the <fcntl.h> header file. */=
#cmakedefine HAVE_FCNTL_H

diff --git a/configure.ac b/configure.ac

index 75367e8..= 1b908e6 100644
--- a/configure.ac
+++ b/con= figure.ac
@@ -988,10 +988,6 @@
[AC_MSG_E= RROR([OpenSSL check for AES-256-GCM support failed])]
)

- # Al= l supported OpenSSL versions (>=3D 1.1.0)
- # have this feature
- have_export_keying_material=3D"yes"=
-
CFLAGS=3D= "${saved_CFLAGS}"
LIBS=3D"${saved_LIBS}&qu= ot;

@@ -1064,7 +1060,6 @@
[AC_DEFINE([HAVE_MBEDTLS_SSL_TLS_PRF], [0], [no])]

)<= /span>

- hav= e_export_keying_material=3D"yes"
AC_CHECK_FUNC(=
[mbedtls_ssl_conf_export_keys_ext_cb],
= [AC_DEFINE([HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB], [1], [yes])],
@@ -1077,7 +1072,7 @@
[AC_DEFINE([HAVE_MBE= DTLS_SSL_SET_EXPORT_KEYS_CB], [0], [no])]
)
if test "x$ac_cv_func_mbedtls_ssl_set_export_keys_cb" !=3D= xyes; then

- have_ex= port_keying_material=3D"no"
+ AC_MSG_ERROR(This version of mbed TLS has no support f= or exporting key material.)
fi
fi

@@ -1132,17 +1127,12 @@
)
AC_CHECK_HEADER([wolfssl/options.h],,[AC_MSG_ERROR([wolfSS= L header wolfssl/options.h not found!])])

- # wolfSSL signal EKM support
<= br>- have_export_keying_material= =3D"yes"
-
if test "${enable_wolfssl_options_h}" =3D "y= es"; then
AC_DEFINE([EXTERNAL_OPTS_OPENVPN], [1], [= Include options.h from wolfSSL library])
else
<= span> AC_DEFINE([WOLFSSL_USER_SETTINGS], [1], [Use custom user_settings.h= file for wolfSSL library])

fi
- have_export_keying_material= =3D"yes"
-
CFLAGS=3D"${saved_CFLAGS}"
LIBS= =3D"${saved_LIBS}"

@@ -1346,12 = +1336,6 @@
test "${enable_dns_updown_by_default}"= ; =3D "yes" && AC_DEFINE([ENABLE_DNS_UPDOWN_BY_DEFAULT], = [1], [Enable dns-updown hook by default])
test "${ena= ble_ntlm}" =3D "yes" && AC_DEFINE([ENABLE_NTLM], [1]= , [Enable NTLMv2 proxy support])
test "${enable_crypt= o_ofb_cfb}" =3D "yes" && AC_DEFINE([ENABLE_OFB_CFB_M= ODE], [1], [Enable OFB and CFB cipher modes])
-if test "${have_export_keying_material}" = =3D "yes"; then
- AC_DEFINE(
- [HAV= E_EXPORT_KEYING_MATERIAL], [1],
- [Crypto library supports keying material exporter]
- )

-fi
OPTIONAL_CRYPTO_CFLAGS=3D"${= OPTIONAL_CRYPTO_CFLAGS} ${CRYPTO_CFLAGS}"
OPTIONAL_CR= YPTO_LIBS=3D"${OPTIONAL_CRYPTO_LIBS} ${CRYPTO_LIBS}"

diff --git a/src/openvpn/init.c b/src/openvpn/init.c<= /span>
index e0ba255..15eacab 100644
--- a/src/ope= nvpn/init.c
+++ b/src/openvpn/init.c
@@ -34= 83,7 +3483,6 @@
to.comp_options =3D options->comp;<= /span>
#endif

-#ifdef HAVE_EXPORT_KEYING_MATERIAL
= if (options->keying_material_exporter_label)
{
to.ekm_size =3D options->keying_material_exporter_= length;
@@ -3499,7 +3498,6 @@
{=
to.ekm_size =3D 0;
}
-#endif /* HAVE_EXPORT_KEYING_MATERIA= L */


/* TLS handshake authentication= (--tls-auth) */
if (options->ce.tls_auth_file)
diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c<= br>index 80dd0c0..a5eee01 100644
--- a/src/openvpn/mu= lti.c
+++ b/src/openvpn/multi.c
@@ -1837,7 = +1837,6 @@
c->c2.push_request_received =3D true= ;
}

-#ifdef HAVE_EXPORT_KEYING_MATERIAL
= if (proto & IV_PROTO_TLS_KEY_EXPORT)
{ o->imported_protocol_flags |=3D CO_USE_TLS_KEY_MATERIAL_= EXPORT;
@@ -1856,7 +1855,6 @@
{=
o->imported_protocol_flags |=3D CO_USE_DYNAMIC_TLS_CR= YPT;
}
-#endif

if (proto & IV_PROT= O_CC_EXIT_NOTIFY)
{
diff --git a/src/o= penvpn/options.c b/src/openvpn/options.c
index 6672b5c..831= eeb0 100644
--- a/src/openvpn/options.c
+++= b/src/openvpn/options.c
@@ -664,10 +664,8 @@
#endif

"--x509-track x : Save peer X509 attr= ibute x in environment for use by\n"
" = plugins and management interface.\n"
-#ifdef HAVE_EXPORT_KEYING_MATERIAL "--keying-material-exporter label len : Save Exported Key= ing Material (RFC5705)\n"
" = of len bytes (min. 16 bytes) using label in environment for use by plugins= .\n"
-#endif
"--remote-cert-ku v ... : Require that the peer certif= icate was signed with\n"
" = explicit key usage, you can specify more than one value.\n"
= " value should be given in hex format.\n&q= uot;
@@ -2394,9 +2392,9 @@
}

#define MUST_BE_UNDEF(parm, parm_name) \
- if (options->parm !=3D defa= ults.parm) { msg(M_USAGE, use_err, parm_name); }

+ if (options->parm !=3D defaults.par= m) { msg(M_USAGE, use_err, parm_name); }
#define MUST_BE_F= ALSE(condition, parm_name) \
- if (condition) { msg(M_USAGE, use_err, parm_name); }
<= span style=3D"color: hsl(120, 100%, 40%);">+ if (condition) { msg(M_= USAGE, use_err, parm_name); }


static voi= d
options_postprocess_verify_ce(const struct options *opti= ons,
@@ -2644,7 +2642,7 @@
const c= har use_err[] =3D "--%s cannot be used with --mode server.";

#define USAGE_VALID_SERVER_PROTOS "--mo= de server currently only supports " \
- "--proto values of udp, tcp-server, tcp4-serv= er, or tcp6-server"
+ "--proto values of udp, tcp-server, tcp4-server, or tcp6-= server"
#ifdef TARGET_ANDROID
= msg(M_FATAL, "--mode server not supported on Android");<= br> #endif
@@ -3594,10 +3592,6 @@
= "calculation anymore or your security policy (e.g. FIPS 140-= 2) "
"forbids it. Connections will o= nly work with peers running "
"OpenV= PN 2.6.0 or higher)");
-#ifndef HAVE_EXPORT_KEYING_MATERIAL
- msg(M_FATAL, "Keying Material Exporters (R= FC 5705) not available either. "
- "No way to generate data channel keys left= .");
-#endif
if (o->mode =3D=3D MODE_SERVER)
= {
msg(M_WARN, "Automatically enablin= g option "
@@ -5499,11 +5493,11 @@
}<= /span>

#define VERIFY_PERMISSION(mask) { = \
- if (!verify_permission(p[0], file, line, (mask), p= ermission_mask, \
- { = \
- goto err; = \
- } = \
+ if (!verify_permission(p[0], file, lin= e, (mask), permission_mask, \
+ option_types_found, msg= level, options, is_inline)) \
+ { = \
+ goto err; = \
+ = } = \
}

static bool
@@ -8663,13 +8657,11 @@
/* NCP only o= ption that is pushed by the server to enable EKM,
= * should not be used by normal users in config files*/
= VERIFY_PERMISSION(OPT_P_NCP)
-#ifdef HAVE_EXPORT_KEYING_MATERIAL
if= (streq(p[1], "tls-ekm"))
{
options->imported_protocol_flags |=3D CO_USE_TLS_KEY_MA= TERIAL_EXPORT;

}
else
-#endif
= {
msg(msglevel, "Unknown key-deriv= ation method %s", p[1]);
}
@@= -8686,7 +8678,6 @@
{
= options->imported_protocol_flags |=3D CO_USE_CC_EXIT_NOTIFY;
}
-#ifdef HAVE_EXPORT_KEYING_MATERIAL
else= if (streq(p[j], "tls-ekm"))
{
options->imported_protocol_flags |=3D CO_USE= _TLS_KEY_MATERIAL_EXPORT;
@@ -8695,7 +8686,6 @@
<= span> {

options->imported_p= rotocol_flags |=3D CO_USE_DYNAMIC_TLS_CRYPT;
}=
-#endif
else if (streq(p[j], "aead-epoch"))

{

options->imported_prot= ocol_flags |=3D CO_EPOCH_DATA_KEY_FORMAT;
@@ -9452,7 +9442,= 6 @@
options->use_peer_id =3D true;
<= span> options->peer_id =3D atoi_warn(p[1], msglevel);

= }
-#ifdef HA= VE_EXPORT_KEYING_MATERIAL
else if (streq(p[0], "k= eying-material-exporter") && p[1] && p[2])
<= span> {

int ekm_length =3D positive_atoi(p[2],= msglevel);
@@ -9479,7 +9468,6 @@
= options->keying_material_exporter_label =3D p[1];
= options->keying_material_exporter_length =3D ekm_length;
}

-#endif /* H= AVE_EXPORT_KEYING_MATERIAL */
else if (streq(p[0], &qu= ot;allow-recursive-routing") && !p[1])
{<= /span>
VERIFY_PERMISSION(OPT_P_GENERAL);
= diff --git a/src/openvpn/options.h b/src/openvpn/options.h
= index 8d1ef6c..b0b8d96 100644
--- a/src/openvpn/options.h
+++ b/src/openvpn/options.h
@@ -701,11 +701,= 9 @@
bool use_peer_id;
uint32_t p= eer_id;

-#ifdef HAVE_EXPORT_KEYING_MATERIAL
/* Keying Mater= ial Exporters [RFC 5705] */
const char *keying_materia= l_exporter_label;
int keying_material_exporter_length;=
-#endif
/* force using TLS key material export for data channel key generati= on */

bool force_key_material_export;
=
diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c=
index fd299ef..5ecf42b 100644
--- a/src/openvpn/s= sl.c
+++ b/src/openvpn/ssl.c
@@ -2034,10 +2= 034,8 @@

buf_printf(&out, &q= uot;IV_CIPHERS=3D%s\n", session->opt->config_ncp_ciphers);

-#ifdef HA= VE_EXPORT_KEYING_MATERIAL
iv_proto |=3D IV_PROTO_T= LS_KEY_EXPORT;
iv_proto |=3D IV_PROTO_DYN_TLS_CRYP= T;
-#endif

buf_printf(&out, "IV_PROTO=3D%d\n&q= uot;, iv_proto);

diff --git a/src/openvpn= /ssl_mbedtls.c b/src/openvpn/ssl_mbedtls.c
index ec3135a..6= 474f80 100644
--- a/src/openvpn/ssl_mbedtls.c
+++ b/src/openvpn/ssl_mbedtls.c

@@ -174,8 +174,6 @@
return ctx->initialised;
}
<= span>

-#ifdef HAVE_EXP= ORT_KEYING_MATERIAL
-
#if HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB
/*

* Key export callback for older versions of mbed TL= S, to be used with
@@ -254,7 +252,7 @@
= cache->tls_prf_type =3D tls_prf_type;
}
#else /* if HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB */

-#error either HAVE_MBEDTLS_SSL_CONF_E= XPORT_KEYS_EXT_CB or HAVE_MBEDTLS_SSL_SET_EXPORT_KEYS_CB must be defined wh= en HAVE_EXPORT_KEYING_MATERIAL is defined

+#error either mbedtls_ssl_conf_export_keys_ext_cb or = mbedtls_ssl_set_export_keys_cb must be available in mbed TLS
#endif /* HAVE_MBEDTLS_SSL_CONF_EXPORT_KEYS_EXT_CB */
<= /span>
bool
@@ -289,16 +287,6 @@
= return false;
}
}
= -#else /* ifdef HAVE_EXPORT_KEYI= NG_MATERIAL */
-bool
-key_state_export_keying_= material(struct tls_session *session,
- const char *label, size_t = label_size,
- = void *ekm, size_t ekm_size)
-{
- /* Dummy function to avoid ifdefs in the common code */=
- return false;
= -}
-#endif /* HAVE_EXPORT_KEYING_MATERIAL */
<= span>

bool
tls_ctx_set_options(struct tl= s_root_ctx *ctx, unsigned int ssl_flags)
diff --git a/src/o= penvpn/ssl_mbedtls.h b/src/openvpn/ssl_mbedtls.h
index ec30= bb5..9ebb2ce 100644
--- a/src/openvpn/ssl_mbedtls.h<= br>+++ b/src/openvpn/ssl_mbedtls.h
@@ -85,7 +85,6 @@<= /span>
void *sign_ctx;
};
<= /span>
-#ifdef HAVE_EXPORT_KEY= ING_MATERIAL
/** struct to cache TLS secrets for keying ma= terial exporter (RFC 5705).
* The constants (64 and 48) a= re inherent to TLS version and
* the whole keying materia= l export will likely change when they change */
@@ -94,9 +9= 3,6 @@
mbedtls_tls_prf_types tls_prf_type;
<= span> unsigned char master_secret[48];

};
-#else /* ifdef HAVE_EXPORT_KEYING= _MATERIAL */

-struct tl= s_key_cache { };
-#endi= f

/**
* Structure that= wraps the TLS context. Contents differ depending on the
di= ff --git a/src/openvpn/ssl_ncp.c b/src/openvpn/ssl_ncp.c
in= dex ead91da..a9cd470 100644
--- a/src/openvpn/ssl_ncp.c
+++ b/src/openvpn/ssl_ncp.c
@@ -446,7 +446,6 @= @
session->opt->crypto_flags &=3D ~CO_EP= OCH_DATA_KEY_FORMAT;
}

-#if defined(HAVE_EXPORT_KEYING_MATE= RIAL)

if (iv_proto_peer & IV_PROTO_TLS_KEY_EXPORT)=
{
session->opt->crypto= _flags |=3D CO_USE_TLS_KEY_MATERIAL_EXPORT;
@@ -479,7 +478,= 6 @@
{
session->opt->cr= ypto_flags |=3D CO_USE_DYNAMIC_TLS_CRYPT;
}
= -#endif /* if defined(HAVE_EXPORT= _KEYING_MATERIAL) */
}

= void

To view, visit change 1043. To unsubsc= ribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icbfffae877f8eca8d94721a4d54= e140c50d4a550
Gerrit-Change-Number: 1043
Gerrit-PatchSet: 1
Gerrit-Owner: MaxF <max@...2606...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--R5Zf2t9krFg=--