Deprecate ncp-disable and add improved ncp to Changes.rst
PATCH 1/8 Deprecate ncp-disable and add improved ncp to Changes.rst
--- Changes.rst | 18 ++++++++++++++++++ src/openvpn/options.c | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-)
Changes.rst +18 -0
@@ -13,6 +13,24 @@ ChaCha20-Poly1305 cipher support Added support for using the ChaCha20-Poly1305 cipher in the OpenVPN data channel. +Improved Data channel cipher negotiation + OpenVPN clients will now signal all supported cipher from the + ``ncp-ciphers`` option to the server via ``IV_CIPHERS``. OpenVPN + servers will select the first common cipher from the ``ncp-ciphers`` + list instead of blindly pushing the first cipher of the list. This + allows to use a configuration like + ``ncp-ciphers ChaCha20-Poly1305:AES-256-GCM`` on the server that + prefers ChaCha20-Poly1305 but uses it only if the client supports it. + +Deprecated features +------------------- +For an up-to-date list of all deprecated options, see this wiki page: +https://community.openvpn.net/openvpn/wiki/DeprecatedOptions + +- ``ncp-disable`` has been deprecated + With the improved and matured data channel cipher negioation, the use + of ``ncp-disable`` should not be necessary anymore. + Overview of changes in 2.4 ==========================
src/openvpn/options.c +4 -1
@@ -545,7 +545,7 @@ static const char usage_message[] =" (default=%s).\n" " Set alg=none to disable encryption.\n" "--ncp-ciphers list : List of ciphers that are allowed to be negotiated.\n" -"--ncp-disable : Disable cipher negotiation.\n" +"--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
@@ -7904,6 +7904,9 @@ add_option(struct options *options, {VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_INSTANCE ); options->ncp_enabled = false; +msg (M_WARN ,"DEPRECATED OPTION: ncp-disable. Disabling dynamic " +"cipher negioating is a depracted debug feature that will " +"be removed in OpenVPN 2.6" ); } else if (streq(p[0], "prng") && p[1] && !p[3]) {
Signature · 1 line
2.26.2
PATCH 2/8 Make key_state->authenticated more state machine like
This order the states from unauthenticated to authenticated and also changes the comparison for KS_AUTH_FALSE from != to >
It also add comments and documents part using the state machine better.
Remove a now obsolete comment and two obsolete ifdefs. While keeping the ifdef in ssl_verify would save a few bytes of code, this is too minor to justify keeping the ifdef
--- src/openvpn/multi.c | 12 +++++++++--- src/openvpn/ssl.c | 7 ++++--- src/openvpn/ssl_common.h | 22 ++++++++++++++++------ src/openvpn/ssl_verify.c | 18 +++++++----------- 4 files changed, 36 insertions(+), 23 deletions(-)
src/openvpn/multi.c +9 -3
@@ -2352,12 +2352,12 @@ multi_process_post(struct multi_context *m, struct multi_instance *mi, const unsif (!IS_SIG (&mi->context) && ((flags &MPP_PRE_SELECT ) || ((flags &MPP_CONDITIONAL_PRE_SELECT ) && !ANY_OUT (&mi->context)))) {#if defined(ENABLE_ASYNC_PUSH ) && defined(ENABLE_DEF_AUTH ) -bool was_authenticated = false; +bool was_unauthenticated = true;struct key_state *ks =NULL ;if (mi->context.c2.tls_multi) { ks = &mi->context.c2.tls_multi->session[TM_ACTIVE ].key[KS_PRIMARY ]; - was_authenticated = ks->authenticated; + was_unauthenticated = (ks->authenticated ==KS_AUTH_FALSE ); }#endif
@@ -2366,7 +2366,13 @@ multi_process_post(struct multi_context *m, struct multi_instance *mi, const unspre_select (&mi->context);#if defined(ENABLE_ASYNC_PUSH ) && defined(ENABLE_DEF_AUTH ) -if (ks && ks->auth_control_file && ks->auth_deferred && !was_authenticated) +/* +* if we see the state transition from unauthenticated to deferred +* and a auth_control_file, we assume it got just added and add +* inotify watch to that file +*/ +if (ks && ks->auth_control_file && was_unauthenticated + && (ks->authenticated ==KS_AUTH_DEFERRED )) {/* watch acf file */ long watch_descriptor =inotify_add_watch (m->top.c2.inotify_fd, ks->auth_control_file,IN_CLOSE_WRITE |IN_ONESHOT );
src/openvpn/ssl.c +4 -3
@@ -2466,7 +2466,7 @@ key_method_2_write(struct buffer *buf, struct tls_session *session)if (session->opt->server && !(session->opt->ncp_enabled && session->opt->mode ==MODE_SERVER && ks->key_id <=0 )) { -if (ks->authenticated !=KS_AUTH_FALSE ) +if (ks->authenticated >KS_AUTH_FALSE ) {if (!tls_session_generate_data_channel_keys (session)) {
@@ -2659,7 +2659,7 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessiosecure_memzero (up,sizeof (*up));/* Perform final authentication checks */ -if (ks->authenticated !=KS_AUTH_FALSE ) +if (ks->authenticated >KS_AUTH_FALSE ) {verify_final_auth_checks (multi, session); }
@@ -2684,7 +2684,7 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessio* Call OPENVPN_PLUGIN_TLS_FINAL plugin if defined, for final * veto opportunity over authentication decision. */ -if ((ks->authenticated !=KS_AUTH_FALSE ) +if ((ks->authenticated >KS_AUTH_FALSE ) &&plugin_defined (session->opt->plugins,OPENVPN_PLUGIN_TLS_FINAL )) {key_state_export_keying_material (&ks->ks_ssl, session);
@@ -2715,6 +2715,7 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessioreturn true; error: + ks->authenticated =KS_AUTH_FALSE ;secure_memzero (ks->key_src,sizeof (*ks->key_src));if (up) {
src/openvpn/ssl_common.h +16 -6
@@ -127,10 +127,23 @@ struct key_source2 {struct key_source server;/**< Random provided by server. */ }; + +/** +* This refelects the (server side) state auf authentication after the TLS +* session has been established and key_method_2_read is called. If async auth +* is enabled the state will first move to KS_AUTH_DEFERRED before eventually +* being set to KS_AUTH_TRUE or KS_AUTH_FALSE +* Only KS_AUTH_TRUE is fully authenticated +*/ enum ks_auth_state { -KS_AUTH_FALSE , -KS_AUTH_TRUE , -KS_AUTH_DEFERRED +KS_AUTH_FALSE ,/**< Key state is not authenticated */ +KS_AUTH_DEFERRED ,/**< Key state authentication is being deferred, +* by async auth */ +KS_AUTH_TRUE /**< Key state is authenticated. TLS and user/pass +* succeeded. This include AUTH_PENDING/OOB +* authentication as those hold the +* connection artifically in KS_AUTH_DEFERRED +*/ };/**
@@ -194,8 +207,6 @@ struct key_stateenum ks_auth_state authenticated;time_t auth_deferred_expire; -#ifdef ENABLE_DEF_AUTH -/* If auth_deferred is true, authentication is being deferred */ #ifdef MANAGEMENT_DEF_AUTH unsigned int mda_key_id;unsigned int mda_status;
@@ -205,7 +216,6 @@ struct key_statetime_t acf_last_mod;char *auth_control_file;#endif -#endif };/** Control channel wrapping (--tls-auth/--tls-crypt) context */
src/openvpn/ssl_verify.c +7 -11
@@ -950,7 +950,7 @@ tls_authentication_status(struct tls_multi *multi, const int latency)if (DECRYPT_KEY_ENABLED (multi, ks)) { active = true; -if (ks->authenticated !=KS_AUTH_FALSE ) +if (ks->authenticated >KS_AUTH_FALSE ) {#ifdef ENABLE_DEF_AUTH unsigned int s1 =ACF_DISABLED ;
@@ -1249,6 +1249,9 @@ verify_user_pass_management(struct tls_session *session,/* * Main username/password verification entry point +* +* Will set session->ks[KS_PRIMARY].authenticated according to +* result of the username/password verifcation */ void verify_user_pass(struct user_pass *up, struct tls_multi *multi,
@@ -1414,17 +1417,10 @@ verify_user_pass(struct user_pass *up, struct tls_multi *multi,*/ send_push_reply_auth_token (multi); } -#ifdef ENABLE_DEF_AUTH msg (D_HANDSHAKE ,"TLS: Username/Password authentication %s for username '%s' %s" , (ks->authenticated ==KS_AUTH_DEFERRED ) ?"deferred" :"succeeded" , up->username, (session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) ?"[CN SET]" :"" ); -#else -msg (D_HANDSHAKE ,"TLS: Username/Password authentication %s for username '%s' %s" , -"succeeded" , - up->username, - (session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) ?"[CN SET]" :"" ); -#endif }else {
@@ -1445,7 +1441,7 @@ verify_final_auth_checks(struct tls_multi *multi, struct tls_session *session) }/* Don't allow the CN to change once it's been locked */ -if (ks->authenticated !=KS_AUTH_FALSE && multi->locked_cn) +if (ks->authenticated >KS_AUTH_FALSE && multi->locked_cn) {const char *cn = session->common_name;if (cn &&strcmp (cn, multi->locked_cn))
@@ -1461,7 +1457,7 @@ verify_final_auth_checks(struct tls_multi *multi, struct tls_session *session) }/* Don't allow the cert hashes to change once they have been locked */ -if (ks->authenticated !=KS_AUTH_FALSE && multi->locked_cert_hash_set) +if (ks->authenticated >KS_AUTH_FALSE && multi->locked_cert_hash_set) {const struct cert_hash_set *chs = session->cert_hash_set;if (chs && !cert_hash_compare (chs, multi->locked_cert_hash_set))
@@ -1475,7 +1471,7 @@ verify_final_auth_checks(struct tls_multi *multi, struct tls_session *session) }/* verify --client-config-dir based authentication */ -if (ks->authenticated !=KS_AUTH_FALSE && session->opt->client_config_dir_exclusive) +if (ks->authenticated >KS_AUTH_FALSE && session->opt->client_config_dir_exclusive) {struct gc_arena gc =gc_new ();
Signature · 1 line
2.26.2
Re: [Openvpn-devel] [PATCH 2/8] Make key_state->authenticated more state machine like
Typo
Quoted 96 lines · Arne Schwabe
This order the states from unauthenticated to authenticated and also changes the comparison for
KS_AUTH_FALSEfrom != to >It also add comments and documents part using the state machine better.
Remove a now obsolete comment and two obsolete ifdefs. While keeping the ifdef in
ssl_verifywould save a few bytes of code, this is too minor to justify keeping the ifdefSigned-off-by Arne Schwabe <[email protected]...>--- src/openvpn/multi.c | 12 +++++++++--- src/openvpn/ssl.c | 7 ++++--- src/openvpn/ssl_common.h | 22 ++++++++++++++++------ src/openvpn/ssl_verify.c | 18 +++++++----------- 4 files changed, 36 insertions(+), 23 deletions(-)src/openvpn/multi.c +9
-3@@ -2352,12 +2352,12 @@ multi_process_post(struct multi_context *m, struct multi_instance *mi, const unsif (!IS_SIG (&mi->context) && ((flags &MPP_PRE_SELECT ) || ((flags &MPP_CONDITIONAL_PRE_SELECT ) && !ANY_OUT (&mi->context)))) {#if defined(ENABLE_ASYNC_PUSH ) && defined(ENABLE_DEF_AUTH ) -bool was_authenticated = false; +bool was_unauthenticated = true;struct key_state *ks =NULL ;if (mi->context.c2.tls_multi) { ks = &mi->context.c2.tls_multi->session[TM_ACTIVE ].key[KS_PRIMARY ]; - was_authenticated = ks->authenticated; + was_unauthenticated = (ks->authenticated ==KS_AUTH_FALSE ); }#endif @@ -2366,7 +2366,13 @@ multi_process_post(struct multi_context *m, struct multi_instance *mi, const unspre_select (&mi->context);#if defined(ENABLE_ASYNC_PUSH ) && defined(ENABLE_DEF_AUTH ) -if (ks && ks->auth_control_file && ks->auth_deferred && !was_authenticated) +/* +* if we see the state transition from unauthenticated to deferred +* and a auth_control_file, we assume it got just added and add +* inotify watch to that file +*/ +if (ks && ks->auth_control_file && was_unauthenticated + && (ks->authenticated ==KS_AUTH_DEFERRED )) {/* watch acf file */ long watch_descriptor =inotify_add_watch (m->top.c2.inotify_fd, ks->auth_control_file,IN_CLOSE_WRITE |IN_ONESHOT );src/openvpn/ssl.c +4
-3@@ -2466,7 +2466,7 @@ key_method_2_write(struct buffer *buf, struct tls_session *session)if (session->opt->server && !(session->opt->ncp_enabled && session->opt->mode ==MODE_SERVER && ks->key_id <=0 )) { -if (ks->authenticated !=KS_AUTH_FALSE ) +if (ks->authenticated >KS_AUTH_FALSE ) {if (!tls_session_generate_data_channel_keys (session)) {@@ -2659,7 +2659,7 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessiosecure_memzero (up,sizeof (*up));/* Perform final authentication checks */ -if (ks->authenticated !=KS_AUTH_FALSE ) +if (ks->authenticated >KS_AUTH_FALSE ) {verify_final_auth_checks (multi, session); }@@ -2684,7 +2684,7 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessio* Call OPENVPN_PLUGIN_TLS_FINAL plugin if defined, for final * veto opportunity over authentication decision. */ -if ((ks->authenticated !=KS_AUTH_FALSE ) +if ((ks->authenticated >KS_AUTH_FALSE ) &&plugin_defined (session->opt->plugins,OPENVPN_PLUGIN_TLS_FINAL )) {key_state_export_keying_material (&ks->ks_ssl, session);@@ -2715,6 +2715,7 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessioreturn true; error: + ks->authenticated =KS_AUTH_FALSE ;secure_memzero (ks->key_src,sizeof (*ks->key_src));if (up) {src/openvpn/ssl_common.h +0
-0
src/openvpn/ssl_common.h struct key_source2 { · line 132
Quoted 6 lines
src/openvpn/ssl_common.h +3
-0@@ -127,10 +127,23 @@ struct key_source2 {struct key_source server;/**< Random provided by server. */ }; + +/** +* This refelects the (server side) state auf authentication after the TLS
refelects -> reflects
Re: [Openvpn-devel] [PATCH 2/8] Make key_state->authenticated more state machine like
In reply to Arne SchwabeHi,
thanks for bearing with me and for adding the requested comment. I believe the status enum is now easier to grasp and to extend.
Code was basically already reviewed ad this revision did not bring any functional change with it. "It still looks good".
Tested only on the client side and it did not break anything visible (as expected).
Quoted 208 lines · Arne Schwabe
This order the states from unauthenticated to authenticated and also changes the comparison for
KS_AUTH_FALSEfrom != to >It also add comments and documents part using the state machine better.
Remove a now obsolete comment and two obsolete ifdefs. While keeping the ifdef in
ssl_verifywould save a few bytes of code, this is too minor to justify keeping the ifdefSigned-off-by Arne Schwabe <[email protected]...>--- src/openvpn/multi.c | 12 +++++++++--- src/openvpn/ssl.c | 7 ++++--- src/openvpn/ssl_common.h | 22 ++++++++++++++++------ src/openvpn/ssl_verify.c | 18 +++++++----------- 4 files changed, 36 insertions(+), 23 deletions(-)src/openvpn/multi.c +9
-3@@ -2352,12 +2352,12 @@ multi_process_post(struct multi_context *m, struct multi_instance *mi, const unsif (!IS_SIG (&mi->context) && ((flags &MPP_PRE_SELECT ) || ((flags &MPP_CONDITIONAL_PRE_SELECT ) && !ANY_OUT (&mi->context)))) {#if defined(ENABLE_ASYNC_PUSH ) && defined(ENABLE_DEF_AUTH ) -bool was_authenticated = false; +bool was_unauthenticated = true;struct key_state *ks =NULL ;if (mi->context.c2.tls_multi) { ks = &mi->context.c2.tls_multi->session[TM_ACTIVE ].key[KS_PRIMARY ]; - was_authenticated = ks->authenticated; + was_unauthenticated = (ks->authenticated ==KS_AUTH_FALSE ); }#endif @@ -2366,7 +2366,13 @@ multi_process_post(struct multi_context *m, struct multi_instance *mi, const unspre_select (&mi->context);#if defined(ENABLE_ASYNC_PUSH ) && defined(ENABLE_DEF_AUTH ) -if (ks && ks->auth_control_file && ks->auth_deferred && !was_authenticated) +/* +* if we see the state transition from unauthenticated to deferred +* and a auth_control_file, we assume it got just added and add +* inotify watch to that file +*/ +if (ks && ks->auth_control_file && was_unauthenticated + && (ks->authenticated ==KS_AUTH_DEFERRED )) {/* watch acf file */ long watch_descriptor =inotify_add_watch (m->top.c2.inotify_fd, ks->auth_control_file,IN_CLOSE_WRITE |IN_ONESHOT );src/openvpn/ssl.c +4
-3@@ -2466,7 +2466,7 @@ key_method_2_write(struct buffer *buf, struct tls_session *session)if (session->opt->server && !(session->opt->ncp_enabled && session->opt->mode ==MODE_SERVER && ks->key_id <=0 )) { -if (ks->authenticated !=KS_AUTH_FALSE ) +if (ks->authenticated >KS_AUTH_FALSE ) {if (!tls_session_generate_data_channel_keys (session)) {@@ -2659,7 +2659,7 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessiosecure_memzero (up,sizeof (*up));/* Perform final authentication checks */ -if (ks->authenticated !=KS_AUTH_FALSE ) +if (ks->authenticated >KS_AUTH_FALSE ) {verify_final_auth_checks (multi, session); }@@ -2684,7 +2684,7 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessio* Call OPENVPN_PLUGIN_TLS_FINAL plugin if defined, for final * veto opportunity over authentication decision. */ -if ((ks->authenticated !=KS_AUTH_FALSE ) +if ((ks->authenticated >KS_AUTH_FALSE ) &&plugin_defined (session->opt->plugins,OPENVPN_PLUGIN_TLS_FINAL )) {key_state_export_keying_material (&ks->ks_ssl, session);@@ -2715,6 +2715,7 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessioreturn true; error: + ks->authenticated =KS_AUTH_FALSE ;secure_memzero (ks->key_src,sizeof (*ks->key_src));if (up) {src/openvpn/ssl_common.h +16
-6@@ -127,10 +127,23 @@ struct key_source2 {struct key_source server;/**< Random provided by server. */ }; + +/** +* This refelects the (server side) state auf authentication after the TLS +* session has been established and key_method_2_read is called. If async auth +* is enabled the state will first move to KS_AUTH_DEFERRED before eventually +* being set to KS_AUTH_TRUE or KS_AUTH_FALSE +* Only KS_AUTH_TRUE is fully authenticated +*/ enum ks_auth_state { -KS_AUTH_FALSE , -KS_AUTH_TRUE , -KS_AUTH_DEFERRED +KS_AUTH_FALSE ,/**< Key state is not authenticated */ +KS_AUTH_DEFERRED ,/**< Key state authentication is being deferred, +* by async auth */ +KS_AUTH_TRUE /**< Key state is authenticated. TLS and user/pass +* succeeded. This include AUTH_PENDING/OOB +* authentication as those hold the +* connection artifically in KS_AUTH_DEFERRED +*/ };/** @@ -194,8 +207,6 @@ struct key_stateenum ks_auth_state authenticated;time_t auth_deferred_expire; -#ifdef ENABLE_DEF_AUTH -/* If auth_deferred is true, authentication is being deferred */ #ifdef MANAGEMENT_DEF_AUTH unsigned int mda_key_id;unsigned int mda_status;@@ -205,7 +216,6 @@ struct key_statetime_t acf_last_mod;char *auth_control_file;#endif -#endif };/** Control channel wrapping (--tls-auth/--tls-crypt) context */ src/openvpn/ssl_verify.c +7
-11@@ -950,7 +950,7 @@ tls_authentication_status(struct tls_multi *multi, const int latency)if (DECRYPT_KEY_ENABLED (multi, ks)) { active = true; -if (ks->authenticated !=KS_AUTH_FALSE ) +if (ks->authenticated >KS_AUTH_FALSE ) {#ifdef ENABLE_DEF_AUTH unsigned int s1 =ACF_DISABLED ;@@ -1249,6 +1249,9 @@ verify_user_pass_management(struct tls_session *session,/* * Main username/password verification entry point +* +* Will set session->ks[KS_PRIMARY].authenticated according to +* result of the username/password verifcation */ void verify_user_pass(struct user_pass *up, struct tls_multi *multi,@@ -1414,17 +1417,10 @@ verify_user_pass(struct user_pass *up, struct tls_multi *multi,*/ send_push_reply_auth_token (multi); } -#ifdef ENABLE_DEF_AUTH msg (D_HANDSHAKE ,"TLS: Username/Password authentication %s for username '%s' %s" , (ks->authenticated ==KS_AUTH_DEFERRED ) ?"deferred" :"succeeded" , up->username, (session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) ?"[CN SET]" :"" ); -#else -msg (D_HANDSHAKE ,"TLS: Username/Password authentication %s for username '%s' %s" , -"succeeded" , - up->username, - (session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) ?"[CN SET]" :"" ); -#endif }else {@@ -1445,7 +1441,7 @@ verify_final_auth_checks(struct tls_multi *multi, struct tls_session *session) }/* Don't allow the CN to change once it's been locked */ -if (ks->authenticated !=KS_AUTH_FALSE && multi->locked_cn) +if (ks->authenticated >KS_AUTH_FALSE && multi->locked_cn) {const char *cn = session->common_name;if (cn &&strcmp (cn, multi->locked_cn))@@ -1461,7 +1457,7 @@ verify_final_auth_checks(struct tls_multi *multi, struct tls_session *session) }/* Don't allow the cert hashes to change once they have been locked */ -if (ks->authenticated !=KS_AUTH_FALSE && multi->locked_cert_hash_set) +if (ks->authenticated >KS_AUTH_FALSE && multi->locked_cert_hash_set) {const struct cert_hash_set *chs = session->cert_hash_set;if (chs && !cert_hash_compare (chs, multi->locked_cert_hash_set))@@ -1475,7 +1471,7 @@ verify_final_auth_checks(struct tls_multi *multi, struct tls_session *session) }/* verify --client-config-dir based authentication */ -if (ks->authenticated !=KS_AUTH_FALSE && session->opt->client_config_dir_exclusive) +if (ks->authenticated >KS_AUTH_FALSE && session->opt->client_config_dir_exclusive) {struct gc_arena gc =gc_new ();
Signature · 1 line
Antonio Quartulli
Re: [Openvpn-devel] [PATCH 2/8] Make key_state->authenticated more state machine like
In reply to Arne Schwabetypo x3
Quoted 38 lines · Arne Schwabe
This order the states from unauthenticated to authenticated and also changes the comparison for
KS_AUTH_FALSEfrom != to >It also add comments and documents part using the state machine better.
Remove a now obsolete comment and two obsolete ifdefs. While keeping the ifdef in
ssl_verifywould save a few bytes of code, this is too minor to justify keeping the ifdefSigned-off-by Arne Schwabe <[email protected]...>--- src/openvpn/multi.c | 12 +++++++++--- src/openvpn/ssl.c | 7 ++++--- src/openvpn/ssl_common.h | 22 ++++++++++++++++------ src/openvpn/ssl_verify.c | 18 +++++++----------- 4 files changed, 36 insertions(+), 23 deletions(-)src/openvpn/multi.c +2
-2@@ -2352,12 +2352,12 @@ multi_process_post(struct multi_context *m, struct multi_instance *mi, const unsif (!IS_SIG (&mi->context) && ((flags &MPP_PRE_SELECT ) || ((flags &MPP_CONDITIONAL_PRE_SELECT ) && !ANY_OUT (&mi->context)))) {#if defined(ENABLE_ASYNC_PUSH ) && defined(ENABLE_DEF_AUTH ) -bool was_authenticated = false; +bool was_unauthenticated = true;struct key_state *ks =NULL ;if (mi->context.c2.tls_multi) { ks = &mi->context.c2.tls_multi->session[TM_ACTIVE ].key[KS_PRIMARY ]; - was_authenticated = ks->authenticated; + was_unauthenticated = (ks->authenticated ==KS_AUTH_FALSE ); }#endif
src/openvpn/multi.c multi_process_post(struct multi_context *m, struct multi_instance *mi, const uns · line 2371
Quoted 7 lines
src/openvpn/multi.c +3
-1@@ -2366,7 +2366,13 @@ multi_process_post(struct multi_context *m, struct multi_instance *mi, const unspre_select (&mi->context);#if defined(ENABLE_ASYNC_PUSH ) && defined(ENABLE_DEF_AUTH ) -if (ks && ks->auth_control_file && ks->auth_deferred && !was_authenticated) +/* +* if we see the state transition from unauthenticated to deferred +* and a auth_control_file, we assume it got just added and add
and aN auth_control_file
Quoted 63 lines
src/openvpn/multi.c +4
-0+* inotify watch to that file +*/ +if (ks && ks->auth_control_file && was_unauthenticated + && (ks->authenticated ==KS_AUTH_DEFERRED )) {/* watch acf file */ long watch_descriptor =inotify_add_watch (m->top.c2.inotify_fd, ks->auth_control_file,IN_CLOSE_WRITE |IN_ONESHOT );src/openvpn/ssl.c +4
-3@@ -2466,7 +2466,7 @@ key_method_2_write(struct buffer *buf, struct tls_session *session)if (session->opt->server && !(session->opt->ncp_enabled && session->opt->mode ==MODE_SERVER && ks->key_id <=0 )) { -if (ks->authenticated !=KS_AUTH_FALSE ) +if (ks->authenticated >KS_AUTH_FALSE ) {if (!tls_session_generate_data_channel_keys (session)) {@@ -2659,7 +2659,7 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessiosecure_memzero (up,sizeof (*up));/* Perform final authentication checks */ -if (ks->authenticated !=KS_AUTH_FALSE ) +if (ks->authenticated >KS_AUTH_FALSE ) {verify_final_auth_checks (multi, session); }@@ -2684,7 +2684,7 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessio* Call OPENVPN_PLUGIN_TLS_FINAL plugin if defined, for final * veto opportunity over authentication decision. */ -if ((ks->authenticated !=KS_AUTH_FALSE ) +if ((ks->authenticated >KS_AUTH_FALSE ) &&plugin_defined (session->opt->plugins,OPENVPN_PLUGIN_TLS_FINAL )) {key_state_export_keying_material (&ks->ks_ssl, session);@@ -2715,6 +2715,7 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessioreturn true; error: + ks->authenticated =KS_AUTH_FALSE ;secure_memzero (ks->key_src,sizeof (*ks->key_src));if (up) {src/openvpn/ssl_common.h +8
-0@@ -127,10 +127,23 @@ struct key_source2 {struct key_source server;/**< Random provided by server. */ }; + +/** +* This refelects the (server side) state auf authentication after the TLS +* session has been established and key_method_2_read is called. If async auth +* is enabled the state will first move to KS_AUTH_DEFERRED before eventually +* being set to KS_AUTH_TRUE or KS_AUTH_FALSE +* Only KS_AUTH_TRUE is fully authenticated +*/ enum ks_auth_state {
src/openvpn/ssl_common.h struct key_source2 { · line 145
Quoted 10 lines
src/openvpn/ssl_common.h +7
-3-KS_AUTH_FALSE , -KS_AUTH_TRUE , -KS_AUTH_DEFERRED +KS_AUTH_FALSE ,/**< Key state is not authenticated */ +KS_AUTH_DEFERRED ,/**< Key state authentication is being deferred, +* by async auth */ +KS_AUTH_TRUE /**< Key state is authenticated. TLS and user/pass +* succeeded. This include AUTH_PENDING/OOB +* authentication as those hold the +* connection artifically in KS_AUTH_DEFERRED
artifically -> artificially
Quoted 35 lines
src/openvpn/ssl_common.h +1
-3+*/ };/** @@ -194,8 +207,6 @@ struct key_stateenum ks_auth_state authenticated;time_t auth_deferred_expire; -#ifdef ENABLE_DEF_AUTH -/* If auth_deferred is true, authentication is being deferred */ #ifdef MANAGEMENT_DEF_AUTH unsigned int mda_key_id;unsigned int mda_status;@@ -205,7 +216,6 @@ struct key_statetime_t acf_last_mod;char *auth_control_file;#endif -#endif };/** Control channel wrapping (--tls-auth/--tls-crypt) context */ src/openvpn/ssl_verify.c +1
-1@@ -950,7 +950,7 @@ tls_authentication_status(struct tls_multi *multi, const int latency)if (DECRYPT_KEY_ENABLED (multi, ks)) { active = true; -if (ks->authenticated !=KS_AUTH_FALSE ) +if (ks->authenticated >KS_AUTH_FALSE ) {#ifdef ENABLE_DEF_AUTH unsigned int s1 =ACF_DISABLED ;
src/openvpn/ssl_verify.c verify_user_pass_management(struct tls_session *session, · line 1254
Quoted 6 lines
src/openvpn/ssl_verify.c +3
-0@@ -1249,6 +1249,9 @@ verify_user_pass_management(struct tls_session *session,/* * Main username/password verification entry point +* +* Will set session->ks[KS_PRIMARY].authenticated according to +* result of the username/password verifcation
verifcation -> verification
Quoted 49 lines
src/openvpn/ssl_verify.c +3
-10*/ void verify_user_pass(struct user_pass *up, struct tls_multi *multi,@@ -1414,17 +1417,10 @@ verify_user_pass(struct user_pass *up, struct tls_multi *multi,*/ send_push_reply_auth_token (multi); } -#ifdef ENABLE_DEF_AUTH msg (D_HANDSHAKE ,"TLS: Username/Password authentication %s for username '%s' %s" , (ks->authenticated ==KS_AUTH_DEFERRED ) ?"deferred" :"succeeded" , up->username, (session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) ?"[CN SET]" :"" ); -#else -msg (D_HANDSHAKE ,"TLS: Username/Password authentication %s for username '%s' %s" , -"succeeded" , - up->username, - (session->opt->ssl_flags &SSLF_USERNAME_AS_COMMON_NAME ) ?"[CN SET]" :"" ); -#endif }else {@@ -1445,7 +1441,7 @@ verify_final_auth_checks(struct tls_multi *multi, struct tls_session *session) }/* Don't allow the CN to change once it's been locked */ -if (ks->authenticated !=KS_AUTH_FALSE && multi->locked_cn) +if (ks->authenticated >KS_AUTH_FALSE && multi->locked_cn) {const char *cn = session->common_name;if (cn &&strcmp (cn, multi->locked_cn))@@ -1461,7 +1457,7 @@ verify_final_auth_checks(struct tls_multi *multi, struct tls_session *session) }/* Don't allow the cert hashes to change once they have been locked */ -if (ks->authenticated !=KS_AUTH_FALSE && multi->locked_cert_hash_set) +if (ks->authenticated >KS_AUTH_FALSE && multi->locked_cert_hash_set) {const struct cert_hash_set *chs = session->cert_hash_set;if (chs && !cert_hash_compare (chs, multi->locked_cert_hash_set))@@ -1475,7 +1471,7 @@ verify_final_auth_checks(struct tls_multi *multi, struct tls_session *session) }/* verify --client-config-dir based authentication */ -if (ks->authenticated !=KS_AUTH_FALSE && session->opt->client_config_dir_exclusive) +if (ks->authenticated >KS_AUTH_FALSE && session->opt->client_config_dir_exclusive) {struct gc_arena gc =gc_new ();
[Openvpn-devel] [PATCH applied] Re: Make key_state->authenticated more state machine like
In reply to Arne SchwabeYour patch has been applied to the master branch.
I have fixed the typos tincanteksup noticed plus one of my own, and tested this on the t_server testbed (tcp, udp, normal auth, async-auth plugin). Happy server, with 2.3, 2.4 and git master client.
While it already got an ACK, a good and thorough beating is always good for this stuff :-)
commit 5608041c7b343fbcd2d3317a8a49f43cb168a390
Author: Arne Schwabe Date: Thu Jul 9 12:15:57 2020 +0200
Make key_state->authenticated more state machine like
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]/msg20258.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 3/8 Extract process_incoming_push_reply from process_incoming_push_msg
In reply to Arne SchwabeThis is a small refactoring to make both function more readable. It also eliminates the ret variable in process_incoming_push_msg that now serves no purpose anymore.
--- src/openvpn/push.c | 113 +++++++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 49 deletions(-)
src/openvpn/push.c +64 -49
@@ -855,6 +855,63 @@ push_update_digest(md_ctx_t *ctx, struct buffer *buf, const struct options *opt) } } +static int +process_incoming_push_reply (struct context *c, +unsigned int permission_mask, +const unsigned int *option_types_found, +struct buffer *buf) +{ +int ret =PUSH_MSG_ERROR ; +const uint8_t ch =buf_read_u8 (buf); +if (ch ==',' ) + { +struct buffer buf_orig = (*buf); +if (!c->c2.pulled_options_digest_init_done) + { + c->c2.pulled_options_state =md_ctx_new (); +md_ctx_init (c->c2.pulled_options_state,md_kt_get ("SHA256" )); + c->c2.pulled_options_digest_init_done = true; + } +if (!c->c2.did_pre_pull_restore) + { +pre_pull_restore (&c->options, &c->c2.gc); + c->c2.did_pre_pull_restore = true; + } +if (apply_push_options (&c->options, + buf, + permission_mask, + option_types_found, + c->c2.es)) + { +push_update_digest (c->c2.pulled_options_state, &buf_orig, + &c->options); +switch (c->options.push_continuation) + { +case 0 : +case 1 : +md_ctx_final (c->c2.pulled_options_state, + c->c2.pulled_options_digest.digest); +md_ctx_cleanup (c->c2.pulled_options_state); +md_ctx_free (c->c2.pulled_options_state); + c->c2.pulled_options_state =NULL ; + c->c2.pulled_options_digest_init_done = false; + ret =PUSH_MSG_REPLY ; +break ; + +case 2 : + ret =PUSH_MSG_CONTINUATION ; +break ; + } + } + } +else if (ch =='\0' ) + { + ret =PUSH_MSG_REPLY ; + } +/* show_settings (&c->options); */ +return ret; +} + int process_incoming_push_msg(struct context *c, const struct buffer *buffer,
@@ -862,64 +919,22 @@ process_incoming_push_msg(struct context *c,unsigned int permission_mask, unsigned int *option_types_found) { - int ret = PUSH_MSG_ERROR; struct buffer buf = *buffer;if (buf_string_compare_advance (&buf,"PUSH_REQUEST" )) { - ret =process_incoming_push_request (c); +return process_incoming_push_request (c); }else if (honor_received_options &&buf_string_compare_advance (&buf,"PUSH_REPLY" )) { -const uint8_t ch =buf_read_u8 (&buf); -if (ch ==',' ) - { -struct buffer buf_orig = buf; -if (!c->c2.pulled_options_digest_init_done) - { - c->c2.pulled_options_state =md_ctx_new (); -md_ctx_init (c->c2.pulled_options_state,md_kt_get ("SHA256" )); - c->c2.pulled_options_digest_init_done = true; - } -if (!c->c2.did_pre_pull_restore) - { -pre_pull_restore (&c->options, &c->c2.gc); - c->c2.did_pre_pull_restore = true; - } -if (apply_push_options (&c->options, - &buf, - permission_mask, - option_types_found, - c->c2.es)) - { -push_update_digest (c->c2.pulled_options_state, &buf_orig, - &c->options); -switch (c->options.push_continuation) - { -case 0 : -case 1 : -md_ctx_final (c->c2.pulled_options_state, c->c2.pulled_options_digest.digest); -md_ctx_cleanup (c->c2.pulled_options_state); -md_ctx_free (c->c2.pulled_options_state); - c->c2.pulled_options_state =NULL ; - c->c2.pulled_options_digest_init_done = false; - ret =PUSH_MSG_REPLY ; -break ; - -case 2 : - ret =PUSH_MSG_CONTINUATION ; -break ; - } - } - } -else if (ch =='\0' ) - { - ret =PUSH_MSG_REPLY ; - } -/* show_settings (&c->options); */ +return process_incoming_push_reply (c, permission_mask, + option_types_found, &buf); + } +else + { +return PUSH_MSG_ERROR ; } -return ret; }
Signature · 1 line
2.26.2
Re: [Openvpn-devel] [PATCH 3/8] Extract process_incoming_push_reply from process_incoming_push_msg
Hi,
another nice patch that makes one more step towards having a more readable code base!
Quoted 78 lines · Arne Schwabe
This is a small refactoring to make both function more readable. It also eliminates the ret variable in
process_incoming_push_msgthat now serves no purpose anymore.Signed-off-by Arne Schwabe <[email protected]...>--- src/openvpn/push.c | 113 +++++++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 49 deletions(-)src/openvpn/push.c +57
-0@@ -855,6 +855,63 @@ push_update_digest(md_ctx_t *ctx, struct buffer *buf, const struct options *opt) } } +static int +process_incoming_push_reply (struct context *c, +unsigned int permission_mask, +const unsigned int *option_types_found, +struct buffer *buf) +{ +int ret =PUSH_MSG_ERROR ; +const uint8_t ch =buf_read_u8 (buf); +if (ch ==',' ) + { +struct buffer buf_orig = (*buf); +if (!c->c2.pulled_options_digest_init_done) + { + c->c2.pulled_options_state =md_ctx_new (); +md_ctx_init (c->c2.pulled_options_state,md_kt_get ("SHA256" )); + c->c2.pulled_options_digest_init_done = true; + } +if (!c->c2.did_pre_pull_restore) + { +pre_pull_restore (&c->options, &c->c2.gc); + c->c2.did_pre_pull_restore = true; + } +if (apply_push_options (&c->options, + buf, + permission_mask, + option_types_found, + c->c2.es)) + { +push_update_digest (c->c2.pulled_options_state, &buf_orig, + &c->options); +switch (c->options.push_continuation) + { +case 0 : +case 1 : +md_ctx_final (c->c2.pulled_options_state, + c->c2.pulled_options_digest.digest); +md_ctx_cleanup (c->c2.pulled_options_state); +md_ctx_free (c->c2.pulled_options_state); + c->c2.pulled_options_state =NULL ; + c->c2.pulled_options_digest_init_done = false; + ret =PUSH_MSG_REPLY ; +break ; + +case 2 : + ret =PUSH_MSG_CONTINUATION ; +break ; + } + } + } +else if (ch =='\0' ) + { + ret =PUSH_MSG_REPLY ; + } +/* show_settings (&c->options); */ +return ret; +} + int process_incoming_push_msg(struct context *c, const struct buffer *buffer,
src/openvpn/push.c process_incoming_push_msg(struct context *c, · line 920
Quoted 2 lines
src/openvpn/push.c +0
-0@@ -862,64 +919,22 @@ process_incoming_push_msg(struct context *c,unsigned int permission_mask, unsigned int *option_types_found)
^^^ this should now be made const,
otherwise you'll trigger a warning because process_incoming_push_reply() wants const.
Quoted 60 lines
src/openvpn/push.c +2
-48{ -int ret =PUSH_MSG_ERROR ;struct buffer buf = *buffer;if (buf_string_compare_advance (&buf,"PUSH_REQUEST" )) { - ret =process_incoming_push_request (c); +return process_incoming_push_request (c); }else if (honor_received_options &&buf_string_compare_advance (&buf,"PUSH_REPLY" )) { -const uint8_t ch =buf_read_u8 (&buf); -if (ch ==',' ) - { -struct buffer buf_orig = buf; -if (!c->c2.pulled_options_digest_init_done) - { - c->c2.pulled_options_state =md_ctx_new (); -md_ctx_init (c->c2.pulled_options_state,md_kt_get ("SHA256" )); - c->c2.pulled_options_digest_init_done = true; - } -if (!c->c2.did_pre_pull_restore) - { -pre_pull_restore (&c->options, &c->c2.gc); - c->c2.did_pre_pull_restore = true; - } -if (apply_push_options (&c->options, - &buf, - permission_mask, - option_types_found, - c->c2.es)) - { -push_update_digest (c->c2.pulled_options_state, &buf_orig, - &c->options); -switch (c->options.push_continuation) - { -case 0 : -case 1 : -md_ctx_final (c->c2.pulled_options_state, c->c2.pulled_options_digest.digest); -md_ctx_cleanup (c->c2.pulled_options_state); -md_ctx_free (c->c2.pulled_options_state); - c->c2.pulled_options_state =NULL ; - c->c2.pulled_options_digest_init_done = false; - ret =PUSH_MSG_REPLY ; -break ; - -case 2 : - ret =PUSH_MSG_CONTINUATION ; -break ; - } - } - } -else if (ch =='\0' ) - { - ret =PUSH_MSG_REPLY ; - } -/* show_settings (&c->options); */ + return process_incoming_push_reply(c, permission_mask,
src/openvpn/push.c process_incoming_push_msg(struct context *c, · line 940
Quoted 10 lines
src/openvpn/push.c +5
-1+ option_types_found, &buf); + } +else + { +return PUSH_MSG_ERROR ; } -return ret; }
The rest looks good!
Tested on the client side and the PUSH_REPLY was still properly processed as expected,
Assuming that const gets fixed:
Signature · 1 line
Antonio Quartulli
[Openvpn-devel] [PATCH applied] Re: Extract process_incoming_push_reply from process_incoming_push_msg
In reply to Arne SchwabeYour patch has been applied to the master branch.
After some discussion on IRC regarding the "const" bit it was decided to not *add* it to the function call, but to *remove* it from the function definition of process_incoming_push_msg() (which would otherwise be done in the 5/8 patch of this series).
With that changed the code compiles without warnings.
Stared a bit at "git show -w --color-moved=zebra" and the change seems to make sense :-)
Tested with local t_client tests on Linux and FreeBSD - haven't done a full server test, because "it's client side code".
commit 5e78bf66fa97818e0587ab1504cf7ecfd73df944
Author: Arne Schwabe Date: Thu Jul 9 12:15:58 2020 +0200
Extract process_incoming_push_reply from process_incoming_push_msg
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]/msg20254.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 4/8 Move protocol option negotiation from push_prepare to new function
In reply to Arne SchwabeThis clean ups the code and removes the surprising side effects of preparing a push reply to also select protocol options.
We also remember if we have seen a push request without async push. This improves reaction time if deferred auth is involved like managment interface deferred auth. The other benefit is removing a number of ifdefs.
--- src/openvpn/forward.c | 4 +-- src/openvpn/multi.c | 81 ++++++++++++++++++++++++++++++++++++++++--- src/openvpn/openvpn.h | 2 -- src/openvpn/push.c | 66 +++++------------------------------ 4 files changed, 88 insertions(+), 65 deletions(-)
src/openvpn/forward.c +2 -2
@@ -1123,8 +1123,8 @@ process_incoming_link_part1(struct context *c, struct link_socket_info *lsi, boo }/* -* Drop non-TLS packet if client-connect script/plugin has not -* yet succeeded. +* Drop non-TLS packet if client-connect script/plugin and cipher selection +* has not yet succeeded. */ if (c->c2.context_auth !=CAS_SUCCEEDED ) {
src/openvpn/multi.c +77 -4
104 lines not on this page · raw message
src/openvpn/openvpn.h +0 -2
@@ -432,9 +432,7 @@ struct context_2#if P2MP /* --ifconfig endpoints to be pushed to client */ -#ifdef ENABLE_ASYNC_PUSH bool push_request_received; -#endif bool push_ifconfig_defined;time_t sent_push_reply_expiry;in_addr_t push_ifconfig_local;
src/openvpn/push.c +9 -57
99 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [Openvpn-devel] [PATCH 4/8] Move protocol option negotiation from push_prepare to new function
typo
Quoted 239 lines · Arne Schwabe
This clean ups the code and removes the surprising side effects of preparing a push reply to also select protocol options.
We also remember if we have seen a push request without async push. This improves reaction time if deferred auth is involved like managment interface deferred auth. The other benefit is removing a number of ifdefs.
Signed-off-by Arne Schwabe <[email protected]...>--- src/openvpn/forward.c | 4 +-- src/openvpn/multi.c | 81 ++++++++++++++++++++++++++++++++++++++++--- src/openvpn/openvpn.h | 2 -- src/openvpn/push.c | 66 +++++------------------------------ 4 files changed, 88 insertions(+), 65 deletions(-)src/openvpn/forward.c +2
-2@@ -1123,8 +1123,8 @@ process_incoming_link_part1(struct context *c, struct link_socket_info *lsi, boo }/* -* Drop non-TLS packet if client-connect script/plugin has not -* yet succeeded. +* Drop non-TLS packet if client-connect script/plugin and cipher selection +* has not yet succeeded. */ if (c->c2.context_auth !=CAS_SUCCEEDED ) {src/openvpn/multi.c +77
-4@@ -824,8 +824,8 @@ multi_create_instance(struct multi_context *m, const struct mroute_addr *real) mi->did_cid_hash = true;#endif -#ifdef ENABLE_ASYNC_PUSH mi->context.c2.push_request_received = false; +#ifdef ENABLE_ASYNC_PUSH mi->inotify_watch =-1 ;#endif @@ -1772,6 +1772,78 @@ multi_client_connect_setenv(struct multi_context *m,gc_free (&gc); } +/** +* Calculates the options that depend on the client capabilities +* based on local options and available peer info +* - choosen cipher +* - peer id +*/ +static void +multi_client_set_protocol_options (struct context *c) +{ + +const char *optstr =NULL ; +struct tls_multi *tls_multi = c->c2.tls_multi; +const char *const peer_info = tls_multi->peer_info; +struct options *o = &c->options; + +/* Send peer-id if client supports it */ + optstr = peer_info ?strstr (peer_info,"IV_PROTO=" ) :NULL ; +if (optstr) + { +int proto =0 ; +int r =sscanf (optstr,"IV_PROTO=%d" , &proto); +if ((r ==1 ) && (proto >=2 )) + { + tls_multi->use_peer_id = true; + } + } + +/* Select cipher if client supports Negotiable Crypto Parameters */ +if (o->ncp_enabled) + { +/* if we have already created our key, we cannot *change* our own +* cipher -> so log the fact and push the "what we have now" cipher +* (so the client is always told what we expect it to use) +*/ +const struct tls_session *session = &tls_multi->session[TM_ACTIVE ]; +if (session->key[KS_PRIMARY ].crypto_options.key_ctx_bi.initialized) + { +msg (M_INFO ,"PUSH: client wants to negotiate cipher (NCP), but " +"server has already generated data channel keys, " +"re-sending previously negotiated cipher '%s'" , + o->ciphername ); + } +else + { +/* +* Push the first cipher from --ncp-ciphers to the client that +* the client announces to be supporting. +*/ +char *push_cipher =ncp_get_best_cipher (o->ncp_ciphers, o->ciphername, + peer_info, + tls_multi->remote_ciphername, + &o->gc); + +if (push_cipher) + { + o->ciphername = push_cipher; + } +else + { +struct gc_arena gc =gc_new (); +const char *peer_ciphers =tls_peer_ncp_list (peer_info, &gc); +msg (M_INFO ,"PUSH: No common cipher between server and client." +"Expect this connection not to work. " +"Server ncp-ciphers: '%s', client supported ciphers '%s'" , + o->ncp_ciphers, peer_ciphers); +gc_free (&gc); + } + } + } +} + +/* * Called as soon as the SSL/TLS connection authenticates. * @@ -2074,13 +2146,14 @@ script_failed:/* set context-level authentication flag */ mi->context.c2.context_auth =CAS_SUCCEEDED ; -#ifdef ENABLE_ASYNC_PUSH -/* authentication complete, send push reply */ +/* authentication complete, calculate dynamic client specific options */ +multi_client_set_protocol_options (&mi->context); + +/* send push reply if ready*/ if (mi->context.c2.push_request_received) {process_incoming_push_request (&mi->context); } -#endif }else {src/openvpn/openvpn.h +0
-2@@ -432,9 +432,7 @@ struct context_2#if P2MP /* --ifconfig endpoints to be pushed to client */ -#ifdef ENABLE_ASYNC_PUSH bool push_request_received; -#endif bool push_ifconfig_defined;time_t sent_push_reply_expiry;in_addr_t push_ifconfig_local;src/openvpn/push.c +4
-48@@ -437,7 +437,7 @@ prepare_auth_token_push_reply(struct tls_multi *tls_multi, struct gc_arena *gc, }/** -* Prepare push options, based on local options and available peer info. +* Prepare push options, based on local options * * @param context context structure storing data for VPN tunnel * @param gc gc arena for allocating push options @@ -449,9 +449,7 @@ bool prepare_push_reply(struct context *c, struct gc_arena *gc, struct push_list *push_list) { - const char *optstr = NULL; struct tls_multi *tls_multi = c->c2.tls_multi; -const char *const peer_info = tls_multi->peer_info;struct options *o = &c->options;/* ipv6 */ @@ -480,18 +478,10 @@ prepare_push_reply(struct context *c, struct gc_arena *gc, 0, gc)); } -/* Send peer-id if client supports it */ - optstr = peer_info ?strstr (peer_info,"IV_PROTO=" ) :NULL ; -if (optstr) +if (tls_multi->use_peer_id) { -int proto =0 ; -int r =sscanf (optstr,"IV_PROTO=%d" , &proto); -if ((r ==1 ) && (proto >=2 )) - { -push_option_fmt (gc, push_list,M_USAGE ,"peer-id %d" , - tls_multi->peer_id); - tls_multi->use_peer_id = true; - } +push_option_fmt (gc, push_list,M_USAGE ,"peer-id %d" , + tls_multi->peer_id); }/* * If server uses --auth-gen-token and we have an auth token @@ -499,47 +489,11 @@ prepare_push_reply(struct context *c, struct gc_arena *gc,*/ prepare_auth_token_push_reply (tls_multi, gc, push_list); -/* Push cipher if client supports Negotiable Crypto Parameters */ -if (o->ncp_enabled) - { -/* if we have already created our key, we cannot *change* our own -* cipher -> so log the fact and push the "what we have now" cipher -* (so the client is always told what we expect it to use) -*/ -const struct tls_session *session = &tls_multi->session[TM_ACTIVE ]; -if (session->key[KS_PRIMARY ].crypto_options.key_ctx_bi.initialized) - { -msg (M_INFO ,"PUSH: client wants to negotiate cipher (NCP), but " -"server has already generated data channel keys, " -"re-sending previously negotiated cipher '%s'" , - o->ciphername ); - } -else - { -/* -* Push the first cipher from --ncp-ciphers to the client that -* the client announces to be supporting. -*/ -char *push_cipher =ncp_get_best_cipher (o->ncp_ciphers, o->ciphername, - peer_info, - tls_multi->remote_ciphername, - &o->gc); - -if (push_cipher) - { - o->ciphername = push_cipher; - } -else - { -const char *peer_ciphers =tls_peer_ncp_list (peer_info, gc); - msg(M_INFO, "PUSH: No common cipher between server and client."
src/openvpn/push.c prepare_push_reply(struct context *c, struct gc_arena *gc, · line 494
Quoted 10 lines
src/openvpn/push.c +3
-7-"Expect this connection not to work. " -"Server ncp-ciphers: '%s', client supported ciphers '%s'" , - o->ncp_ciphers, peer_ciphers); - } - } -push_option_fmt (gc, push_list,M_USAGE ,"cipher %s" , o->ciphername); - } +/* +* Push the selected cipher, at this point the cipher has been +* already negioated and been fixed
another negioated
Quoted 16 lines
src/openvpn/push.c +2
-2+*/ +push_option_fmt (gc, push_list,M_USAGE ,"cipher %s" , o->ciphername);return true; }@@ -794,9 +748,7 @@ process_incoming_push_request(struct context *c) {int ret =PUSH_MSG_ERROR ; -#ifdef ENABLE_ASYNC_PUSH c->c2.push_request_received = true; -#endif if (tls_authentication_status (c->c2.tls_multi,0 ) ==TLS_AUTHENTICATION_FAILED || c->c2.context_auth ==CAS_FAILED ) {const char *client_reason =tls_client_reason (c->c2.tls_multi);
Re: [Openvpn-devel] [PATCH 4/8] Move protocol option negotiation from push_prepare to new function
In reply to Arne SchwabeHi,
Quoted 9 lines · Arne Schwabe
This clean ups the code and removes the surprising side effects of preparing a push reply to also select protocol options.
We also remember if we have seen a push request without async push. This improves reaction time if deferred auth is involved like managment interface deferred auth. The other benefit is removing a number of ifdefs.
Signed-off-by Arne Schwabe <[email protected]...>
I have tested this on the server side test torture program, and it reproduceably fails async-auth (with NCP, if that is relevant)
Jul 9 20:24:55 gentoo tun-udp-p2mp-global-authpam[9557]: cron2-freebsd-tc-amd64/2001:608:0:814::f000:21 Key [AF_INET6]2001:608:0:814::f000:21:28650 [0] not initialized (yet), dropping packet.
All other tests succeed.
Applying 5/8 on top of this makes the async auth test succeed again (and normal connections as well, from a quick glance - the full test is still running).
Let's discuss tomorrow how to proceed here.
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]...[Openvpn-devel] [PATCH applied] Re: Move protocol option negotiation from push_prepare to new function
In reply to Arne SchwabeYour patch has been applied to the master branch.
I have stared at the code, Antonio has stared at the code, and it makes sense. The test server says "but it breaks async auth", so I've amended the commit message with a big fat NOTE that says "this breaks async auth, but we'll fix it next commit".
I have not tested async-push (it might be broken as well), but we'll see to that next week when Lev is back.
commit 6344ea1218583d84baa986e6747e0c023d747245
Author: Arne Schwabe Date: Thu Jul 9 12:15:59 2020 +0200
Move protocol option negotiation from push_prepare to new function
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg20255.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: Move protocol option negotiation from push_prepare to new function
In reply to Arne Schwabe*sigh* the commit ID in the previous mail was wrong, it was "before I changed the commit message". Here's the correct one. Sorry.
commit 4f378ddb9932973965bb4931e85c991ddd86f7f0
Author: Arne Schwabe Date: Thu Jul 9 12:15:59 2020 +0200
Move protocol option negotiation from push_prepare to new function
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg20255.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 5/8 Generate data channel keys after connect options have been parsed
In reply to Arne SchwabeThe simplify the control flow, it makes more sense to generate the data keys when all the prerequisites for generating the data channel keys (ncp cipher selection etc) are met instead of delaying it to the next incoming PUSH_REQUEST message.
This also eliminates the need for the hack introduced by commit 3b06b57d9 to generate the data channel keys on the async file close event.
--- src/openvpn/multi.c | 54 ++++++++++++++++++++++++++------------------- src/openvpn/push.c | 27 ++++------------------- 2 files changed, 35 insertions(+), 46 deletions(-)
src/openvpn/multi.c +31 -23
@@ -1843,6 +1843,30 @@ multi_client_set_protocol_options(struct context *c) } } +/** +* Generates the data channel keys +*/ +static bool +multi_client_generate_tls_keys (struct context *c) +{ +struct frame *frame_fragment =NULL ; +#ifdef ENABLE_FRAGMENT +if (c->options.ce.fragment) + { + frame_fragment = &c->c2.frame_fragment; + } +#endif +struct tls_session *session = &c->c2.tls_multi->session[TM_ACTIVE ]; +if (!tls_session_update_crypto_params (session, &c->options, + &c->c2.frame, frame_fragment)) + { +msg (D_TLS_ERRORS ,"TLS Error: initializing data channel failed" ); +register_signal (c,SIGUSR1 ,"process-push-msg-failed" ); +return false; + } + +return true; +}/* * Called as soon as the SSL/TLS connection authenticates.
@@ -2149,7 +2173,13 @@ script_failed:/* authentication complete, calculate dynamic client specific options */ multi_client_set_protocol_options (&mi->context); -/* send push reply if ready*/ +/* Generate data channel keys */ +if (!multi_client_generate_tls_keys (&mi->context)) + { + mi->context.c2.context_auth =CAS_FAILED ; + } + +/* send push reply if ready */ if (mi->context.c2.push_request_received) {process_incoming_push_request (&mi->context);
@@ -2205,28 +2235,6 @@ multi_process_file_closed(struct multi_context *m, const unsigned int mpp_flags) {/* continue authentication, perform NCP negotiation and send push_reply */ multi_process_post (m, mi, mpp_flags); - -/* With NCP and deferred authentication, we perform cipher negotiation and -* data channel keys generation on incoming push request, assuming that auth -* succeeded. When auth succeeds in between push requests and async push is used, -* we send push reply immediately. Above multi_process_post() call performs -* NCP negotiation and here we do keys generation. */ - -struct context *c = &mi->context; -struct frame *frame_fragment =NULL ; -#ifdef ENABLE_FRAGMENT -if (c->options.ce.fragment) - { - frame_fragment = &c->c2.frame_fragment; - } -#endif -struct tls_session *session = &c->c2.tls_multi->session[TM_ACTIVE ]; -if (!tls_session_update_crypto_params (session, &c->options, - &c->c2.frame, frame_fragment)) - { -msg (D_TLS_ERRORS ,"TLS Error: initializing data channel failed" ); -register_signal (c,SIGUSR1 ,"init-data-channel-failed" ); - } } else {
src/openvpn/push.c +4 -23
@@ -359,30 +359,11 @@ incoming_push_message(struct context *c, const struct buffer *buffer) }event_timeout_clear (&c->c2.push_request_interval); } -else if (status ==PUSH_MSG_REQUEST ) - { -if (c->options.mode ==MODE_SERVER ) - { -struct frame *frame_fragment =NULL ; -#ifdef ENABLE_FRAGMENT -if (c->options.ce.fragment) - { - frame_fragment = &c->c2.frame_fragment; - } -#endif -struct tls_session *session = &c->c2.tls_multi->session[TM_ACTIVE ]; -if (!tls_session_update_crypto_params (session, &c->options, - &c->c2.frame, frame_fragment)) - { -msg (D_TLS_ERRORS ,"TLS Error: initializing data channel failed" ); - goto error; - } - } - } goto cleanup; + error: -register_signal (c,SIGUSR1 ,"process-push-msg-failed" ); +register_signal (c,SIGUSR1 ,"process-push-msg-failed" ); cleanup:gc_free (&gc); }
@@ -748,7 +729,6 @@ process_incoming_push_request(struct context *c) {int ret =PUSH_MSG_ERROR ; - c->c2.push_request_received = true;if (tls_authentication_status (c->c2.tls_multi,0 ) ==TLS_AUTHENTICATION_FAILED || c->c2.context_auth ==CAS_FAILED ) {const char *client_reason =tls_client_reason (c->c2.tls_multi);
@@ -810,7 +790,7 @@ push_update_digest(md_ctx_t *ctx, struct buffer *buf, const struct options *opt)static int process_incoming_push_reply (struct context *c,unsigned int permission_mask, -const unsigned int *option_types_found, +unsigned int *option_types_found,struct buffer *buf) {int ret =PUSH_MSG_ERROR ;
@@ -875,6 +855,7 @@ process_incoming_push_msg(struct context *c,if (buf_string_compare_advance (&buf,"PUSH_REQUEST" )) { + c->c2.push_request_received = true;return process_incoming_push_request (c); } else if (honor_received_options
Signature · 1 line
2.26.2
Re: [Openvpn-devel] [PATCH 5/8] Generate data channel keys after connect options have been parsed
possible white-space error ?
Quoted 118 lines · Arne Schwabe
The simplify the control flow, it makes more sense to generate the data keys when all the prerequisites for generating the data channel keys (ncp cipher selection etc) are met instead of delaying it to the next incoming
PUSH_REQUESTmessage.This also eliminates the need for the hack introduced by commit
3b06b57d9to generate the data channel keys on the async file close event.Signed-off-by Arne Schwabe <[email protected]...>--- src/openvpn/multi.c | 54 ++++++++++++++++++++++++++------------------- src/openvpn/push.c | 27 ++++------------------- 2 files changed, 35 insertions(+), 46 deletions(-)src/openvpn/multi.c +31
-23@@ -1843,6 +1843,30 @@ multi_client_set_protocol_options(struct context *c) } } +/** +* Generates the data channel keys +*/ +static bool +multi_client_generate_tls_keys (struct context *c) +{ +struct frame *frame_fragment =NULL ; +#ifdef ENABLE_FRAGMENT +if (c->options.ce.fragment) + { + frame_fragment = &c->c2.frame_fragment; + } +#endif +struct tls_session *session = &c->c2.tls_multi->session[TM_ACTIVE ]; +if (!tls_session_update_crypto_params (session, &c->options, + &c->c2.frame, frame_fragment)) + { +msg (D_TLS_ERRORS ,"TLS Error: initializing data channel failed" ); +register_signal (c,SIGUSR1 ,"process-push-msg-failed" ); +return false; + } + +return true; +}/* * Called as soon as the SSL/TLS connection authenticates. @@ -2149,7 +2173,13 @@ script_failed:/* authentication complete, calculate dynamic client specific options */ multi_client_set_protocol_options (&mi->context); -/* send push reply if ready*/ +/* Generate data channel keys */ +if (!multi_client_generate_tls_keys (&mi->context)) + { + mi->context.c2.context_auth =CAS_FAILED ; + } + +/* send push reply if ready */ if (mi->context.c2.push_request_received) {process_incoming_push_request (&mi->context);@@ -2205,28 +2235,6 @@ multi_process_file_closed(struct multi_context *m, const unsigned int mpp_flags) {/* continue authentication, perform NCP negotiation and send push_reply */ multi_process_post (m, mi, mpp_flags); - -/* With NCP and deferred authentication, we perform cipher negotiation and -* data channel keys generation on incoming push request, assuming that auth -* succeeded. When auth succeeds in between push requests and async push is used, -* we send push reply immediately. Above multi_process_post() call performs -* NCP negotiation and here we do keys generation. */ - -struct context *c = &mi->context; -struct frame *frame_fragment =NULL ; -#ifdef ENABLE_FRAGMENT -if (c->options.ce.fragment) - { - frame_fragment = &c->c2.frame_fragment; - } -#endif -struct tls_session *session = &c->c2.tls_multi->session[TM_ACTIVE ]; -if (!tls_session_update_crypto_params (session, &c->options, - &c->c2.frame, frame_fragment)) - { -msg (D_TLS_ERRORS ,"TLS Error: initializing data channel failed" ); -register_signal (c,SIGUSR1 ,"init-data-channel-failed" ); - } } else {src/openvpn/push.c +0
-16@@ -359,30 +359,11 @@ incoming_push_message(struct context *c, const struct buffer *buffer) }event_timeout_clear (&c->c2.push_request_interval); } -else if (status ==PUSH_MSG_REQUEST ) - { -if (c->options.mode ==MODE_SERVER ) - { -struct frame *frame_fragment =NULL ; -#ifdef ENABLE_FRAGMENT -if (c->options.ce.fragment) - { - frame_fragment = &c->c2.frame_fragment; - } -#endif -struct tls_session *session = &c->c2.tls_multi->session[TM_ACTIVE ]; -if (!tls_session_update_crypto_params (session, &c->options, - &c->c2.frame, frame_fragment)) - { -msg (D_TLS_ERRORS ,"TLS Error: initializing data channel failed" );
src/openvpn/push.c incoming_push_message(struct context *c, const struct buffer *buffer) · line 366
Quoted 10 lines
src/openvpn/push.c +2
-5- goto error; - } - } - } goto cleanup; + error: -register_signal (c,SIGUSR1 ,"process-push-msg-failed" ); +register_signal (c,SIGUSR1 ,"process-push-msg-failed" );
White-space ? just making a note of it
Quoted 29 lines
src/openvpn/push.c +2
-2cleanup:gc_free (&gc); }@@ -748,7 +729,6 @@ process_incoming_push_request(struct context *c) {int ret =PUSH_MSG_ERROR ; - c->c2.push_request_received = true;if (tls_authentication_status (c->c2.tls_multi,0 ) ==TLS_AUTHENTICATION_FAILED || c->c2.context_auth ==CAS_FAILED ) {const char *client_reason =tls_client_reason (c->c2.tls_multi);@@ -810,7 +790,7 @@ push_update_digest(md_ctx_t *ctx, struct buffer *buf, const struct options *opt)static int process_incoming_push_reply (struct context *c,unsigned int permission_mask, -const unsigned int *option_types_found, +unsigned int *option_types_found,struct buffer *buf) {int ret =PUSH_MSG_ERROR ;@@ -875,6 +855,7 @@ process_incoming_push_msg(struct context *c,if (buf_string_compare_advance (&buf,"PUSH_REQUEST" )) { + c->c2.push_request_received = true;return process_incoming_push_request (c); } else if (honor_received_options
[Openvpn-devel] [PATCH applied] Re: Generate data channel keys after connect options have been parsed
In reply to Arne SchwabeAntonio and I have stared at the code. It has stared back. And it makes sense (AND it reduces quite a bit of code!) - *and* it passes all client and server side tests I have, including async-auth pam.
I have fixed the whitespace mistake, and skipped the "const" hunk (that we already did in 2/8).
Your patch has been applied to the master branch.
commit 07560d9ed11a4bfdd7f2446f2c6ff854ee091154
Author: Arne Schwabe Date: Thu Jul 9 12:16:00 2020 +0200
Generate data channel keys after connect options have been parsed
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg20253.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 6/8 Cleanup: Remove special case code for old poor man's NCP.
In reply to Arne SchwabeEver since the NCPv2 the ncp_get_best_cipher uses the global options->ncp_enabled option and ignore the tls_session->ncp_enabled option.
The server side's poor man's NCP is implemented as seeing the list of supported ciphers from the peer as just one cipher so this special handling for poor man's NCP of the older NCP here is not needed anymore.
Theoretically we can now get rid of tls_session->ncp_enabled but doing so requires more refactoring since options is not available in the methods that still use it. And when we remove ncp-disable the variable will be removed anyway.
This commit moves the data channel key generation for the corner case of a client not supporting NCP but having the same cipher as the server to the same function that also generates data channel keys for NCP and poort man's NCP.
This has an unintended side effect of changing the calculated frame size for this special case. The old path did call tls_session_update_crypto_params.
To avoid this change in behaviour, this patch adds a hacky workaround for this.
A proper solution for this needs still be found but this allows the patch set to be merged.
Document the remaining usage of tls_poor_mans_ncp better.
--- src/openvpn/init.c | 2 ++ src/openvpn/ssl.c | 21 +++++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-)
src/openvpn/init.c +2 -0
@@ -2376,6 +2376,8 @@ do_deferred_options(struct context *c, const unsigned int found) }else if (c->options.ncp_enabled) { +/* If the server did not push a --cipher, we will switch to the +* remote cipher if it is in our ncp-ciphers list */ tls_poor_mans_ncp (&c->options, c->c2.tls_multi->remote_ciphername); }struct frame *frame_fragment =NULL ;
src/openvpn/ssl.c +7 -14
@@ -1986,6 +1986,12 @@ tls_session_update_crypto_params(struct tls_session *session, options->keysize =0 ; } } +else + { +/* Very hacky workaround and quick fix for our calculation +* not correct to avoid a regression */ +return tls_session_generate_data_channel_keys (session); + }init_key_type (&session->opt->key_type, options->ciphername, options->authname, options->keysize, true, true);
@@ -2463,8 +2469,7 @@ key_method_2_write(struct buffer *buf, struct tls_session *session)* generation is postponed until after the pull/push, so we can process pushed * cipher directives. */ -if (session->opt->server && !(session->opt->ncp_enabled - && session->opt->mode ==MODE_SERVER && ks->key_id <=0 )) +if (session->opt->server && !(session->opt->mode ==MODE_SERVER && ks->key_id <=0 )) {if (ks->authenticated >KS_AUTH_FALSE ) {
@@ -2616,18 +2621,6 @@ key_method_2_read(struct buffer *buf, struct tls_multi *multi, struct tls_sessio multi->remote_ciphername =options_string_extract_option (options,"cipher" ,NULL ); -if (!tls_peer_supports_ncp (multi->peer_info)) - { -/* Peer does not support NCP, but leave NCP enabled if the local and -* remote cipher do not match to attempt 'poor-man's NCP'. -*/ -if (multi->remote_ciphername ==NULL - ||0 ==strcmp (multi->remote_ciphername, multi->opt.config_ciphername)) - { - session->opt->ncp_enabled = false; - } - } -if (tls_session_user_pass_enabled (session)) {/* Perform username/password authentication */
Signature · 1 line
2.26.2
[Openvpn-devel] [PATCH applied] Re: Cleanup: Remove special case code for old poor man's NCP.
Tested on client and server side (and server vs. 2.3/2.4/master clients) and all works, including --ncp-disable clients. I'm fairly sure I have not all corner cases covered (like, master client talking to a 2.3 server with poor man's NCP), so more testing is needed in the 2.5-beta phase...
Your patch has been applied to the master branch.
commit e539c95dc8d240327be17e8647e52556dd7fd92d
Author: Arne Schwabe Date: Thu Jul 9 12:16:01 2020 +0200
Cleanup: Remove special case code for old poor man's NCP.
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg20251.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 7/8 Removed unused definition
In reply to Arne Schwabe--- src/openvpn/ssl.c | 5 +++-- src/openvpn/ssl.h | 7 ------- 2 files changed, 3 insertions(+), 9 deletions(-)
src/openvpn/ssl.c +3 -2
@@ -1988,8 +1988,9 @@ tls_session_update_crypto_params(struct tls_session *session, }else { -/* Very hacky workaround and quick fix for our calculation -* not correct to avoid a regression */ +/* Very hacky workaround and quick fix for frame calculation +* different when adjusting frame size when the original and new cipher +* are identical to avoid a regression with client without NCP */ return tls_session_generate_data_channel_keys (session); }
src/openvpn/ssl.h +0 -7
@@ -89,13 +89,6 @@#define TLS_MULTI_HORIZON 2/* call tls_multi_process frequently for n seconds after * every packet sent/received action */ -/* -* The SSL/TLS worker thread will wait at most this many seconds for the -* interprocess communication pipe to the main thread to be ready to accept -* writes. -*/ -#define TLS_MULTI_THREAD_SEND_TIMEOUT 5 -/* Interval that tls_multi_process should call tls_authentication_status */ #define TLS_MULTI_AUTH_STATUS_INTERVAL 10
Signature · 1 line
2.26.2
Re: [Openvpn-devel] [PATCH 7/8] Removed unused definition
Hi,
Quoted 11 lines · Arne Schwabe
Signed-off-by Arne Schwabe <[email protected]...>--- src/openvpn/ssl.c | 5 +++-- src/openvpn/ssl.h | 7 ------- 2 files changed, 3 insertions(+), 9 deletions(-)src/openvpn/ssl.c +0
-0
src/openvpn/ssl.c tls_session_update_crypto_params(struct tls_session *session, · line 1995
Quoted 10 lines
src/openvpn/ssl.c +3
-2@@ -1988,8 +1988,9 @@ tls_session_update_crypto_params(struct tls_session *session, }else { -/* Very hacky workaround and quick fix for our calculation -* not correct to avoid a regression */ +/* Very hacky workaround and quick fix for frame calculation +* different when adjusting frame size when the original and new cipher +* are identical to avoid a regression with client without NCP */ return tls_session_generate_data_channel_keys (session); }
This comment has strayed a bit, I think I'll move it over to the previous patch (6/8) which introduces it - not so useful to add a comment and then change it right in the next patch.
Also, somewhat unrelated change...
Quoted 7 lines
src/openvpn/ssl.h +0
-0@@ -89,13 +89,6 @@#define TLS_MULTI_HORIZON 2/* call tls_multi_process frequently for n seconds after * every packet sent/received action */
src/openvpn/ssl.h line 93
Quoted 10 lines
src/openvpn/ssl.h +0
-7-/* -* The SSL/TLS worker thread will wait at most this many seconds for the -* interprocess communication pipe to the main thread to be ready to accept -* writes. -*/ -#define TLS_MULTI_THREAD_SEND_TIMEOUT 5 -/* Interval that tls_multi_process should call tls_authentication_status */ #define TLS_MULTI_AUTH_STATUS_INTERVAL 10
This one is easy enough, so
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]...[Openvpn-devel] [PATCH applied] Re: Removed unused definition
In reply to Arne SchwabeYour patch has been applied to the master branch.
I have moved the comment change to 6/8 (to be applied as soon as we've worked out 4/8 and 5/8) so this can be nicely applied standalone. "It still compiles", so it is obviously correct :-)
commit a6571181550f518eda3a63fb89e3a8191199dd24
Author: Arne Schwabe Date: Thu Jul 9 12:16:02 2020 +0200
Removed unused definition
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg20256.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 8/8 Code cleanup: remove superflous variable
In reply to Arne Schwabe--- src/openvpn/ssl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
src/openvpn/ssl.c +2 -3
@@ -1231,11 +1231,10 @@ lame_duck_must_die(const struct tls_session *session, interval_t *wakeup)const struct key_state *lame = &session->key[KS_LAME_DUCK ];if (lame->state >=S_INITIAL ) { -const time_t local_now = now;ASSERT (lame->must_die);/* a lame duck key must always have an expiration */ -if (local_now < lame->must_die) +if (now < lame->must_die) { -compute_earliest_wakeup (wakeup, lame->must_die - local_now); +compute_earliest_wakeup (wakeup, lame->must_die - now);return false; }else
Signature · 1 line
2.26.2
Re: [Openvpn-devel] [PATCH 8/8] Code cleanup: remove superflous variable
Hi,
Quoted 10 lines · Arne Schwabe
Signed-off-by Arne Schwabe <[email protected]...>--- src/openvpn/ssl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)src/openvpn/ssl.c +0
-0
src/openvpn/ssl.c lame_duck_must_die(const struct tls_session *session, interval_t *wakeup) · line 1237
Quoted 10 lines
src/openvpn/ssl.c +2
-3@@ -1231,11 +1231,10 @@ lame_duck_must_die(const struct tls_session *session, interval_t *wakeup)const struct key_state *lame = &session->key[KS_LAME_DUCK ];if (lame->state >=S_INITIAL ) { -const time_t local_now = now;ASSERT (lame->must_die);/* a lame duck key must always have an expiration */ -if (local_now < lame->must_die) +if (now < lame->must_die) { -compute_earliest_wakeup (wakeup, lame->must_die - local_now); +compute_earliest_wakeup (wakeup, lame->must_die - now);
The only reason for having this local variable is the case where this code would run concurrently with a thread that could update "now" behind our back.
Since openvpn runs in a single thread, such scenario is not possible at all.
For this reason this patch makes sense and it removes one more bit that was originally introduced in the attempt of implementing multi threading.
Quoted 4 lines
src/openvpn/ssl.c +0
-0return false; }else
Signature · 1 line
Antonio Quartulli
[Openvpn-devel] [PATCH applied] Re: Code cleanup: remove superflous variable
In reply to Arne SchwabeYour patch has been applied to the master branch.
After some discussion on IRC, Antonio and I have come to the conclusion that the original code was related to the pre-2.2 threading attempts, and that "copying 'now' to a new local variable" might have been necessary to avoid another thread messing with it while comparisons are being made - so having a thread-local "local_now" is reasonable.
Now, the threading stuff was never finished and removed in 7aa6c12a4424d nearly 10 years ago... out with it :-)
commit ca514800ca126b69dbde846db819d8bf4c490e68
Author: Arne Schwabe Date: Thu Jul 9 12:16:03 2020 +0200
Code cleanup: remove superflous variable
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]/msg20252.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Hi,
Quoted 11 lines · Arne Schwabe
Signed-off-by Arne Schwabe <[email protected]...>--- Changes.rst | 18 ++++++++++++++++++ src/openvpn/options.c | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-)Changes.rst +0
-0
Changes.rst ChaCha20-Poly1305 cipher support · line 17
Quoted 5 lines
Changes.rst +2
-0@@ -13,6 +13,24 @@ ChaCha20-Poly1305 cipher support Added support for using the ChaCha20-Poly1305 cipher in the OpenVPN data channel. +Improved Data channel cipher negotiation + OpenVPN clients will now signal all supported cipher from the
^^^ cipherS
Quoted 4 lines
Changes.rst +4
-0+ ``ncp-ciphers`` option to the server via ``IV_CIPHERS``. OpenVPN + servers will select the first common cipher from the ``ncp-ciphers`` + list instead of blindly pushing the first cipher of the list. This + allows to use a configuration like
Changes.rst ChaCha20-Poly1305 cipher support · line 31
Quoted 10 lines
Changes.rst +10
-0+ ``ncp-ciphers ChaCha20-Poly1305:AES-256-GCM`` on the server that + prefers ChaCha20-Poly1305 but uses it only if the client supports it. + +Deprecated features +------------------- +For an up-to-date list of all deprecated options, see this wiki page: +https://community.openvpn.net/openvpn/wiki/DeprecatedOptions + +- ``ncp-disable`` has been deprecated + With the improved and matured data channel cipher negioation, the use
^^^ negotiation
Quoted 19 lines
Changes.rst +2
-0+ of ``ncp-disable`` should not be necessary anymore. + Overview of changes in 2.4 ==========================src/openvpn/options.c +1
-1@@ -545,7 +545,7 @@ static const char usage_message[] =" (default=%s).\n" " Set alg=none to disable encryption.\n" "--ncp-ciphers list : List of ciphers that are allowed to be negotiated.\n" -"--ncp-disable : Disable cipher negotiation.\n" +"--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
src/openvpn/options.c add_option(struct options *options, · line 7908
Quoted 5 lines
src/openvpn/options.c +2
-0@@ -7904,6 +7904,9 @@ add_option(struct options *options, {VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_INSTANCE ); options->ncp_enabled = false; +msg (M_WARN ,"DEPRECATED OPTION: ncp-disable. Disabling dynamic " + "cipher negioating is a depracted debug feature that will "
^^^ negotiation ^^^ deprecated
src/openvpn/options.c add_option(struct options *options, · line 7912
Quoted 5 lines
src/openvpn/options.c +1
-0+ "be removed in OpenVPN 2.6"); }else if (streq (p[0 ],"prng" ) && p[1 ] && !p[3 ]) {
I only have one doubt about how visible the message is:
2020-07-09 16:05:08 DEPRECATED OPTION: ncp-disable. Disabling dynamic
cipher negioating is a depracted debug feature that will be removed in OpenVPN 2.6
appears at the top of the log (first line actually) and does not seem easy to spot.
How about adding some ********* or ######## to make it pop out of the screen?
I personally did not see it immediately, even though I knew it was there! (note: it may just be me)
Signature · 1 line
Antonio Quartulli
Taken the review by Antonio and the subsequent discussion on IRC on "where should the message go?" - we leave it where it is, because all the other DEPRECATED OPTIONS warnings are done the same way (except keysize).
Typos fixed, message wrapped slightly differently to avoid line wrap.
Not checked in any significant way (besides "make" compile test, just to be sure I didn't break anything).
Your patch has been applied to the master branch.
commit 2b09c1405fdfffe15b2b444b15cce7820263a048
Author: Arne Schwabe Date: Thu Jul 9 12:15:56 2020 +0200
Deprecate ncp-disable and add improved ncp to Changes.rst
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg20257.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering