Only announce IV_NCP=2 when we are willing to support these ciphers
PATCH 1/1 Only announce IV_NCP=2 when we are willing to support these ciphers
We currently always announce IV_NCP=2 when we support these ciphers even when we do not accept them. This lead to a server pushing a AES-GCM-128 cipher to clients and the client then rejecting it.
--- src/openvpn/init.c | 1 + src/openvpn/openvpn.h | 1 + src/openvpn/options.c | 7 +++++++ src/openvpn/ssl.c | 4 +++- src/openvpn/ssl_common.h | 1 + 5 files changed, 13 insertions(+), 1 deletion(-)
src/openvpn/init.c +1 -0
@@ -2795,6 +2795,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.tcp_mode =link_socket_proto_connection_oriented (options->ce.proto); to.config_ciphername = c->c1.ciphername; to.config_authname = c->c1.authname; + to.config_ncp_ciphers = c->c1.ncp_ciphers; to.ncp_enabled = options->ncp_enabled; to.transition_window = options->transition_window; to.handshake_window = options->handshake_window;
src/openvpn/openvpn.h +1 -0
@@ -208,6 +208,7 @@ struct context_1const char *ciphername;/**< Data channel cipher from config file */ const char *authname;/**< Data channel auth from config file */ +const char *ncp_ciphers;/**< NCP Ciphers */ int keysize;/**< Data channel keysize from config file */ #endif };
src/openvpn/options.c +7 -0
@@ -7687,6 +7687,13 @@ add_option(struct options *options, {VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_INSTANCE ); options->ncp_ciphers = p[1 ]; + +if (!(tls_item_in_cipher_list ("AES-128-GCM" , options->ncp_ciphers) + &&tls_item_in_cipher_list ("AES-256-GCM" , options->ncp_ciphers))) + { +msg (M_INFO ,"Not including AES-128-GCM and AES-256-GCM in ncp-ciphers " +"disables announcing NCP support with IV_NCP=2" ); + } } else if (streq(p[0], "ncp-disable") && !p[1]) {
src/openvpn/ssl.c +3 -1
@@ -2327,7 +2327,9 @@ push_peer_info(struct buffer *buf, struct tls_session *session)/* support for Negotiable Crypto Parameters */ if (session->opt->ncp_enabled - && (session->opt->mode ==MODE_SERVER || session->opt->pull)) + && (session->opt->mode ==MODE_SERVER || session->opt->pull) + &&tls_item_in_cipher_list ("AES-128-GCM" , session->opt->config_ncp_ciphers) + &&tls_item_in_cipher_list ("AES-256-GCM" , session->opt->config_ncp_ciphers)) {buf_printf (&out,"IV_NCP=2\n" ); }
src/openvpn/ssl_common.h +1 -0
@@ -290,6 +290,7 @@ struct tls_optionsconst char *config_ciphername;const char *config_authname; +const char *config_ncp_ciphers;bool ncp_enabled;bool tls_crypt_v2;
Signature · 1 line
2.22.0
Hi,
Quoted 16 lines · Arne Schwabe
We currently always announce IV_NCP=2 when we support these ciphers even when we do not accept them. This lead to a server pushing a AES-GCM-128 cipher to clients and the client then rejecting it.
--- src/openvpn/init.c | 1 + src/openvpn/openvpn.h | 1 + src/openvpn/options.c | 7 +++++++ src/openvpn/ssl.c | 4 +++- src/openvpn/ssl_common.h | 1 + 5 files changed, 13 insertions(+), 1 deletion(-)src/openvpn/init.c +0
-0
src/openvpn/init.c do_init_crypto_tls(struct context *c, const unsigned int flags) · line 2798
Quoted 4 lines
src/openvpn/init.c +1
-0@@ -2795,6 +2795,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.tcp_mode =link_socket_proto_connection_oriented (options->ce.proto); to.config_ciphername = c->c1.ciphername; to.config_authname = c->c1.authname; + to.config_ncp_ciphers = c->c1.ncp_ciphers;
I can't find where config_ncp_ciphers is used and I can't find where ncp_ciphers is set...something is missing?
Quoted 20 lines
src/openvpn/init.c +0
-0to.ncp_enabled = options->ncp_enabled; to.transition_window = options->transition_window; to.handshake_window = options->handshake_window;src/openvpn/openvpn.h +1
-0@@ -208,6 +208,7 @@ struct context_1const char *ciphername;/**< Data channel cipher from config file */ const char *authname;/**< Data channel auth from config file */ +const char *ncp_ciphers;/**< NCP Ciphers */ int keysize;/**< Data channel keysize from config file */ #endif };src/openvpn/options.c +0
-0
src/openvpn/options.c add_option(struct options *options, · line 7696
Quoted 10 lines
src/openvpn/options.c +7
-0@@ -7687,6 +7687,13 @@ add_option(struct options *options, {VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_INSTANCE ); options->ncp_ciphers = p[1 ]; + +if (!(tls_item_in_cipher_list ("AES-128-GCM" , options->ncp_ciphers) + &&tls_item_in_cipher_list ("AES-256-GCM" , options->ncp_ciphers))) + { +msg (M_INFO ,"Not including AES-128-GCM and AES-256-GCM in ncp-ciphers " +"disables announcing NCP support with IV_NCP=2" ); + }
The condition and the text message are not agreeing with each other.
How about making the if condition easier to read by applying De Morgan's law:
if (!tls_item_in_cipher_list("AES-128-GCM", options->ncp_ciphers)
|| !tls_item_in_cipher_list("AES-256-GCM", options->ncp_ciphers)))This reads to me as: "Not enabling AES-128 or AES-256 disables NCP" (Which I think is what you wanted to express in the debug message?)
What do you think?
Quoted 24 lines
src/openvpn/options.c +0
-0}else if (streq (p[0 ],"ncp-disable" ) && !p[1 ]) {src/openvpn/ssl.c +3
-1@@ -2327,7 +2327,9 @@ push_peer_info(struct buffer *buf, struct tls_session *session)/* support for Negotiable Crypto Parameters */ if (session->opt->ncp_enabled - && (session->opt->mode ==MODE_SERVER || session->opt->pull)) + && (session->opt->mode ==MODE_SERVER || session->opt->pull) + &&tls_item_in_cipher_list ("AES-128-GCM" , session->opt->config_ncp_ciphers) + &&tls_item_in_cipher_list ("AES-256-GCM" , session->opt->config_ncp_ciphers)) {buf_printf (&out,"IV_NCP=2\n" ); }src/openvpn/ssl_common.h +0
-0
src/openvpn/ssl_common.h struct tls_options · line 296
Quoted 7 lines
src/openvpn/ssl_common.h +1
-0@@ -290,6 +290,7 @@ struct tls_optionsconst char *config_ciphername;const char *config_authname; +const char *config_ncp_ciphers;bool ncp_enabled;bool tls_crypt_v2;
Cheers,
Signature · 1 line
Antonio Quartulli
Hi,
src/openvpn/options.c add_option(struct options *options, · line 7692
Quoted 2 lines · Arne Schwabe
src/openvpn/options.c +2
-0+if (!(tls_item_in_cipher_list ("AES-128-GCM" , options->ncp_ciphers) + &&tls_item_in_cipher_list ("AES-256-GCM" , options->ncp_ciphers)))
What about AES-192-GCM? What *exactly* does IV_NCP=2 guarantee?
Can we have something nicer for cipher negotiation instead?
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]...Am 23.09.19 um 16:34 schrieb Gert Doering:
Quoted 8 lines
Hi,
src/openvpn/options.c add_option(struct options *options, · line 7692
Quoted 2 lines · Arne Schwabe
src/openvpn/options.c +2
-0+if (!(tls_item_in_cipher_list ("AES-128-GCM" , options->ncp_ciphers) + &&tls_item_in_cipher_list ("AES-256-GCM" , options->ncp_ciphers)))What about AES-192-GCM? What *exactly* does IV_NCP=2 guarantee?
Our manpage says only 128 and 256 are in the default ncp-cihper list, so lets not guarantee 192.
Arne