Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1768?usp=email

to look at the new patch set (#18).


Change subject: oob: advertise a connect_lifetime in the probe reply
......................................................................

oob: advertise a connect_lifetime in the probe reply

A server answering an out-of-band SERVER_PROBE now also advertises a
connect_lifetime in the PROBE_REPLY: how long, in seconds, a probing
client may use the reply as the server's HARD_RESET when it starts a
handshake.

The value is inferred, not configurable: the reply is only usable as
that reset while its stateless SYN-cookie is valid, i.e. the guaranteed
cookie window of ~handshake_window (2 quantised buckets; see
check_session_hmac_and_pkt_id), so the server advertises exactly that. A
probe that arrived as P_CONTROL_OOB_WKC_V1 also gets
OOB_PROBE_REPLY_FLAG_RESEND_WKC, telling the client to resend the WKc
when completing the handshake, since the server keeps no state.

Only the wire advertisement is added here -- the server puts both values
into the probe_reply it builds for an accepted probe. The client side
that acts on them follows.

Change-Id: Ib2b6c2246f9d9c0a505292ee8d879f714901ffae
Signed-off-by: Lev Stipakov <[email protected]>
---
M doc/man-sections/server-options.rst
M src/openvpn/mudp.c
M src/openvpn/oob.h
3 files changed, 27 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/68/1768/18

diff --git a/doc/man-sections/server-options.rst 
b/doc/man-sections/server-options.rst
index 48469d6..c1a0ed4 100644
--- a/doc/man-sections/server-options.rst
+++ b/doc/man-sections/server-options.rst
@@ -698,6 +698,12 @@
   stateless and rate-limited, and a probe is only answered if its
   timestamp is within ``--hand-window`` of the server's clock.

+  For a client that supports it, the reply also serves as this server's
+  reset packet, letting the client start its handshake from it and save a
+  round trip. The reply carries how long it may be used for that, derived
+  from ``--hand-window``: lowering ``--hand-window`` shortens that window
+  as well.
+
 --stale-routes-check args
   Remove routes which haven't had activity for ``n`` seconds (i.e. the ageing
   time).  This check is run every ``t`` seconds (i.e. check interval).
diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c
index ab4cbb4..c3b076e 100644
--- a/src/openvpn/mudp.c
+++ b/src/openvpn/mudp.c
@@ -258,12 +258,27 @@
             return false;
         }

+        /* A tls-crypt-v2 client must resend the WKc if it later uses this 
reply
+         * to start a handshake, since we keep no state. */
+        uint32_t reply_flags =
+            (verdict == VERDICT_VALID_OOB_WKC_V1) ? 
OOB_PROBE_REPLY_FLAG_RESEND_WKC : 0;
+
+        /* The client's third packet validates only while its SYN-cookie does, 
so
+         * the advertised connect_lifetime is inferred (not configurable): the
+         * guaranteed cookie window of ~handshake_window (2 quantised buckets; 
see
+         * check_session_hmac_and_pkt_id). Advertising more would make the 
client
+         * trust an already-expired cookie. (RFC: connect_lifetime is how long 
the
+         * server considers the reply valid.) */
+        int connect_lifetime = min_int(2 * ((handwindow + 1) / 2), 0xffff);
+
         /* the echo of the peer's session id, plus what we advertise */
         struct oob_probe_reply reply = {
             .peer_session_id = state->peer_session_id,
             .priority = (uint16_t)m->top.options.server_probe_reply_priority,
             .weight = (uint16_t)m->top.options.server_probe_reply_weight,
             .max_latency_diff = 
(uint16_t)m->top.options.server_probe_reply_max_latency_diff,
+            .connect_lifetime = (uint16_t)connect_lifetime,
+            .flags = reply_flags,
         };

         /* Our session id is a stateless SYN cookie (the same HMAC the 
three-way
diff --git a/src/openvpn/oob.h b/src/openvpn/oob.h
index e76745d..c12c5c4 100644
--- a/src/openvpn/oob.h
+++ b/src/openvpn/oob.h
@@ -159,6 +159,12 @@
  */
 bool oob_timestamp_in_window(uint64_t probe_ts, uint64_t now, uint64_t 
window_secs);

+/* probe_reply flags (the reply TLV's 32-bit flags field) */
+/* bit 0: the client must resend the wrapped client key (via P_CONTROL_WKC_V1)
+ * when it completes the handshake started from this reply. Set
+ * by a tls-crypt-v2 server, which is stateless and discarded the WKc. */
+#define OOB_PROBE_REPLY_FLAG_RESEND_WKC 0x1
+
 /**
  * Decide whether a received SERVER_PROBE is answered. Combines
  * oob_server_probe_read() and oob_timestamp_in_window(): the probe is dropped

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1768?usp=email
To unsubscribe, or for help writing mail filters, visit 
http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib2b6c2246f9d9c0a505292ee8d879f714901ffae
Gerrit-Change-Number: 1768
Gerrit-PatchSet: 18
Gerrit-Owner: stipa <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to