Skip to contentSkip to conversation

P2P NCP support patch set

PATCH In review Arne Schwabe 5 participants 24 messages Apr 8, 2021 – Apr 27, 2021

lore
Share & tools
lore
#0 lore raw

cover P2P NCP support patch set

Note: this patchset requires the "Move context_auth from context_2 to tls_multi and name it multi_state" patch to be applied first.

Our P2P mode is currently lacking in features compared to the P2MP mode. Especially EKM, DATA_v2 and NCP cannot be used with P2P mode. And the differences increase code complexity as we need to maintain two code paths. As we don't intend to deprecate P2P mode, this patchset implements NCP for P2P mode.

P2P NCP is lot less ambigous than normal NCP and will only be activated if both peers support it and avoids all the edge cases of different level of support for different versions.

Arne Schwabe (3):
Change options->data_channel_use_ekm to flags
Remove --ncp-disable option
Support NCP in pure P2P VPN setups

 Changes.rst                           |   4 +
 doc/man-sections/protocol-options.rst |   8 +-
 src/openvpn/init.c                    | 113 +++++++++++++----
 src/openvpn/multi.c                   |   9 +-
 src/openvpn/options.c                 |  48 ++-----
 src/openvpn/options.h                 |   5 +-
 src/openvpn/push.c                    |   2 +-
 src/openvpn/ssl.c                     | 173 ++++++++++++++++++--------
 src/openvpn/ssl.h                     |   5 +
 src/openvpn/ssl_backend.h             |   1 +
 src/openvpn/ssl_common.h              |  11 +-
 src/openvpn/ssl_ncp.c                 | 149 +++++++++++++++++++++-
 src/openvpn/ssl_ncp.h                 |  25 ++++
 tests/unit_tests/openvpn/test_ncp.c   |  11 ++
 14 files changed, 426 insertions(+), 138 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/3 Change options->data_channel_use_ekm to flags

Instead maintaining two different representation of the data channel options in struct options and struct tls_options, use the same flags variable that tls_options uses.

---
 src/openvpn/multi.c   | 5 ++++-
 src/openvpn/options.c | 4 ++--
 src/openvpn/options.h | 4 ++--
 src/openvpn/push.c    | 2 +-
 src/openvpn/ssl.c     | 6 ++----
 5 files changed, 11 insertions(+), 10 deletions(-)
src/openvpn/multi.c +4 -1
index d5f34c349..e6eb34bfb 100644
@@ -1783,7 +1783,10 @@ multi_client_set_protocol_options(struct context *c)
     }
 
 #ifdef HAVE_EXPORT_KEYING_MATERIAL
-    o->data_channel_use_ekm = (proto & IV_PROTO_TLS_KEY_EXPORT);
+    if (proto & IV_PROTO_TLS_KEY_EXPORT)
+    {
+        o->data_channel_crypto_flags |= CO_USE_TLS_KEY_MATERIAL_EXPORT;
+    }
 #endif
 
     /* Select cipher if client supports Negotiable Crypto Parameters */
src/openvpn/options.c +2 -2
index 9e61b1e05..24d722fd5 100644
@@ -3651,7 +3651,7 @@ pre_pull_restore(struct options *o, struct gc_arena *gc)
 
     o->push_continuation = 0;
     o->push_option_types_found = 0;
-    o->data_channel_use_ekm = false;
+    o->data_channel_crypto_flags = 0;
 }
 
 /**
@@ -7949,7 +7949,7 @@ add_option(struct options *options,
 #ifdef HAVE_EXPORT_KEYING_MATERIAL
         if (streq(p[1], "tls-ekm"))
         {
-            options->data_channel_use_ekm = true;
+            options->data_channel_crypto_flags |= CO_USE_TLS_KEY_MATERIAL_EXPORT;
         }
         else
 #endif
src/openvpn/options.h +2 -2
index 65e5ffccf..b80cd3d1b 100644
@@ -651,8 +651,8 @@ struct options
      * to the routing tables that would move packets into the tunnel. */
     bool allow_recursive_routing;
 
-    /* Use RFC5705 key export to generate data channel keys */
-    bool data_channel_use_ekm;
+    /* data channel crypto flags set by push/pull. Reuses the CO_* crypto_flags */
+    unsigned int data_channel_crypto_flags;
 };
 
 #define streq(x, y) (!strcmp((x), (y)))
src/openvpn/push.c +1 -1
index 15a9141ee..2e92d8ee2 100644
@@ -595,7 +595,7 @@ prepare_push_reply(struct context *c, struct gc_arena *gc,
     {
         push_option_fmt(gc, push_list, M_USAGE, "cipher %s", o->ciphername);
     }
-    if (o->data_channel_use_ekm)
+    if (o->data_channel_crypto_flags & CO_USE_TLS_KEY_MATERIAL_EXPORT)
     {
         push_option_fmt(gc, push_list, M_USAGE, "key-derivation tls-ekm");
     }
src/openvpn/ssl.c +2 -4
index d8662d000..5d65c3da5 100644
@@ -1860,10 +1860,8 @@ tls_session_update_crypto_params(struct tls_session *session,
         return false;
     }
 
-    if (options->data_channel_use_ekm)
-    {
-        session->opt->crypto_flags |= CO_USE_TLS_KEY_MATERIAL_EXPORT;
-    }
+    /* Import crypto settings that might be set by pull/push */
+    session->opt->crypto_flags |= options->data_channel_crypto_flags;
 
     if (strcmp(options->ciphername, session->opt->config_ciphername))
     {
Signature · 1 line
2.31.1
#6 lore raw

PATCH 2/3 Remove --ncp-disable option

In reply to Arne Schwabe

NCP has proven to be stable and apart from the one VPN Provider doing hacky things with homebrewed NCP we have not had any reports about ncp-disable being required. Remove ncp-disable to simplify code paths.

Note: This patch breaks client without --pull. The follow up patch for P2P NCP will restore that. But to avoid all the NCP/non-NCP special cases to be implemented in P2P. P2P will directly switch from always non-NCP to always NCP.

---
 Changes.rst                           |  4 +++
 doc/man-sections/protocol-options.rst |  8 ++----
 src/openvpn/init.c                    | 17 ++++---------
 src/openvpn/multi.c                   |  4 ---
 src/openvpn/options.c                 | 36 +++------------------------
 src/openvpn/options.h                 |  1 -
 src/openvpn/ssl.c                     |  3 +--
 src/openvpn/ssl_common.h              |  1 -
 src/openvpn/ssl_ncp.c                 |  4 ---
 9 files changed, 16 insertions(+), 62 deletions(-)
Changes.rst +4 -0
index 457dfc07e..d6ccc1c92 100644
@@ -47,6 +47,10 @@ Deprecated features
     is considered "too complicated", using ``--peer-fingerprint`` makes
     TLS mode about as easy as using ``--secret``.
 
+``ncp-disable`` has been removed
+    This option mainly served a role as debug option when NCP was first
+    introduced. It should now no longer be necessary.
+
 Overview of changes in 2.5
 ==========================
 
doc/man-sections/protocol-options.rst +2 -6
index 4b6928c68..fe8ca8fd1 100644
@@ -65,8 +65,8 @@ configured in a compatible way between both the local and remote side.
   The default is :code:`BF-CBC`, an abbreviation for Blowfish in Cipher
   Block Chaining mode. When cipher negotiation (NCP) is allowed,
   OpenVPN 2.4 and newer on both client and server side will automatically
-  upgrade to :code:`AES-256-GCM`.  See ``--data-ciphers`` and
-  ``--ncp-disable`` for more details on NCP.
+  upgrade to :code:`AES-256-GCM`.  See ``--data-ciphers`` for more details
+  on NCP.
 
   Using :code:`BF-CBC` is no longer recommended, because of its 64-bit
   block size. This small block size allows attacks based on collisions, as
@@ -230,10 +230,6 @@ configured in a compatible way between both the local and remote side.
     have been configured with `--enable-small`
     (typically used on routers or other embedded devices).
 
---ncp-disable
-  **DEPRECATED** Disable "Negotiable Crypto Parameters". This completely
-  disables cipher negotiation.
-
 --secret args
   **DEPRECATED** Enable Static Key encryption mode (non-TLS). Use pre-shared secret
   ``file`` which was generated with ``--genkey``.
src/openvpn/init.c +5 -12
index 28d183aa0..4a6b84914 100644
@@ -2226,18 +2226,14 @@ pull_permission_mask(const struct context *c)
         | OPT_P_EXPLICIT_NOTIFY
         | OPT_P_ECHO
         | OPT_P_PULL_MODE
-        | OPT_P_PEER_ID;
+        | OPT_P_PEER_ID
+        | OPT_P_NCP;
 
     if (!c->options.route_nopull)
     {
         flags |= (OPT_P_ROUTE | OPT_P_IPWIN32);
     }
 
-    if (c->options.ncp_enabled)
-    {
-        flags |= OPT_P_NCP;
-    }
-
     return flags;
 }
 
@@ -2734,8 +2730,6 @@ do_init_crypto_tls_c1(struct context *c)
         *
         * Therefore, the key structure has to be initialized when:
         * - any non-BF-CBC cipher was selected; or
-        * - BF-CBC is selected and NCP is disabled (explicit request to
-        *   use the BF-CBC cipher); or
         * - BF-CBC is selected, NCP is enabled and fallback is enabled
         *   (BF-CBC will be the fallback).
         * - BF-CBC is in data-ciphers and we negotiate to use BF-CBC:
@@ -2745,12 +2739,12 @@ do_init_crypto_tls_c1(struct context *c)
         * Note that BF-CBC will still be part of the OCC string to retain
         * backwards compatibility with older clients.
         */
-        if (!streq(options->ciphername, "BF-CBC") || !options->ncp_enabled
-            || (options->ncp_enabled && tls_item_in_cipher_list("BF-CBC", options->ncp_ciphers))
+        if (!streq(options->ciphername, "BF-CBC")
+            || tls_item_in_cipher_list("BF-CBC", options->ncp_ciphers)
             || options->enable_ncp_fallback)
         {
             /* Do not warn if the if the cipher is used only in OCC */
-            bool warn = !options->ncp_enabled || options->enable_ncp_fallback;
+            bool warn = options->enable_ncp_fallback;
             init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname,
                           true, warn);
         }
@@ -2847,7 +2841,6 @@ 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->options.ciphername;
     to.config_ncp_ciphers = c->options.ncp_ciphers;
-    to.ncp_enabled = options->ncp_enabled;
     to.transition_window = options->transition_window;
     to.handshake_window = options->handshake_window;
     to.packet_timeout = options->tls_timeout;
src/openvpn/multi.c +0 -4
index e6eb34bfb..1dd7c8983 100644
@@ -1790,10 +1790,6 @@ multi_client_set_protocol_options(struct context *c)
 #endif
 
     /* Select cipher if client supports Negotiable Crypto Parameters */
-    if (!o->ncp_enabled)
-    {
-        return true;
-    }
 
     /* 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
src/openvpn/options.c +4 -32
index 24d722fd5..e2759a1ac 100644
@@ -526,7 +526,6 @@ static const char usage_message[] =
     "                  (default=%s).\n"
     "                  Set alg=none to disable encryption.\n"
     "--data-ciphers list : List of ciphers that are allowed to be negotiated.\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"
 #ifndef ENABLE_CRYPTO_MBEDTLS
@@ -843,7 +842,6 @@ init_options(struct options *o, const bool init_gc)
     o->stale_routes_check_interval = 0;
     o->ifconfig_pool_persist_refresh_freq = 600;
     o->scheduled_exit_interval = 5;
-    o->ncp_enabled = true;
     o->ncp_ciphers = "AES-256-GCM:AES-128-GCM";
     o->authname = "SHA1";
     o->prng_hash = "SHA1";
@@ -1715,7 +1713,6 @@ show_settings(const struct options *o)
     SHOW_STR_INLINE(shared_secret_file);
     SHOW_PARM(key_direction, keydirection2ascii(o->key_direction, false, true), "%s");
     SHOW_STR(ciphername);
-    SHOW_BOOL(ncp_enabled);
     SHOW_STR(ncp_ciphers);
     SHOW_STR(authname);
     SHOW_STR(prng_hash);
@@ -3061,7 +3058,6 @@ options_postprocess_cipher(struct options *o)
     if (!o->pull && !(o->mode == MODE_SERVER))
     {
         /* we are in the classic P2P mode */
-        o->ncp_enabled = false;
         msg( M_WARN, "Cipher negotiation is disabled since neither "
              "P2MP client nor server mode is enabled");
 
@@ -3078,18 +3074,6 @@ options_postprocess_cipher(struct options *o)
     /* pull or P2MP mode */
     if (!o->ciphername)
     {
-        if (!o->ncp_enabled)
-        {
-            msg(M_USAGE, "--ncp-disable needs an explicit --cipher or "
-                         "--data-ciphers-fallback config option");
-        }
-
-        msg(M_WARN, "--cipher is not set. Previous OpenVPN version defaulted to "
-            "BF-CBC as fallback when cipher negotiation failed in this case. "
-            "If you need this fallback please add '--data-ciphers-fallback "
-            "BF-CBC' to your configuration and/or add BF-CBC to "
-            "--data-ciphers.");
-
         /* We still need to set the ciphername to BF-CBC since various other
          * parts of OpenVPN assert that the ciphername is set */
         o->ciphername = "BF-CBC";
@@ -3131,13 +3115,10 @@ options_postprocess_mutate(struct options *o)
     options_postprocess_cipher(o);
     options_postprocess_mutate_invariant(o);
 
-    if (o->ncp_enabled)
+    o->ncp_ciphers = mutate_ncp_cipher_list(o->ncp_ciphers, &o->gc);
+    if (o->ncp_ciphers == NULL)
     {
-        o->ncp_ciphers = mutate_ncp_cipher_list(o->ncp_ciphers, &o->gc);
-        if (o->ncp_ciphers == NULL)
-        {
-            msg(M_USAGE, "NCP cipher list contains unsupported ciphers or is too long.");
-        }
+        msg(M_USAGE, "NCP cipher list contains unsupported ciphers or is too long.");
     }
 
     if (o->remote_list && !o->connection_list)
@@ -3879,8 +3860,7 @@ options_string(const struct options *o,
         }
         /* Only announce the cipher to our peer if we are willing to
          * support it */
-        if (p2p_nopull || !o->ncp_enabled
-            || tls_item_in_cipher_list(ciphername, o->ncp_ciphers))
+        if (p2p_nopull || tls_item_in_cipher_list(ciphername, o->ncp_ciphers))
         {
             buf_printf(&out, ",cipher %s", ciphername);
         }
@@ -7957,14 +7937,6 @@ add_option(struct options *options,
             msg(msglevel, "Unknown key-derivation method %s", p[1]);
         }
     }
-    else if (streq(p[0], "ncp-disable") && !p[1])
-    {
-        VERIFY_PERMISSION(OPT_P_GENERAL|OPT_P_INSTANCE);
-        options->ncp_enabled = false;
-        msg(M_WARN, "DEPRECATED OPTION: ncp-disable. Disabling "
-            "cipher negotiation is a deprecated debug feature that "
-            "will be removed in OpenVPN 2.6");
-    }
     else if (streq(p[0], "prng") && p[1] && !p[3])
     {
         VERIFY_PERMISSION(OPT_P_GENERAL);
src/openvpn/options.h +0 -1
index b80cd3d1b..17f21103d 100644
@@ -506,7 +506,6 @@ struct options
     const char *ciphername;
     bool enable_ncp_fallback;      /**< If defined fall back to
                                     * ciphername if NCP fails */
-    bool ncp_enabled;
     const char *ncp_ciphers;
     const char *authname;
     const char *prng_hash;
src/openvpn/ssl.c +1 -2
index 5d65c3da5..068b66616 100644
@@ -2149,8 +2149,7 @@ 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))
+        if (session->opt->mode == MODE_SERVER || session->opt->pull)
         {
             if (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))
src/openvpn/ssl_common.h +0 -1
index 5b24623d4..3f8dd0178 100644
@@ -308,7 +308,6 @@ struct tls_options
 
     const char *config_ciphername;
     const char *config_ncp_ciphers;
-    bool ncp_enabled;
 
     bool tls_crypt_v2;
     const char *tls_crypt_v2_verify_script;
src/openvpn/ssl_ncp.c +0 -4
index f02a3103c..722256b42 100644
@@ -289,10 +289,6 @@ check_pull_client_ncp(struct context *c, const int found)
         return true;
     }
 
-    if (!c->options.ncp_enabled)
-    {
-        return true;
-    }
     /* If the server did not push a --cipher, we will switch to the
      * remote cipher if it is in our ncp-ciphers list */
     if(tls_poor_mans_ncp(&c->options, c->c2.tls_multi->remote_ciphername))
Signature · 1 line
2.31.1
#19 lore raw

PATCH 3/3 Support NCP in pure P2P VPN setups

In reply to Arne Schwabe

Currently P2P mode of OpenVPN is on of the few places that cannot negotiate modern OpenVPN features. This becomes more and more problematic since P2P and P2MP code diverge more and more and also the lack of switching to more advanced features like Data v2 currently blocks P2P mode from working together with the upcoming ovpn-dco support.

This NCP support is a lot simpler and works in the following way:

- P2P peer announce an extremely limited IV_ variable set (IV_PROTO and IV_CIPHERS)
- Both peers check if the IV_PROTO_NCP_P2P bit is present in IV_PROTO
- if yes both sides deterministically determine according to IV_PROTO and IV_CIPHER what options can be used and start using these

There are no poor man's NCP or other compatibility workaround like in the normal NCP, making this NCP leanear and more deterministic.

---
 src/openvpn/init.c                  | 100 ++++++++++++++---
 src/openvpn/options.c               |   8 +-
 src/openvpn/ssl.c                   | 168 +++++++++++++++++++---------
 src/openvpn/ssl.h                   |   5 +
 src/openvpn/ssl_backend.h           |   1 +
 src/openvpn/ssl_common.h            |  10 ++
 src/openvpn/ssl_ncp.c               | 145 ++++++++++++++++++++++++
 src/openvpn/ssl_ncp.h               |  25 +++++
 tests/unit_tests/openvpn/test_ncp.c |  11 ++
 9 files changed, 403 insertions(+), 70 deletions(-)
src/openvpn/init.c +84 -16
index 4a6b84914..11ac8b776 100644
@@ -68,6 +68,7 @@ static const char *saved_pid_file_name; /* GLOBAL */
 #define CF_INIT_TLS_AUTH_STANDALONE (1<<2)
 
 static void do_init_first_time(struct context *c);
+static bool do_deferred_p2p_ncp(struct context *c);
 
 void
 context_clear(struct context *c)
@@ -2151,6 +2152,14 @@ do_up(struct context *c, bool pulled_options, unsigned int option_types_found)
                 return false;
             }
         }
+        else if (c->mode == MODE_POINT_TO_POINT)
+        {
+            if (!do_deferred_p2p_ncp(c))
+            {
+                msg(D_TLS_ERRORS, "ERROR: Failed to apply P2P negotiated protocol options");
+                return false;
+            }
+        }
 
         /* if --up-delay specified, open tun, do ifconfig, and run up script now */
         if (c->options.up_delay || PULL_DEFINED(&c->options))
@@ -2237,6 +2246,72 @@ pull_permission_mask(const struct context *c)
     return flags;
 }
 
+static
+void adjust_mtu_peerid(struct context *c)
+{
+    frame_add_to_extra_frame(&c->c2.frame, +3);     /* peer-id overhead */
+    if (!c->options.ce.link_mtu_defined)
+    {
+        frame_add_to_link_mtu(&c->c2.frame, +3);
+        msg(D_PUSH, "OPTIONS IMPORT: adjusting link_mtu to %d",
+            EXPANDED_SIZE(&c->c2.frame));
+    }
+    else
+    {
+        msg(M_WARN, "OPTIONS IMPORT: WARNING: peer-id set, but link-mtu"
+                    " fixed by config - reducing tun-mtu to %d, expect"
+                    " MTU problems", TUN_MTU_SIZE(&c->c2.frame) );
+    }
+}
+
+static bool
+do_deferred_p2p_ncp(struct context *c)
+{
+
+    if (!c->c2.tls_multi)
+    {
+        return true;
+    }
+
+    if (c->c2.tls_multi->use_peer_id)
+    {
+        adjust_mtu_peerid(c);
+    }
+
+    struct tls_session *session = &c->c2.tls_multi->session[TM_ACTIVE];
+
+    const char *ncp_cipher = get_p2p_ncp_cipher(session, c->c2.tls_multi->peer_info,
+                                                &c->options.gc);
+
+    if (ncp_cipher)
+    {
+        c->options.ciphername = ncp_cipher;
+    }
+    else if (!c->options.enable_ncp_fallback)
+    {
+        msg(D_TLS_ERRORS, "ERROR: failed to negotiate cipher with peer and "
+                          "--data-ciphers-fallback not enabled. No useable "
+                          "data channel cipher");
+        return false;
+    }
+
+    struct frame *frame_fragment = NULL;
+#ifdef ENABLE_FRAGMENT
+    if (c->options.ce.fragment)
+    {
+        frame_fragment = &c->c2.frame_fragment;
+    }
+#endif
+
+    if (!tls_session_update_crypto_params(session, &c->options, &c->c2.frame,
+                                         frame_fragment))
+    {
+        msg(D_TLS_ERRORS, "ERROR: failed to set crypto cipher");
+        return false;
+    }
+    return true;
+}
+
 /*
  * Handle non-tun-related pulled options.
  */
@@ -2324,19 +2399,7 @@ do_deferred_options(struct context *c, const unsigned int found)
         msg(D_PUSH, "OPTIONS IMPORT: peer-id set");
         c->c2.tls_multi->use_peer_id = true;
         c->c2.tls_multi->peer_id = c->options.peer_id;
-        frame_add_to_extra_frame(&c->c2.frame, +3);     /* peer-id overhead */
-        if (!c->options.ce.link_mtu_defined)
-        {
-            frame_add_to_link_mtu(&c->c2.frame, +3);
-            msg(D_PUSH, "OPTIONS IMPORT: adjusting link_mtu to %d",
-                EXPANDED_SIZE(&c->c2.frame));
-        }
-        else
-        {
-            msg(M_WARN, "OPTIONS IMPORT: WARNING: peer-id set, but link-mtu"
-                " fixed by config - reducing tun-mtu to %d, expect"
-                " MTU problems", TUN_MTU_SIZE(&c->c2.frame) );
-        }
+        adjust_mtu_peerid(c);
     }
 
     /* process (potentially pushed) crypto options */
@@ -2865,16 +2928,21 @@ do_init_crypto_tls(struct context *c, const unsigned int flags)
     to.pull = options->pull;
     if (options->push_peer_info)        /* all there is */
     {
-        to.push_peer_info_detail = 2;
+        to.push_peer_info_detail = 3;
     }
     else if (options->pull)             /* pull clients send some details */
     {
-        to.push_peer_info_detail = 1;
+        to.push_peer_info_detail = 2;
     }
-    else                                /* default: no peer-info at all */
+    else if (options->mode == MODE_SERVER) /* server: no peer info at all */
     {
         to.push_peer_info_detail = 0;
     }
+    else                  /* default: minimal info to allow NCP in P2P mode */
+    {
+        to.push_peer_info_detail = 1;
+    }
+
 
     /* should we not xmit any packets until we get an initial
      * response from client? */
src/openvpn/options.c +4 -4
index e2759a1ac..26489becb 100644
@@ -3057,10 +3057,6 @@ options_postprocess_cipher(struct options *o)
 {
     if (!o->pull && !(o->mode == MODE_SERVER))
     {
-        /* we are in the classic P2P mode */
-        msg( M_WARN, "Cipher negotiation is disabled since neither "
-             "P2MP client nor server mode is enabled");
-
         /* If the cipher is not set, use the old default of BF-CBC. We will
          * warn that this is deprecated on cipher initialisation, no need
          * to warn here as well */
@@ -3068,6 +3064,10 @@ options_postprocess_cipher(struct options *o)
         {
             o->ciphername = "BF-CBC";
         }
+        else
+        {
+            o->enable_ncp_fallback = true;
+        }
         return;
     }
 
src/openvpn/ssl.c +118 -50

253 lines not on this page · raw message

src/openvpn/ssl.h +5 -0
index 300a70d35..f39d9d788 100644
@@ -122,6 +122,11 @@
 /** Supports signaling keywords with AUTH_PENDING, e.g. timeout=xy */
 #define IV_PROTO_AUTH_PENDING_KW (1<<4)
 
+/** Support doing NCP in P2P mode. This mode works by both peers looking at
+ * each other's IV_ variables and deterministically deciding both on the same
+ * result. */
+#define IV_PROTO_NCP_P2P         (1<<5)
+
 /* Default field in X509 to be username */
 #define X509_USERNAME_FIELD_DEFAULT "CN"
 
src/openvpn/ssl_backend.h +1 -0
index c3d12e5be..d228c70d8 100644
@@ -390,6 +390,7 @@ void backend_tls_ctx_reload_crl(struct tls_root_ctx *ssl_ctx,
                                 const char *crl_file, bool crl_inline);
 
 #define EXPORT_KEY_DATA_LABEL       "EXPORTER-OpenVPN-datakeys"
+#define EXPORT_P2P_PEERID_LABEL     "EXPORTER-OpenVPN-p2p-peerid"
 /**
  * Keying Material Exporters [RFC 5705] allows additional keying material to be
  * derived from existing TLS channel. This exported keying material can then be
src/openvpn/ssl_common.h +10 -0
index 3f8dd0178..9404be939 100644
@@ -271,6 +271,16 @@ struct tls_options
     bool disable_occ;
     int mode;
     bool pull;
+    /**
+     * The detail of info we push in peer info
+     *
+     * 0 - nothing at all, P2MP server only
+     * 1 - only the most basic information to negotiate cipher and features
+     *     for P2P NCP
+     * 2 - normal setting for clients
+     * 3 - full information including "sensitive data" like IV_HWADDR
+     *     enabled by --push-peer-info
+     */
     int push_peer_info_detail;
     int transition_window;
     int handshake_window;
src/openvpn/ssl_ncp.c +145 -0

149 lines not on this page · raw message

src/openvpn/ssl_ncp.h +25 -0
index 39158a568..c02be6939 100644
@@ -32,6 +32,7 @@
 
 #include "buffer.h"
 #include "options.h"
+#include "ssl_common.h"
 
 /**
  * Returns whether the client supports NCP either by
@@ -115,4 +116,28 @@ bool tls_item_in_cipher_list(const char *item, const char *list);
  */
 #define MAX_NCP_CIPHERS_LENGTH 127
 
+/**
+ * Determines if there is common cipher of both peer by looking at the
+ * IV_CIPHER peer info. In contrast of the server mode NCP that tries to
+ * accomandate all kind of corner cases in P2P mode NCP only takes IV_CIPHER
+ * into account and falls back to previous behaviour if this fails.
+ */
+void p2p_mode_ncp(struct tls_multi *multi, struct tls_session *session);
+
+/**
+ * Determines the best common cipher from both peers IV_CIPHER lists. The
+ * first cipher from the tls-server that is also in the tls-client IV_CIPHER
+ * list will be returned. If no common cipher can be found, both peer
+ * will continue to use whatever cipher is their default and NULL will be
+ * returned.
+ *
+ * @param session       tls_session
+ * @param peer_info     peer info of the peer
+ * @param gc            gc arena that will be used to allocate the returned cipher
+ * @return              common cipher if one exist.
+ */
+const char *
+get_p2p_ncp_cipher(struct tls_session *session, const char *peer_info,
+                   struct gc_arena *gc);
+
 #endif /* ifndef OPENVPN_SSL_NCP_H */
tests/unit_tests/openvpn/test_ncp.c +11 -0
index 4077be5e8..9dcd6f0a7 100644
@@ -44,6 +44,17 @@
 const char *bf_chacha = "BF-CBC:CHACHA20-POLY1305";
 const char *aes_ciphers = "AES-256-GCM:AES-128-GCM";
 
+
+/* Define this function here as dummy since including the ssl_*.c files
+ * leads to having to include even more unrelated code */
+bool
+key_state_export_keying_material(struct tls_session *session,
+                                 const char* label, size_t label_size,
+                                 void *ekm, size_t ekm_size)
+{
+    ASSERT(0);
+}
+
 static void
 test_check_ncp_ciphers_list(void **state)
 {
Signature · 1 line
2.31.1
#22 lore raw

PATCH 4/4 Implement deferred auth for scripts

In reply to Arne Schwabe

This patch also refactors the if condition that checks the result of the authentication since that has become quite unreadable. It renames s1/s2 and extracts some parts of the condition into individual variables to make the condition better understandle

Patch v2: add refactoring of the if condition
Patch v4: fix documentation not mentioning method as 2nd line Patch v5: fix deferred auth used by both plugin and script not working Patch v6: Add missing async inotify for script deferred auth

---
 Changes.rst                         |  10 +++
 doc/man-sections/script-options.rst |  14 +++-
 src/openvpn/multi.c                 |   6 ++
 src/openvpn/ssl.c                   |   1 +
 src/openvpn/ssl_common.h            |   1 +
 src/openvpn/ssl_verify.c            | 105 ++++++++++++++++++++--------
 6 files changed, 106 insertions(+), 31 deletions(-)
Changes.rst +10 -0
index d6ccc1c92..e7ae6abed 100644
@@ -30,6 +30,16 @@ TLS mode with self-signed certificates
     become optional. This allows for small OpenVPN setups without setting up
     a PKI with Easy-RSA or similar software.
 
+Deferred auth support for scripts
+    The ``--auth-user-pass-verify`` script supports now deferred authentication.
+
+Pending auth support for plugins and scripts
+    Both auth plugin and script can now signal pending authentication to
+    the client when using deferred authentication. The new ``client-crresponse``
+    script option and ``OPENVPN_PLUGIN_CLIENT_CRRESPONSE`` plugin function can
+    be used to parse a client response to a ``CR_TEXT`` two factor challenge.
+
+    See ``sample/sample-scripts/totpauth.py`` for an example.
 
 Deprecated features
 -------------------
doc/man-sections/script-options.rst +13 -1
index 03b3dd77b..22990f4f4 100644
@@ -90,7 +90,19 @@ SCRIPT HOOKS
 
   The script should examine the username and password, returning a success
   exit code (:code:`0`) if the client's authentication request is to be
-  accepted, or a failure code (:code:`1`) to reject the client.
+  accepted, a failure code (:code:`1`) to reject the client, or a that
+  the authentication is deferred (:code:`2`). If the authentication is
+  deferred, the script must fork/start a background or another non-blocking
+  operation to continue the authentication in the background. When finshing
+  the authentication, a :code:`1` or :code:`0` must be written to the
+  file specified by the :code:`auth_control_file`.
+
+  When deferred authentication is in use, the script can also request
+  pending authentication by writing to the file specified by the
+  :code:`auth_pending_file`. The first line must be the timeout in
+  seconds, the required method on the second line (e.g. crtext) and
+  third line must be the EXTRA as documented in the
+  ``client-pending-auth`` section of `doc/management.txt`.
 
   This directive is designed to enable a plugin-style interface for
   extending OpenVPN's authentication capabilities.
src/openvpn/multi.c +6 -0
index ee3ee6ced..eba80ee59 100644
@@ -2989,6 +2989,12 @@ multi_process_post(struct multi_context *m, struct multi_instance *mi, const uns
             add_inotify_file_watch(m, mi, m->top.c2.inotify_fd,
                                    ks->plugin_auth.auth_control_file);
         }
+        if (ks && ks->script_auth.auth_control_file && was_unauthenticated
+            && (ks->authenticated == KS_AUTH_DEFERRED))
+        {
+            add_inotify_file_watch(m, mi, m->top.c2.inotify_fd,
+                                   ks->script_auth.auth_control_file);
+        }
 #endif
 
         if (!IS_SIG(&mi->context))
src/openvpn/ssl.c +1 -0
index c28818b6e..6e53a3be4 100644
@@ -994,6 +994,7 @@ key_state_free(struct key_state *ks, bool clear)
     packet_id_free(&ks->crypto_options.packet_id);
 
     key_state_rm_auth_control_files(&ks->plugin_auth);
+    key_state_rm_auth_control_files(&ks->script_auth);
 
     if (clear)
     {
src/openvpn/ssl_common.h +1 -0
index 824dac310..f85131ee7 100644
@@ -222,6 +222,7 @@ struct key_state
     time_t acf_last_mod;
 
     struct auth_deferred_status plugin_auth;
+    struct auth_deferred_status script_auth;
 };
 
 /** Control channel wrapping (--tls-auth/--tls-crypt) context */
src/openvpn/ssl_verify.c +75 -30

205 lines not on this page · raw message

Signature · 1 line
2.31.1
#7 lore raw

Re: [Openvpn-devel] [PATCH 2/3] Remove --ncp-disable option

In reply to Arne Schwabe

Hi,

Quoted 8 lines · Arne Schwabe

NCP has proven to be stable and apart from the one VPN Provider doing hacky things with homebrewed NCP we have not had any reports about ncp-disable being required. Remove ncp-disable to simplify code paths.

Note: This patch breaks client without --pull. The follow up patch for P2P NCP will restore that. But to avoid all the NCP/non-NCP special cases to be implemented in P2P. P2P will directly switch from always non-NCP to always NCP.

I would Feature-NAK this :   disabling NCP is a valuable option. IMHO.

Also, is the MTU calculation part on the server side now done correctly?    I remember that with 2.4 the server would subtract (or add, depending on point of iew) far too many bytes to handle NCP

JJK

Quoted 277 lines
---
  Changes.rst                           |  4 +++
  doc/man-sections/protocol-options.rst |  8 ++----
  src/openvpn/init.c                    | 17 ++++---------
  src/openvpn/multi.c                   |  4 ---
  src/openvpn/options.c                 | 36 +++------------------------
  src/openvpn/options.h                 |  1 -
  src/openvpn/ssl.c                     |  3 +--
  src/openvpn/ssl_common.h              |  1 -
  src/openvpn/ssl_ncp.c                 |  4 ---
  9 files changed, 16 insertions(+), 62 deletions(-)
Changes.rst +4 -0
index 457dfc07e..d6ccc1c92 100644
@@ -47,6 +47,10 @@ Deprecated features
      is considered "too complicated", using ``--peer-fingerprint`` makes
      TLS mode about as easy as using ``--secret``.
 
+``ncp-disable`` has been removed
+    This option mainly served a role as debug option when NCP was first
+    introduced. It should now no longer be necessary.
+
  Overview of changes in 2.5
  ==========================
 
doc/man-sections/protocol-options.rst +2 -6
index 4b6928c68..fe8ca8fd1 100644
@@ -65,8 +65,8 @@ configured in a compatible way between both the local and remote side.
    The default is :code:`BF-CBC`, an abbreviation for Blowfish in Cipher
    Block Chaining mode. When cipher negotiation (NCP) is allowed,
    OpenVPN 2.4 and newer on both client and server side will automatically
-  upgrade to :code:`AES-256-GCM`.  See ``--data-ciphers`` and
-  ``--ncp-disable`` for more details on NCP.
+  upgrade to :code:`AES-256-GCM`.  See ``--data-ciphers`` for more details
+  on NCP.
 
    Using :code:`BF-CBC` is no longer recommended, because of its 64-bit
    block size. This small block size allows attacks based on collisions, as
@@ -230,10 +230,6 @@ configured in a compatible way between both the local and remote side.
      have been configured with `--enable-small`
      (typically used on routers or other embedded devices).
 
---ncp-disable
-  **DEPRECATED** Disable "Negotiable Crypto Parameters". This completely
-  disables cipher negotiation.
-
  --secret args
    **DEPRECATED** Enable Static Key encryption mode (non-TLS). Use pre-shared secret
    ``file`` which was generated with ``--genkey``.
src/openvpn/init.c +5 -12
index 28d183aa0..4a6b84914 100644
@@ -2226,18 +2226,14 @@ pull_permission_mask(const struct context *c)
          | OPT_P_EXPLICIT_NOTIFY
          | OPT_P_ECHO
          | OPT_P_PULL_MODE
-        | OPT_P_PEER_ID;
+        | OPT_P_PEER_ID
+        | OPT_P_NCP;
 
      if (!c->options.route_nopull)
      {
          flags |= (OPT_P_ROUTE | OPT_P_IPWIN32);
      }
 
-    if (c->options.ncp_enabled)
-    {
-        flags |= OPT_P_NCP;
-    }
-
      return flags;
  }
 
@@ -2734,8 +2730,6 @@ do_init_crypto_tls_c1(struct context *c)
          *
          * Therefore, the key structure has to be initialized when:
          * - any non-BF-CBC cipher was selected; or
-        * - BF-CBC is selected and NCP is disabled (explicit request to
-        *   use the BF-CBC cipher); or
          * - BF-CBC is selected, NCP is enabled and fallback is enabled
          *   (BF-CBC will be the fallback).
          * - BF-CBC is in data-ciphers and we negotiate to use BF-CBC:
@@ -2745,12 +2739,12 @@ do_init_crypto_tls_c1(struct context *c)
          * Note that BF-CBC will still be part of the OCC string to retain
          * backwards compatibility with older clients.
          */
-        if (!streq(options->ciphername, "BF-CBC") || !options->ncp_enabled
-            || (options->ncp_enabled && tls_item_in_cipher_list("BF-CBC", options->ncp_ciphers))
+        if (!streq(options->ciphername, "BF-CBC")
+            || tls_item_in_cipher_list("BF-CBC", options->ncp_ciphers)
              || options->enable_ncp_fallback)
          {
              /* Do not warn if the if the cipher is used only in OCC */
-            bool warn = !options->ncp_enabled || options->enable_ncp_fallback;
+            bool warn = options->enable_ncp_fallback;
              init_key_type(&c->c1.ks.key_type, options->ciphername, options->authname,
                            true, warn);
          }
@@ -2847,7 +2841,6 @@ 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->options.ciphername;
      to.config_ncp_ciphers = c->options.ncp_ciphers;
-    to.ncp_enabled = options->ncp_enabled;
      to.transition_window = options->transition_window;
      to.handshake_window = options->handshake_window;
      to.packet_timeout = options->tls_timeout;
src/openvpn/multi.c +0 -4
index e6eb34bfb..1dd7c8983 100644
@@ -1790,10 +1790,6 @@ multi_client_set_protocol_options(struct context *c)
  #endif
 
      /* Select cipher if client supports Negotiable Crypto Parameters */
-    if (!o->ncp_enabled)
-    {
-        return true;
-    }
 
      /* 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
src/openvpn/options.c +4 -32
index 24d722fd5..e2759a1ac 100644
@@ -526,7 +526,6 @@ static const char usage_message[] =
      "                  (default=%s).\n"
      "                  Set alg=none to disable encryption.\n"
      "--data-ciphers list : List of ciphers that are allowed to be negotiated.\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"
  #ifndef ENABLE_CRYPTO_MBEDTLS
@@ -843,7 +842,6 @@ init_options(struct options *o, const bool init_gc)
      o->stale_routes_check_interval = 0;
      o->ifconfig_pool_persist_refresh_freq = 600;
      o->scheduled_exit_interval = 5;
-    o->ncp_enabled = true;
      o->ncp_ciphers = "AES-256-GCM:AES-128-GCM";
      o->authname = "SHA1";
      o->prng_hash = "SHA1";
@@ -1715,7 +1713,6 @@ show_settings(const struct options *o)
      SHOW_STR_INLINE(shared_secret_file);
      SHOW_PARM(key_direction, keydirection2ascii(o->key_direction, false, true), "%s");
      SHOW_STR(ciphername);
-    SHOW_BOOL(ncp_enabled);
      SHOW_STR(ncp_ciphers);
      SHOW_STR(authname);
      SHOW_STR(prng_hash);
@@ -3061,7 +3058,6 @@ options_postprocess_cipher(struct options *o)
      if (!o->pull && !(o->mode == MODE_SERVER))
      {
          /* we are in the classic P2P mode */
-        o->ncp_enabled = false;
          msg( M_WARN, "Cipher negotiation is disabled since neither "
               "P2MP client nor server mode is enabled");
 
@@ -3078,18 +3074,6 @@ options_postprocess_cipher(struct options *o)
      /* pull or P2MP mode */
      if (!o->ciphername)
      {
-        if (!o->ncp_enabled)
-        {
-            msg(M_USAGE, "--ncp-disable needs an explicit --cipher or "
-                         "--data-ciphers-fallback config option");
-        }
-
-        msg(M_WARN, "--cipher is not set. Previous OpenVPN version defaulted to "
-            "BF-CBC as fallback when cipher negotiation failed in this case. "
-            "If you need this fallback please add '--data-ciphers-fallback "
-            "BF-CBC' to your configuration and/or add BF-CBC to "
-            "--data-ciphers.");
-
          /* We still need to set the ciphername to BF-CBC since various other
           * parts of OpenVPN assert that the ciphername is set */
          o->ciphername = "BF-CBC";
@@ -3131,13 +3115,10 @@ options_postprocess_mutate(struct options *o)
      options_postprocess_cipher(o);
      options_postprocess_mutate_invariant(o);
 
-    if (o->ncp_enabled)
+    o->ncp_ciphers = mutate_ncp_cipher_list(o->ncp_ciphers, &o->gc);
+    if (o->ncp_ciphers == NULL)
      {
-        o->ncp_ciphers = mutate_ncp_cipher_list(o->ncp_ciphers, &o->gc);
-        if (o->ncp_ciphers == NULL)
-        {
-            msg(M_USAGE, "NCP cipher list contains unsupported ciphers or is too long.");
-        }
+        msg(M_USAGE, "NCP cipher list contains unsupported ciphers or is too long.");
      }
 
      if (o->remote_list && !o->connection_list)
@@ -3879,8 +3860,7 @@ options_string(const struct options *o,
          }
          /* Only announce the cipher to our peer if we are willing to
           * support it */
-        if (p2p_nopull || !o->ncp_enabled
-            || tls_item_in_cipher_list(ciphername, o->ncp_ciphers))
+        if (p2p_nopull || tls_item_in_cipher_list(ciphername, o->ncp_ciphers))
          {
              buf_printf(&out, ",cipher %s", ciphername);
          }
@@ -7957,14 +7937,6 @@ add_option(struct options *options,
              msg(msglevel, "Unknown key-derivation method %s", p[1]);
          }
      }
-    else if (streq(p[0], "ncp-disable") && !p[1])
-    {
-        VERIFY_PERMISSION(OPT_P_GENERAL|OPT_P_INSTANCE);
-        options->ncp_enabled = false;
-        msg(M_WARN, "DEPRECATED OPTION: ncp-disable. Disabling "
-            "cipher negotiation is a deprecated debug feature that "
-            "will be removed in OpenVPN 2.6");
-    }
      else if (streq(p[0], "prng") && p[1] && !p[3])
      {
          VERIFY_PERMISSION(OPT_P_GENERAL);
src/openvpn/options.h +0 -1
index b80cd3d1b..17f21103d 100644
@@ -506,7 +506,6 @@ struct options
      const char *ciphername;
      bool enable_ncp_fallback;      /**< If defined fall back to
                                      * ciphername if NCP fails */
-    bool ncp_enabled;
      const char *ncp_ciphers;
      const char *authname;
      const char *prng_hash;
src/openvpn/ssl.c +1 -2
index 5d65c3da5..068b66616 100644
@@ -2149,8 +2149,7 @@ 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))
+        if (session->opt->mode == MODE_SERVER || session->opt->pull)
          {
              if (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))
src/openvpn/ssl_common.h +0 -1
index 5b24623d4..3f8dd0178 100644
@@ -308,7 +308,6 @@ struct tls_options
 
      const char *config_ciphername;
      const char *config_ncp_ciphers;
-    bool ncp_enabled;
 
      bool tls_crypt_v2;
      const char *tls_crypt_v2_verify_script;
src/openvpn/ssl_ncp.c +0 -4
index f02a3103c..722256b42 100644
@@ -289,10 +289,6 @@ check_pull_client_ncp(struct context *c, const int found)
          return true;
      }
 
-    if (!c->options.ncp_enabled)
-    {
-        return true;
-    }
      /* If the server did not push a --cipher, we will switch to the
       * remote cipher if it is in our ncp-ciphers list */
      if(tls_poor_mans_ncp(&c->options, c->c2.tls_multi->remote_ciphername))
#8 lore raw

Re: [Openvpn-devel] [PATCH 2/3] Remove --ncp-disable option

Am 08.04.21 um 16:36 schrieb Jan Just Keijser:

Quoted 7 lines

Hi,

Quoted 4 lines · Arne Schwabe

NCP has proven to be stable and apart from the one VPN Provider doing hacky things with homebrewed NCP we have not had any reports about ncp-disable being required. Remove ncp-disable to simplify code paths.

Quoted 5 lines
Quoted 4 lines

Note: This patch breaks client without --pull. The follow up patch for P2P NCP will restore that. But to avoid all the NCP/non-NCP special cases to be implemented in P2P. P2P will directly switch from always non-NCP to always NCP.

I would Feature-NAK this :   disabling NCP is a valuable option. IMHO.

I disagree here. NCP in 2.5 is mature mature enough that disabling NCP is not necessary any more. If you have any evidence otherwise, please explain a bit more since I personally don't see the value in it.

Quoted 3 lines

Also, is the MTU calculation part on the server side now done correctly?    I remember that with 2.4 the server would subtract (or add, depending on point of iew) far too many bytes to handle NCP

Not fully yet but the case where NCP cipher == original cipher has a workaround.

Arne

#9 lore raw

Re: [Openvpn-devel] [PATCH 2/3] Remove --ncp-disable option

Quoted 8 lines · Arne Schwabe

Am 08.04.21 um 16:36 schrieb Jan Just Keijser:

Quoted 7 lines

Hi,

Quoted 4 lines · Arne Schwabe

NCP has proven to be stable and apart from the one VPN Provider doing hacky things with homebrewed NCP we have not had any reports about ncp-disable being required. Remove ncp-disable to simplify code paths.

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

Note: This patch breaks client without --pull. The follow up patch for P2P NCP will restore that. But to avoid all the NCP/non-NCP special cases to be implemented in P2P. P2P will directly switch from always non-NCP to always NCP.

I would Feature-NAK this :   disabling NCP is a valuable option. IMHO.

I disagree here. NCP in 2.5 is mature mature enough that disabling NCP is not necessary any more. If you have any evidence otherwise, please explain a bit more since I personally don't see the value in it.

I don't have any evidence with 2.5 right now but this is just a matter of use/principle to me: I can very well see that I would like to have a setup *without* NCP as I simply do not need it (e.g. my cipher is hardwired to aes-256-gcm)  and in that case I don't *want* NCP to ensure my setup is 100% predictable.

Disabling this option means you give me less control over the setup and I don't like that, thus Feature-NAK.

Quoted 8 lines
Quoted 3 lines

Also, is the MTU calculation part on the server side now done correctly?    I remember that with 2.4 the server would subtract (or add, depending on point of iew) far too many bytes to handle NCP

Not fully yet but the case where NCP cipher == original cipher has a workaround.

I'd say that removing the ability to disable NCP  can happen *only* when all negative side-effects of enabling it have been mitigated fully.  On a slow link the NCP overhead can be quite disastrous and not just during connection setup, but during the *whole* session. To me, yet another reason for Feature-NAK

JJK

#10 lore raw

Re: [Openvpn-devel] [PATCH 2/3] Remove --ncp-disable option

Hi,

Quoted 5 lines · Jan Just Keijser

I don't have any evidence with 2.5 right now but this is just a matter of use/principle to me: I can very well see that I would like to have a setup *without* NCP as I simply do not need it (e.g. my cipher is hardwired to aes-256-gcm)  and in that case I don't *want* NCP to ensure my setup is 100% predictable.

By setting "--data-ciphers AES-256-GCM" on the client side, you achieve a 100% predictable outcome. No other cipher will be offered or accepted.

Quoted 2 lines

Disabling this option means you give me less control over the setup and I don't like that, thus Feature-NAK.

Removing that option means "less confusing code variants that can lead to 'it works with NCP but not with NCP disabled'".

Since I test all these variants, and find the confusing corner cases, it would be good to have less code paths throughout OpenVPN, especially in the server option negotiation and key setup phases.

Quoted 5 lines

I'd say that removing the ability to disable NCP  can happen *only* when all negative side-effects of enabling it have been mitigated fully.  On a slow link the NCP overhead can be quite disastrous and not just during connection setup, but during the *whole* session. To me, yet another reason for Feature-NAK

The overhead of NCP is roughly "some 100 bytes sent extra from client to server in the TLS handshake phase" (to announce the acceptable ciphers) and "cipher xxx" in the PUSH_REPLY.

There is no overhead in the data phase.

Please explain how this can be "quite disastrous"?

(Of course, if NCP negotiates a cipher with more overhead than you'd like to use, that would be "more overhead" - but this is fully under the client's control with --data-ciphers. It even works with "none", provided both client and server permit this)

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]...
#11 lore raw

Re: [Openvpn-devel] [PATCH 2/3] Remove --ncp-disable option

Hi,

Quoted 10 lines · Gert Doering

Hi,

Quoted 5 lines · Jan Just Keijser

I don't have any evidence with 2.5 right now but this is just a matter of use/principle to me: I can very well see that I would like to have a setup *without* NCP as I simply do not need it (e.g. my cipher is hardwired to aes-256-gcm)  and in that case I don't *want* NCP to ensure my setup is 100% predictable.

By setting "--data-ciphers AES-256-GCM" on the client side, you achieve a 100% predictable outcome. No other cipher will be offered or accepted.

Ah a new 2.5 option - I assume the same thing is true for adding this on the server side?

And I see that --data-ciphers works only in combination with NCP, that is, if you do --data-ciphers aes-256-gcm --ncp-disable
then --data-ciphers is effectively ignored.  Nice  ;)

Quoted 21 lines
Quoted 2 lines

Disabling this option means you give me less control over the setup and I don't like that, thus Feature-NAK.

Removing that option means "less confusing code variants that can lead to 'it works with NCP but not with NCP disabled'".

Since I test all these variants, and find the confusing corner cases, it would be good to have less code paths throughout OpenVPN, especially in the server option negotiation and key setup phases.

Quoted 5 lines

I'd say that removing the ability to disable NCP  can happen *only* when all negative side-effects of enabling it have been mitigated fully.  On a slow link the NCP overhead can be quite disastrous and not just during connection setup, but during the *whole* session. To me, yet another reason for Feature-NAK

The overhead of NCP is roughly "some 100 bytes sent extra from client to server in the TLS handshake phase" (to announce the acceptable ciphers) and "cipher xxx" in the PUSH_REPLY.

There is no overhead in the data phase.

Quoted 7 lines

Please explain how this can be "quite disastrous"?

(Of course, if NCP negotiates a cipher with more overhead than you'd like to use, that would be "more overhead" - but this is fully under the client's control with --data-ciphers. It even works with "none", provided both client and server permit this)

I was thinking about this email discussion we had in October 2018:

Quoted 16 lines · Gert Doering
Quoted 10 lines · Jan Just Keijser
Quoted 2 lines

So, the '32' is easily explained. However, the rest of the MTU calculation baffles me.

Part of this is "peer-id" (+3 bytes) and "the theoretical maximum crypto + hmac overhead" which 2.3 calculates "for the cipher chosen" and 2.4 needs to calculale for the worst-case cipher+auth, since it does not know what the server will push.

In other words, you do not want to know - and the whole "match configured client/server tun-mtu/link-mtu OCC thingie" is a real nuisance.

so I now understand the client MTU:
  openvpn 2.3.18 -> mtu = 1431
  openvpn 2.4.6 -> mtu = 1428 which accounts for peer-id (+3)

Quoted 7 lines

but the *server* mtu?!?!?!  I would have expected that with
--ncp-disable added I would end up with more or less the same MTU as
with the 2.3 code. Instead I see
  openvpn 2.3.18 -> mtu = 1431
  openvpn 2.4.6 -> mtu = 1379
which is 62 bytes LESS , so even with peer-id subtracted (does it apply to the server MTU?)  I end up with 59 bytes unaccounted for *in tun mode*.

and I was hoping that this would be resolved before removing something like --ncp-disable. Having said that, I now see that with openvpn 2.5, the server mtu is still 1379 in my setup, regardless of whether I use --ncp-disable or not  - seems to me that is still too low.

On the client side I now see even more confusing fun:

Server has --ncp-disable set:
- with  --cipher aes-256-cbc  the client side MTU is 1428
- with  --cipher aes-256-gcm  the client side MTU is 1376  <--- huh?

Server does not have --ncp-disable set:
- with  --cipher aes-256-cbc  the client side MTU is 1428
- with  --cipher aes-256-gcm  the client side MTU is 1448 (ok I understand the latter).

What I'd really like to see is a way to get the server-side MTU to also be 1428/1448 using the right magic options - any idea if that's possible? The lower the MTU on either side, the lower the maximum bandwidth - which will hurt especially over low-bandwidth links.

Also, when this option is dropped, does that mean that a 2.4/2.5 client with the option set can no longer connect to a 2.6 server?

Conclusion: a further overhaul of the ncp/cipher/data-ciphers logic might be in order...
Which is one of my gut reasons for saying : don't remove --ncp-disable until this mess is thoroughly sorted out.

JM2CW,

JJK

=============
Client config:

client
proto udp
remote $SERVER
port 1194
dev tun
nobind
remote-cert-tls server
ca       ca.crt
cert     client1.crt
key      client1.key
cipher aes-256-cbc
auth   sha256
link-mtu 1500
fragment 0
mssfix 0

=============
Server config:

proto udp
port 1194
dev tun
server 10.200.0.0 255.255.255.0
dh       dh2048.pem
ca       ca.crt
cert     server.crt
key      server.key
persist-key
persist-tun
keepalive 10 60
topology subnet
cipher aes-256-cbc
auth   sha256
link-mtu 1500
fragment 0
mssfix 0

#12 lore raw

Re: [Openvpn-devel] [PATCH 2/3] Remove --ncp-disable option

Hi Jan Just,

Quoted 13 lines · Jan Just Keijser

Hi,

Quoted 10 lines · Gert Doering

Hi,

Quoted 5 lines · Jan Just Keijser

I don't have any evidence with 2.5 right now but this is just a matter of use/principle to me: I can very well see that I would like to have a setup *without* NCP as I simply do not need it (e.g. my cipher is hardwired to aes-256-gcm)  and in that case I don't *want* NCP to ensure my setup is 100% predictable.

By setting "--data-ciphers AES-256-GCM" on the client side, you achieve a 100% predictable outcome. No other cipher will be offered or accepted.

Quoted 7 lines

Ah a new 2.5 option - I assume the same thing is true for adding this on the server side?

And I see that --data-ciphers works only in combination with NCP, that is, if you do
  --data-ciphers aes-256-gcm --ncp-disable
then --data-ciphers is effectively ignored.  Nice  ;)

Yeah, so the NCP behaviour is now customizable enough to give you total control over what should happen.

Quoted 57 lines
Quoted 22 lines
Quoted 3 lines

Disabling this option means you give me less control over the setup and I don't like that, thus Feature-NAK.

Removing that option means "less confusing code variants that can lead to 'it works with NCP but not with NCP disabled'".

Since I test all these variants, and find the confusing corner cases, it would be good to have less code paths throughout OpenVPN, especially in the server option negotiation and key setup phases.

Quoted 5 lines

I'd say that removing the ability to disable NCP  can happen *only* when all negative side-effects of enabling it have been mitigated fully.  On a slow link the NCP overhead can be quite disastrous and not just during connection setup, but during the *whole* session. To me, yet another reason for Feature-NAK

The overhead of NCP is roughly "some 100 bytes sent extra from client to server in the TLS handshake phase" (to announce the acceptable ciphers) and "cipher xxx" in the PUSH_REPLY.

There is no overhead in the data phase.

Quoted 7 lines

Please explain how this can be "quite disastrous"?

(Of course, if NCP negotiates a cipher with more overhead than you'd like to use, that would be "more overhead" - but this is fully under the client's control with --data-ciphers. It even works with "none", provided both client and server permit this)

I was thinking about this email discussion we had in October 2018:

Quoted 17 lines · Gert Doering
Quoted 11 lines · Jan Just Keijser
Quoted 2 lines

So, the '32' is easily explained. However, the rest of the MTU calculation baffles me.

Part of this is "peer-id" (+3 bytes) and "the theoretical maximum crypto + hmac overhead" which 2.3 calculates "for the cipher chosen" and 2.4 needs to calculale for the worst-case cipher+auth, since it does not know what the server will push.

In other words, you do not want to know - and the whole "match configured client/server tun-mtu/link-mtu OCC thingie" is a real nuisance.

so I now understand the client MTU:
  openvpn 2.3.18 -> mtu = 1431
  openvpn 2.4.6 -> mtu = 1428 which accounts for peer-id (+3)

Quoted 9 lines

but the *server* mtu?!?!?!  I would have expected that with --ncp-disable added I would end up with more or less the same MTU as with the 2.3 code. Instead I see
  openvpn 2.3.18 -> mtu = 1431
  openvpn 2.4.6 -> mtu = 1379
which is 62 bytes LESS , so even with peer-id subtracted (does it apply to the server MTU?)  I end up with 59 bytes unaccounted for *in tun mode*.

Quoted 5 lines

and I was hoping that this would be resolved before removing something like --ncp-disable. Having said that, I now see that with openvpn 2.5, the server mtu is still 1379 in my setup, regardless of whether I use --ncp-disable or not  - seems to me that is still too low.

If I understand your point correctly, you basically confirmed that this "MTU issue" you are seeing is unrelated to having --ncp-disable or not.

Therefore I think this topic should not be an argument for *not* removing --ncp-disable.

We have been busy discussing the "MTU mess" in the past weeks, so this is also something that we are all committed to solve. However, for the sake of this discussion, I'd keep this problem separated (worth discussing in another thread, of course!).

Quoted 11 lines

On the client side I now see even more confusing fun:

Server has --ncp-disable set:
- with  --cipher aes-256-cbc  the client side MTU is 1428
- with  --cipher aes-256-gcm  the client side MTU is 1376  <--- huh?

Server does not have --ncp-disable set:
- with  --cipher aes-256-cbc  the client side MTU is 1428
- with  --cipher aes-256-gcm  the client side MTU is 1448 (ok I understand the latter).

Quoted 7 lines

What I'd really like to see is a way to get the server-side MTU to also be 1428/1448 using the right magic options - any idea if that's possible? The lower the MTU on either side, the lower the maximum bandwidth - which will hurt especially over low-bandwidth links.

Also, when this option is dropped, does that mean that a 2.4/2.5 client with the option set can no longer connect to a 2.6 server?

No. *All* clients will still be able to connect.

The NCP logic has a case for "the client is not NCP-capable".

In this case the server checks OCC string to see what cipher the client is going to use. If this cipher is part of the data-ciphers list on the server, then that cipher will be used.
If there is no OCC string, I think the server will use the configured fallback-cipher.

So compatibility is preserved.

As you can see NCP is much more comprehensive that what it was before, hence the request to drop --ncp-disable.

Quoted 3 lines

Conclusion: a further overhaul of the ncp/cipher/data-ciphers logic might be in order...

This is exactly what has been going on, I'd say, with the addition of the new options and new logic to keep compatibility with non-NCP clients.

Quoted 2 lines

Which is one of my gut reasons for saying : don't remove --ncp-disable until this mess is thoroughly sorted out.

I hope this patch makes more sense now.

Regards,

Signature · 1 line
Antonio Quartulli
#13 lore raw

Re: [Openvpn-devel] [PATCH 2/3] Remove --ncp-disable option

In reply to Jan Just Keijser

Am 09.04.21 um 11:24 schrieb Jan Just Keijser:

Quoted 13 lines

Hi,

Quoted 10 lines · Gert Doering

Hi,

Quoted 5 lines · Jan Just Keijser

I don't have any evidence with 2.5 right now but this is just a matter of use/principle to me: I can very well see that I would like to have a setup *without* NCP as I simply do not need it (e.g. my cipher is hardwired to aes-256-gcm)  and in that case I don't *want* NCP to ensure my setup is 100% predictable.

By setting "--data-ciphers AES-256-GCM" on the client side, you achieve a 100% predictable outcome. No other cipher will be offered or accepted.

Quoted 7 lines

Ah a new 2.5 option - I assume the same thing is true for adding this on the server side?

And I see that --data-ciphers works only in combination with NCP, that is, if you do
  --data-ciphers aes-256-gcm --ncp-disable
then --data-ciphers is effectively ignored.  Nice  ;)

Yes data-ciphers (and data-ciphers-fallback) are meant to replace all other cipher related options eventually.

Quoted 6 lines
Quoted 1 line

and I was hoping that this would be resolved before removing something like --ncp-disable. Having said that, I now see that with openvpn 2.5, the server mtu is still 1379 in my setup, regardless of whether I use --ncp-disable or not  - seems to me that is still too low.

Yes DATA_V2 adds 3 bytes compared to DATA_V1.

Quoted 11 lines

On the client side I now see even more confusing fun:

Server has --ncp-disable set:
- with  --cipher aes-256-cbc  the client side MTU is 1428
- with  --cipher aes-256-gcm  the client side MTU is 1376  <--- huh?

Server does not have --ncp-disable set:
- with  --cipher aes-256-cbc  the client side MTU is 1428
- with  --cipher aes-256-gcm  the client side MTU is 1448 (ok I understand the latter).

Quoted 7 lines

What I'd really like to see is a way to get the server-side MTU to also be 1428/1448 using the right magic options - any idea if that's possible? The lower the MTU on either side, the lower the maximum bandwidth - which will hurt especially over low-bandwidth links.

Also, when this option is dropped, does that mean that a 2.4/2.5 client with the option set can no longer connect to a 2.6 server?

I am not sure how you came to that conclusion. I have written a fairly comprehensible documentation how NCP in 2.5 works for our manpage:
https://github.com/OpenVPN/openvpn/blob/master/doc/man-sections/cipher-negotiation.rst

That should also answer your question.

Quoted 4 lines

Conclusion: a further overhaul of the ncp/cipher/data-ciphers logic might be in order...
Which is one of my gut reasons for saying : don't remove --ncp-disable until this mess is thoroughly sorted out.

Please don't mix two things here. Yes the MTU calculation and MTU in general is broken but shouldn't pollute this discussion here.

And yes we will look into MTU related issues before 2.6 is released but having a non NCP and a NCP code path for MTU is not helping to reduce the complexity.

Arne

#14 lore raw

Re: [Openvpn-devel] [PATCH 2/3] Remove --ncp-disable option

Hi Arne, Antonio,

Quoted 22 lines · Arne Schwabe

Am 09.04.21 um 11:24 schrieb Jan Just Keijser:

Quoted 9 lines · Gert Doering
Quoted 8 lines · Jan Just Keijser
Quoted 5 lines

I don't have any evidence with 2.5 right now but this is just a matter of use/principle to me: I can very well see that I would like to have a setup *without* NCP as I simply do not need it (e.g. my cipher is hardwired to aes-256-gcm)  and in that case I don't *want* NCP to ensure my setup is 100% predictable.

By setting "--data-ciphers AES-256-GCM" on the client side, you achieve a 100% predictable outcome. No other cipher will be offered or accepted.

Quoted 7 lines

Ah a new 2.5 option - I assume the same thing is true for adding this on the server side?

And I see that --data-ciphers works only in combination with NCP, that is, if you do
  --data-ciphers aes-256-gcm --ncp-disable
then --data-ciphers is effectively ignored.  Nice  ;)

Yes data-ciphers (and data-ciphers-fallback) are meant to replace all other cipher related options eventually.

Quoted 7 lines
Quoted 5 lines

and I was hoping that this would be resolved before removing something like --ncp-disable. Having said that, I now see that with openvpn 2.5, the server mtu is still 1379 in my setup, regardless of whether I use --ncp-disable or not  - seems to me that is still too low.

Yes DATA_V2 adds 3 bytes compared to DATA_V1.

I understand the 3 bytes (--peerid and such) but is there any way to NOT have such a low server-side MTU? Also note that having a different server-side MTU versus client-side MTU makes it even harder to tune the performance

Quoted 28 lines
Quoted 11 lines

On the client side I now see even more confusing fun:

Server has --ncp-disable set:
- with  --cipher aes-256-cbc  the client side MTU is 1428
- with  --cipher aes-256-gcm  the client side MTU is 1376  <--- huh?

Server does not have --ncp-disable set:
- with  --cipher aes-256-cbc  the client side MTU is 1428
- with  --cipher aes-256-gcm  the client side MTU is 1448 (ok I understand the latter).

Quoted 7 lines

What I'd really like to see is a way to get the server-side MTU to also be 1428/1448 using the right magic options - any idea if that's possible? The lower the MTU on either side, the lower the maximum bandwidth - which will hurt especially over low-bandwidth links.

Also, when this option is dropped, does that mean that a 2.4/2.5 client with the option set can no longer connect to a 2.6 server?

I am not sure how you came to that conclusion. I have written a fairly comprehensible documentation how NCP in 2.5 works for our manpage:
https://github.com/OpenVPN/openvpn/blob/master/doc/man-sections/cipher-negotiation.rst

That should also answer your question.

Quoted 4 lines

Conclusion: a further overhaul of the ncp/cipher/data-ciphers logic might be in order...
Which is one of my gut reasons for saying : don't remove --ncp-disable until this mess is thoroughly sorted out.

Quoted 8 lines

Please don't mix two things here. Yes the MTU calculation and MTU in general is broken but shouldn't pollute this discussion here.

And yes we will look into MTU related issues before 2.6 is released but having a non NCP and a NCP code path for MTU is not helping to reduce the complexity.

thanks for all the clarifications - esp the cipher-negotiation.rst was very helpful.
And I understand the argument about "polluting the discussion" but to me the *order* in which things are done is important. That is, for the 2.6 release all MTU issues should be resolved , so that noone will ever have a need to debug MTU issues by dis- or enabling NCP. So I guess if things were done in the order
  1) fix the MTU issues on both client and server side
  2) drop --ncp-disable
then you would not have heard any complaints from me.

cheers,

JJK

#15 lore raw

Re: [Openvpn-devel] [PATCH 2/3] Remove --ncp-disable option

Quoted 11 lines
Quoted 7 lines
Quoted 5 lines

and I was hoping that this would be resolved before removing something like --ncp-disable. Having said that, I now see that with openvpn 2.5, the server mtu is still 1379 in my setup, regardless of whether I use --ncp-disable or not  - seems to me that is still too low.

Yes DATA_V2 adds 3 bytes compared to DATA_V1.

I understand the 3 bytes (--peerid and such) but is there any way to NOT have such a low server-side MTU?
Also note that having a different server-side MTU versus client-side MTU makes it even harder to tune the performance

Basically no. The Data V1 vs Data V2 discussion is basically done and V2 is here to stay. If 3 bytes really are too much (and we have a very strong use case to save those bytes), having optionally reduce the auth tag in AES-GCM/CachaPoly to something like 128 bit (16 bytes) or 160 bit instead the current 256 bit (32 bytes) makes probably more sense. E.g. Wireguard only uses 16 bytes auth tag and IPSec allows 16/12/8 bytes according to RFC4106.

I don't think there is any real different client vs server mtu here apart from potential bugs in the MTU code but not any fundamental

Quoted 10 lines

thanks for all the clarifications - esp the cipher-negotiation.rst was very helpful.
And I understand the argument about "polluting the discussion" but to me the *order* in which things are done is important. That is, for the 2.6 release all MTU issues should be resolved , so that noone will ever have a need to debug MTU issues by dis- or enabling NCP.
So I guess if things were done in the order
  1) fix the MTU issues on both client and server side
  2) drop --ncp-disable
then you would not have heard any complaints from me.

That is an easy thing to say if you don't do the development.

But no, it doesn't work this way this time. I am simply not abanding my 30-40 outstanding patches now (that include also DCO), stop working on them when they are nearly finished, spend all my time on MTU and then later come back to the NCP/DCO/TLS session refactoring.

And I also don't want to invest time fixing MTU issues related to disabled MTU if I remove that feature later. That is just wasted time.

And as Antonio said, we are committed to fixing these issues. We do not plan to release a 2.6 version with broken MTU.

Arne

#16 lore raw

Re: [Openvpn-devel] [PATCH 2/3] Remove --ncp-disable option

In reply to Arne Schwabe

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, 9 April 2021 10:53, Arne Schwabe <[email protected]...> wrote:

<snip>

Quoted 7 lines

I am not sure how you came to that conclusion. I have written a fairly comprehensible documentation how NCP in 2.5 works for our manpage:
https://github.com/OpenVPN/openvpn/blob/master/doc/man-sections/cipher-negotiation.rst

That should also answer your question.

sorry for the noise but I created a quick ref. guide for cipher negotiation:

https://community.openvpn.net/openvpn/wiki/CipherNegotiation

It may be of some value to others reading this thread.

Regards
R

-----BEGIN PGP SIGNATURE-----
Version: ProtonMail

wsBzBAEBCAAGBQJgcES+ACEJEE+XnPZrkLidFiEECbw9RGejjXJ5xVVVT5ec 9muQuJ2TPAgAuSyk329uuzmDecw9kvFBa/UDQ2C8U4ZVwXZZKXk4AL5NtM9Q Nbsi6qHMPT/WYfgVMOPbJLvWgUx2yi51rPawis5itd4Ghe7nZtBQOdjz1LZY /5VfqgOIMtfvovL+Wlg1SpwPM5Mo/ApILcec4jfrP5XJxe/6Xo8Mx4ZcYLq7 EmjVZ3gFWSX3kmBTdtQmPRKZ6qTe3gezwduZ667eRy58kK39SRFX2tsjvFT+ 2D8mtkLIQvJNDbO1KHNmW4oXxcu7YesQScAshOBpIutyU0vUyg37fp+SoTcs Q4oS2Wp2T2HZlPMkvBopbiddk6Wu1+kaP0+jDiBllSkZRrcrwCRtsQ== =8Qly
-----END PGP SIGNATURE-----

#17 lore raw

Re: [Openvpn-devel] [PATCH 2/3] Remove --ncp-disable option

In reply to Jan Just Keijser

Hi,

Quoted 9 lines · Jan Just Keijser
Quoted 8 lines · Gert Doering
Quoted 5 lines · Jan Just Keijser

I don't have any evidence with 2.5 right now but this is just a matter of use/principle to me: I can very well see that I would like to have a setup *without* NCP as I simply do not need it (e.g. my cipher is hardwired to aes-256-gcm)  and in that case I don't *want* NCP to ensure my setup is 100% predictable.

By setting "--data-ciphers AES-256-GCM" on the client side, you achieve a 100% predictable outcome. No other cipher will be offered or accepted.

Quoted 7 lines

Ah a new 2.5 option - I assume the same thing is true for adding this on the server side?

And I see that --data-ciphers works only in combination with NCP, that is, if you do
  --data-ciphers aes-256-gcm --ncp-disable
then --data-ciphers is effectively ignored.  Nice  ;)

--data-ciphers is the option to tell the client what to announce as acceptable ciphers to the server, and what to accept if pushed (in case a server is not well-behaved).

This is part of NCP, and if you turn off NCP, it is no longer active.

And because this confuses people, the idea is, for 2.6, to remove that knob with changes the flow "config -> operational session" in ways that most people are not aware.

[..]

Quoted 10 lines

On the client side I now see even more confusing fun:

Server has --ncp-disable set:
- with  --cipher aes-256-cbc  the client side MTU is 1428
- with  --cipher aes-256-gcm  the client side MTU is 1376  <--- huh?

Server does not have --ncp-disable set:
- with  --cipher aes-256-cbc  the client side MTU is 1428
- with  --cipher aes-256-gcm  the client side MTU is 1448 (ok I understand the latter).

The MTU/frame overhead calculation, depending on configured and negotiated ciphers, is a big source of pain (just grep the source for "frame") - and yes, we are aware of it, but it's actually close to impossible to fix without really ripping it all out and doing it anew.

Arne is currently busy with ripping out all the renegotiation / half- authenticated keys / session stuff, and I understand that MTU is not far down his list.

My server test rig has a few cases where "large ping" fails due to exactly this, MTU miscalculations. Which is good, because it reminds me every day that this needs fixing.

Quoted 4 lines

What I'd really like to see is a way to get the server-side MTU to also be 1428/1448 using the right magic options - any idea if that's possible? The lower the MTU on either side, the lower the maximum bandwidth - which will hurt especially over low-bandwidth links.

Just set --tun-mtu 1448, done.

The "automatic" way is "take link-mtu, default 1500, and calculate tun-mtu from it depending on cipher/auth overhead". Which fails more often than not, but --tun-mtu can also be set directly.

Quoted 2 lines

Also, when this option is dropped, does that mean that a 2.4/2.5 client with the option set can no longer connect to a 2.6 server?

No. My test bed talks happily to 2.2 and 2.3 clients, some instances with --ncp-disable, most with NCP enabled (= as if there were no option to disable NCP).

You don't need that option today to make them talk, so they won't stop talking if you take the option away.

Quoted 4 lines

Conclusion: a further overhaul of the ncp/cipher/data-ciphers logic might be in order...
Which is one of my gut reasons for saying : don't remove --ncp-disable until this mess is thoroughly sorted out.

ncp/cipher/data-cipher is fine, and well-documented.

frame/mtu is where the pain is.

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]...
#2 lore raw

Re: [Openvpn-devel] [PATCH 1/3] Change options->data_channel_use_ekm to flags

In reply to Arne Schwabe

Hi Arne,

Quoted 5 lines · Arne Schwabe

Instead maintaining two different representation of the data channel options in struct options and struct tls_options, use the same flags variable that tls_options uses.

Thia patch looks good, but I Was wondering: why converting this flag to a bitmask? are you planning to add more bits to o->data_channel_crypto_flags?

Or is it just to simplify the conversion to crypto_flags?

Cheers,

Signature · 1 line
Antonio Quartulli
#3 lore raw

Re: [Openvpn-devel] [PATCH 1/3] Change options->data_channel_use_ekm to flags

Am 16.04.21 um 00:27 schrieb Antonio Quartulli:

Quoted 7 lines

Hi Arne,

Quoted 4 lines · Arne Schwabe

Instead maintaining two different representation of the data channel options in struct options and struct tls_options, use the same flags variable that tls_options uses.

Quoted 8 lines
Quoted 1 line

Thia patch looks good, but I Was wondering: why converting this flag to a bitmask? are you planning to add more bits to o->data_channel_crypto_flags?

Or is it just to simplify the conversion to crypto_flags?

Kinda both. I have a patch that extends the IV to be xor'ed instead of just counting upwards like TLS 1.3 is doing that but I currently keeping that back as it might not be worth doing that.

Arne

Acked-by on v1 1/3
#4 lore raw

Re: [Openvpn-devel] [PATCH 1/3] Change options->data_channel_use_ekm to flags

In reply to Arne Schwabe

Hi,

Quoted 5 lines · Arne Schwabe

Instead maintaining two different representation of the data channel options in struct options and struct tls_options, use the same flags variable that tls_options uses.

It's a simple restyling, converting this flag to bitfield. I don't think there is much gain, but allows adding more flags in the future with little effort (and little chance to introduce bugs).

Passes my basic test (with the ekm being properly activated).

GitLab CI compile rig is happy too.

Signature · 1 line
Antonio Quartulli
#18 lore raw

Re: [Openvpn-devel] [PATCH 2/3] Remove --ncp-disable option

In reply to Arne Schwabe

Hi,

Quoted 10 lines · Arne Schwabe

NCP has proven to be stable and apart from the one VPN Provider doing hacky things with homebrewed NCP we have not had any reports about ncp-disable being required. Remove ncp-disable to simplify code paths.

Note: This patch breaks client without --pull. The follow up patch for P2P NCP will restore that. But to avoid all the NCP/non-NCP special cases to be implemented in P2P. P2P will directly switch from always non-NCP to always NCP.

The patch looks good to me and passes my basic connectivity tests. Also I got no compile-time complain from any platform I could build on.

However, there is a comment that still talk about NCP being disabled/enabled. I think it should be changed too as we don't have the two cases anymore (the if-condition below is modified by this patch):

src/openvpn/init.c:2726: * as NCP-fallback or when NCP has been
disabled or explicitly

Cheers,

Signature · 1 line
Antonio Quartulli
#20 lore raw

Re: [Openvpn-devel] [PATCH 3/3] Support NCP in pure P2P VPN setups

In reply to Arne Schwabe

As per Arne's request, this patch is on hold as he wants to send another change first, which will heavily conflict with this patch.

We will wait for a new version of this patch that will be based on this other change he will send.

Cheers,

Signature · 1 line
Antonio Quartulli
#21 lore raw

Re: [Openvpn-devel] [PATCH 3/3] Support NCP in pure P2P VPN setups

Arne,

FYI this patch does not apply on master anymore, not even after applying 1/3 and 2/3.

Cheers,

Signature · 1 line
Antonio Quartulli
#5 lore raw

[Openvpn-devel] [PATCH applied] Re: Change options->data_channel_use_ekm to flags

In reply to Arne Schwabe

Lightly stared at code and ran client-side tests that actually used EKM... which meant "upgrading the server the t_client tests talk to" (and all passes).

Your patch has been applied to the master branch.

commit 9c625f4a6633de05d030884cac779cb41a5060e1

Author: Arne Schwabe
Date:   Thu Apr 8 16:02:26 2021 +0200
     Change options->data_channel_use_ekm to flags

     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]/msg22084.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#23 lore raw

Re: [Openvpn-devel] [PATCH 4/4] Implement deferred auth for scripts

In reply to Arne Schwabe

Hi,

Quoted 9 lines · Arne Schwabe

This patch also refactors the if condition that checks the result of the authentication since that has become quite unreadable. It renames s1/s2 and extracts some parts of the condition into individual variables to make the condition better understandle

Patch v2: add refactoring of the if condition
Patch v4: fix documentation not mentioning method as 2nd line Patch v5: fix deferred auth used by both plugin and script not working Patch v6: Add missing async inotify for script deferred auth

Just for the sake of the archives - this patch is a rebased re-send of the patch in

https://patchwork.openvpn.net/patch/1720/

(different from/to commit IDs, but otherwise 100% identical)

Someone already closed *this* one in patchwork, but I came across it today when working on the "patchset" this was sent with, and it confused me. So, document, close.

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]...