Floating: Add support for floating in TLS mode
A message that is not in the archive (sent off-list or not yet received): [email protected]...
Hi,
no comments for this patch? It is really cool if you roam from wifi to edge on mobiles, you are immediately reconnected to your vpn after a connection change. No 1 minute wait for openvpn to complete the openvpn authentication. (cause is the ~1s GSM EDGE roundtrip time) If you travel in a train through, this will enhance your experience drastically.
I would really appreciate any comments on this, or if you have any hints.
With kind regards,
André
Quoted 4 lines · André Valentin
Add support for floating in tls mode using the HMAC of a packet. It costs a roundtrip through the clients. Because it is based on the HMAC, it is secure in ways of cryptography. Before the iteration starts, some sanity checks are done.
Hi André,
Thank you for coding and sharing! I marked your original mail for later processing, just had not gotten to it yet. This is a cool feature, and it has been proposed before on this list (see
http://thread.gmane.org/gmane.network.openvpn.devel/7384/focus=7395).
That patch did not make it in, primarily because we (or at least I) got distracted by an issue in the crypto code that thread pointed us to, where a non-constant time memcmp was used to compare HMAC's. Unfortunately, after fixing that issue the thread never got the follow-up it deserved.
Returning to your patch, I did not fully review the code, but it at least has the same problem: you are using a non-constant time memcmp to compare HMAC's, which would introduce a possible side-channel vulnerability. The solution is simple: use memcmp_constant_time() from crypto.c.
While taking a peak at your patch I tried to apply it on my local codebase, but got conflicts on both the master and release/2.3 branches. On what commit did you base the patch? It would be nice if it would apply clean to at least the master branch.
Regards,
-Steffan
Quoted 30 lines · André Valentin
Hi,
no comments for this patch? It is really cool if you roam from wifi to edge on mobiles, you are immediately reconnected to your vpn after a connection change. No 1 minute wait for openvpn to complete the openvpn authentication. (cause is the ~1s GSM EDGE roundtrip time) If you travel in a train through, this will enhance your experience drastically.
I would really appreciate any comments on this, or if you have any hints.
With kind regards,
André
Quoted 4 lines · André Valentin
Add support for floating in tls mode using the HMAC of a packet. It costs a roundtrip through the clients. Because it is based on the HMAC, it is secure in ways of cryptography. Before the iteration starts, some sanity checks are done.
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Hi Steffan,
at firsts thanks for taking a review!
Quoted 4 lines · Steffan Karger
Thank you for coding and sharing! I marked your original mail for later processing, just had not gotten to it yet. This is a cool feature, and it has been proposed before on this list (see
http://thread.gmane.org/gmane.network.openvpn.devel/7384/focus=7395).
Yepp, I really wondern when I discovered that it is currently missing.
Quoted 5 lines
Returning to your patch, I did not fully review the code, but it at least has the same problem: you are using a non-constant time memcmp to compare HMAC's, which would introduce a possible side-channel vulnerability. The solution is simple: use
memcmp_constant_time()fromcrypto.c.
No problem, I switched to the standard function because I thought it is not relevant in this scenario where the time "is added".
Quoted 4 lines
While taking a peak at your patch I tried to apply it on my local codebase, but got conflicts on both the master and release/2.3 branches. On what commit did you base the patch? It would be nice if it would apply clean to at least the master branch.
It should, but I will post a fixed patch tonight. Do you want it for master or release2.3?
Kind regards,
André
Hi,
Quoted 2 lines · André Valentin
It should, but I will post a fixed patch tonight. Do you want it for master or release2.3?
Master, please. Everything goes into master first, and if we decide it goes into 2.3, is cherry-picked master->2.3
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Hi!
Quoted 2 lines
Master, please. Everything goes into master first, and if we decide it goes into 2.3, is cherry-picked master->2.3
The last should have been also to master, I do not understand what happend to it...
André
PATCH v3 1/1 Floating: Add support for floating in TLS mode
In reply to a message not in the archiveHi!
This updates my floating patch to current trunk. I tested it for over 2 weeks now. Please review!
André
From bab19ca1b1f1b89dca00ca18e258dbe1dacf4891 Mon Sep 17 00:00:00 2001
From: avalentin <[email protected]...>
Date: Tue, 17 Dec 2013 21:51:25 +0000
Subject: [PATCH] Floating: Add support for floating in TLS mode
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Add support for floating in tls mode using the HMAC of a packet. It costs a roundtrip through the client list. Because it is bases on the HMAC, it shoudl be secure. The HMAC calculation is very fast, (~700k/s), so this won't be a problem for medium size servers.
URL: https://community.openvpn.net/openvpn/ticket/49
--- src/openvpn/crypto.c | 55 ++++++++++++++++++++++++ src/openvpn/crypto.h | 4 ++ src/openvpn/mudp.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ src/openvpn/mudp.h | 18 ++++++++ src/openvpn/options.c | 3 ++ src/openvpn/perf.h | 2 + src/openvpn/ssl.c | 28 +++++++++++++ src/openvpn/ssl.h | 6 +++ 8 files changed, 228 insertions(+)
src/openvpn/crypto.c +55 -0
@@ -389,6 +389,61 @@ openvpn_decrypt (struct buffer *buf, struct buffer work, }/* +* This verifies if a packet and its HMAC fit to a crypto context. +* +* On success true is returned. +*/ +bool +crypto_test_hmac (struct buffer *buf, +const struct crypto_options *opt) +{ +struct gc_arena gc; +gc_init (&gc); +int offset =1 ; + +if (buf->len >0 && opt->key_ctx_bi) + { +struct key_ctx *ctx = &opt->key_ctx_bi->decrypt; + +/* Verify the HMAC */ +if (ctx->hmac) + { +int hmac_len; +uint8_t local_hmac[MAX_HMAC_KEY_LENGTH ];/* HMAC of ciphertext computed locally */ + +hmac_ctx_reset (ctx->hmac); + +/* Assume the length of the input HMAC */ + hmac_len =hmac_ctx_size (ctx->hmac); + +/* Authentication fails if insufficient data in packet for HMAC */ +if ((buf->len - offset) < hmac_len) + { +gc_free (&gc); +return false; + } + +hmac_ctx_update (ctx->hmac,BPTR (buf) + offset + hmac_len,BLEN (buf) - offset - hmac_len); +hmac_ctx_final (ctx->hmac, local_hmac); + +/* Compare locally computed HMAC with packet HMAC */ +if (memcmp (local_hmac,BPTR (buf) + offset, hmac_len)) + { +gc_free (&gc); +return false; + } + +gc_free (&gc); +return true; + } + } + +gc_free (&gc); +return false; +} + + +/* * How many bytes will we add to frame buffer for a given * set of crypto options? */
src/openvpn/crypto.h +4 -0
@@ -279,6 +279,10 @@ bool openvpn_decrypt (struct buffer *buf, struct buffer work,const struct crypto_options *opt, const struct frame* frame); + +bool crypto_test_hmac (struct buffer *buf, +const struct crypto_options *opt); +/** @} name Functions for performing security operations on data channel packets */ void crypto_adjust_frame_parameters(struct frame *frame,
src/openvpn/mudp.c +112 -0
124 lines not on this page · raw message
src/openvpn/mudp.h +18 -0
@@ -67,5 +67,23 @@ void tunnel_server_udp (struct context *top);*/ struct multi_instance *multi_get_create_instance_udp (struct multi_context *m); + +/**************************************************************************/ +/** +* Find a client instance based on the HMAC, if auth is used. +* @ingroup external_multiplexer +* +* Find a client instance based on the HMAC, if auth is used. The function +* iterates over all peers to find a fitting instance. The found instance is +* updated with the current peer address. +* +* @param m - The single multi_context structure. +* @param mi - The multi_instance structure. +* @param real - The mroute_addr structure. +* +* @return Boolen, true if peer found, false if not. +*/ +bool multi_find_instance_udp (struct multi_context *m,struct multi_instance *mi,struct mroute_addr real); +#endif #endif
src/openvpn/options.c +3 -0
@@ -166,6 +166,9 @@ static const char usage_message[] = " Set n=\"infinite\" to retry indefinitely.\n" "--float : Allow remote to change its IP address/port, such as through\n" " DHCP (this is the default if --remote is not used).\n" +#ifdef ENABLE_CRYPTO + " In server mode a valid/default auth algo is needed.\n" +#endif"--ipchange cmd : Run command cmd on remote ip address initial\n" " setting or change -- execute as: cmd ip-address port#\n" "--port port : TCP/UDP port # for both local and remote.\n"
src/openvpn/perf.h +2 -0
@@ -57,6 +57,8 @@#define PERF_PROC_OUT_TUN 18#define PERF_PROC_OUT_TUN_MTCP 19#define PERF_N 20 +#define PERF_MULTI_FIND_INSTANCE 21 +#ifdef ENABLE_PERFORMANCE_METRICS
src/openvpn/ssl.c +28 -0
@@ -3448,6 +3448,34 @@ tls_rec_payload (struct tls_multi *multi,return ret; } +/* Update the remote_addr, needed if a client floats. */ +void +tls_update_remote_addr (struct tls_multi *multi, +const struct link_socket_actual *from) +{ +struct gc_arena gc =gc_new (); +int i; + +for (i =0 ; i <KEY_SCAN_SIZE ; ++i) + { +struct key_state *ks = multi->key_scan[i]; +if (DECRYPT_KEY_ENABLED (multi, ks) + && ks->authenticated + &&link_socket_actual_defined (&ks->remote_addr) + ) + { +if (link_socket_actual_match (from, &ks->remote_addr)) +continue ; +dmsg (D_TLS_KEYSELECT , +"TLS: tls_update_remote_addr from IP=%s to IP=%s" , +print_link_socket_actual (&ks->remote_addr, &gc), +print_link_socket_actual (from, &gc)); +memcpy (&ks->remote_addr, from,sizeof (*from)); + } + } +gc_free (&gc); +} +/* * Dump a human-readable rendition of an openvpn packet * into a garbage collectable string which is returned.
src/openvpn/ssl.h +6 -0
@@ -431,6 +431,12 @@ bool tls_send_payload (struct tls_multi *multi,bool tls_rec_payload (struct tls_multi *multi,struct buffer *buf); +/* +* Update remote address of a tls_multi structure +*/ +void tls_update_remote_addr (struct tls_multi *multi, +const struct link_socket_actual *from); +#ifdef MANAGEMENT_DEF_AUTH static inline char *tls_get_peer_info (const struct tls_multi *multi)
Signature · 1 line
1.7.10.4
Hi!
Just for reference, I got my throughput numbers from:
http://thread.gmane.org/gmane.network.openvpn.devel/7384/focus=7395
André
Signature · 18 lines
With kind regards, André Valentin Projektkoordination / Systemadministration MarcanT GmbH, Ravensberger Str. 10 G, D - 33602 Bielefeld Fon: +49 (521) 95945-0 | Fax -18 URL: http://www.marcant.net | http://www.global-m2m.com Geschäftsführer: Thorsten Hojas Handelsregister: AG Bielefeld, HRB 35827 USt-ID Nr.: DE 190203238 ___________________________________________________________ CONFIDENTIALITY NOTICE The contents of this email are confidential to the ordinary user of the email address to which it was addressed and may also be privileged. If you are not the addressee of this email you may not copy, forward, disclose or otherwise use it or any part of it in any form whatsoever. If you have received this email in error please email the sender by replying to this message.
Hi,
Quoted 2 lines · Andre Valentin
Just for reference, I got my throughput numbers from:
http://thread.gmane.org/gmane.network.openvpn.devel/7384/focus=7395
Just so that it has been said :-)
We've discussed the patch on the Munich Hackathon, and we intend to do it in a different way. James wants to change the packet format for data packets anyway (due to bad alignment in the current packet format), and the new format would have the option to send the session ID in the data packet as well, like "normally it's not sent, but if we have't heard from the server longer than <x> time units, send a session ID so that hmac-float will work".
This code has not been written yet, though, and we have no specific timelines when it will happen.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Hi!
Quoted 7 lines · Gert Doering
We've discussed the patch on the Munich Hackathon, and we intend to do it in a different way. James wants to change the packet format for data packets anyway (due to bad alignment in the current packet format), and the new format would have the option to send the session ID in the data packet as well, like "normally it's not sent, but if we have't heard from the server longer than <x> time units, send a session ID so that hmac-float will work".
Of course, this is a better idea and should have less problems with scaling. But there should be an option for the client to always send the session id, so that there are no timeouts if the user decides to do so.
Quoted 2 lines
This code has not been written yet, though, and we have no specific timelines when it will happen.
So what does this mean for my work and the current format? Is there still a possibility that it will be integrated for the 'old packet format'?
André
--
With kind regards,
André Valentin
Projektkoordination / Systemadministration
MarcanT GmbH, Ravensberger Str. 10 G, D - 33602 Bielefeld
Fon: +49 (521) 95945-0 | Fax -18
URL: http://www.marcant.net | http://www.global-m2m.com
Geschäftsführer: Thorsten Hojas
Handelsregister: AG Bielefeld, HRB 35827 USt-ID Nr.: DE 190203238
Quoted 9 lines · André Valentin
Quoted 7 lines · Gert Doering
We've discussed the patch on the Munich Hackathon, and we intend to do it in a different way. James wants to change the packet format for data packets anyway (due to bad alignment in the current packet format), and the new format would have the option to send the session ID in the data packet as well, like "normally it's not sent, but if we have't heard from the server longer than <x> time units, send a session ID so that hmac-float will work".
Quoted 3 lines
Of course, this is a better idea and should have less problems with scaling. But there should be an option for the client to always send the session id, so that there are no timeouts if the user decides to do so.
+1 to that - it'd be really neat if floating would work seamlessly without timeouts + retransmissions. It'd be very useful on mobile devices, which often get hit by NAT timeouts on UDP (around 30 or 60 seconds typically), switches between WIFI and 3G, and keepalive pings with tight timers (sub-30-second range) consume a lot of battery.
The regular SSL session ID is maybe a bit long to be sent with each and every packet, though.
Which other enhancements to the packet format are necessary? I gathered that the encrypted data needs to be aligned for AES-NI to work, which probably means that either the packet headers need to be padded so that the data starts on a nice word boundary, or that the data packet needs to begin with the encrypted data and all the headers need to be placed in the end of the packet. Right?
And then some backwards compatibility in the handshake - it'd be good if old clients could optionally be allowed on new servers using the new packet format.
Quoted 4 lines
Quoted 2 lines
This code has not been written yet, though, and we have no specific timelines when it will happen.
So what does this mean for my work and the current format? Is there still a possibility that it will be integrated for the 'old packet format'?
We could also start working on the new packet format, do a prototype if you'd like. Just need to figure out what the exact requirements would be.
- Hessu
Am 30.12.13 16:10, schrieb Heikki Hannikainen:
Quoted 21 lines · André Valentin
Quoted 11 lines · Gert Doering
Quoted 7 lines
We've discussed the patch on the Munich Hackathon, and we intend to do it in a different way. James wants to change the packet format for data packets anyway (due to bad alignment in the current packet format), and the new format would have the option to send the session ID in the data packet as well, like "normally it's not sent, but if we have't heard from the server longer than <x> time units, send a session ID so that hmac-float will work".
Of course, this is a better idea and should have less problems with scaling. But there should be an option for the client to always send the session id, so that there are no timeouts if the user decides to do so.
+1 to that - it'd be really neat if floating would work seamlessly without timeouts + retransmissions. It'd be very useful on mobile devices, which often get hit by NAT timeouts on UDP (around 30 or 60 seconds typically), switches between WIFI and 3G, and keepalive pings with tight timers (sub-30-second range) consume a lot of battery.
The regular SSL session ID is maybe a bit long to be sent with each and every packet, though.
Quoted 6 lines
Which other enhancements to the packet format are necessary? I gathered that the encrypted data needs to be aligned for AES-NI to work, which probably means that either the packet headers need to be padded so that the data starts on a nice word boundary, or that the data packet needs to begin with the encrypted data and all the headers need to be placed in the end of the packet. Right?
Compression does a bit different to achieve compatiblity. The first byte has flag bit that says "The last byte is actually the first" and openvpn will then overwrite the first byte with the last after evaluating the header byte.
The AES-NI instruction are SEE instructions and work on the XMM registers (and not directly on memory), so aligingment is not an issue for AES-NI instructions itself but unaligned load/stores are always slowers.
Quoted 5 lines
And then some backwards compatibility in the handshake - it'd be good if old clients could optionally be allowed on new servers using the new packet format.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
This code has not been written yet, though, and we have no specific timelines when it will happen.
So what does this mean for my work and the current format? Is there still a possibility that it will be integrated for the 'old packet format'?
We could also start working on the new packet format, do a prototype if you'd like. Just need to figure out what the exact requirements would be.
For negoating the packet format the client would submit something like IV_CLNT_SUPPORT 1 or similar (look at the IV_SNAPPY, IV_LZO for compression) to tell the server the supported format and the server would push a packet-format 1 or something similar like that. For a first prototype implementation having only the packet-format 1 is probably good enough.
The basic idea for the new packet format is having a flag in the packet saying "This is the new format" and then having the payload aligned either in the same way as the compression. If we choose the session id to be 3 or 7 byte we would not need the "hack" for the packets with session id.
Arne
Hi Arne,
I am researching how "session id" can be added to packet. Could you please clarify the statement "If we choose the session id to be 3 or 7 byte we would not need the "hack" for the packets with
session id." ?
I am currently at very beginning, so questions might look odd.
1) "3 or 7" - does it mean byte's ordinal number in packet or length of session id in bytes?
2) What you mean by "hack"? Do you mean new packet format or something else?
3) I am trying to comprehend protocol format reading
http://openvpn.net/index.php/open-source/documentation/security-
overview.html and looking at wireshark capture results. Where exactly session id field should be placed?
-Lev
Am 03.01.14 12:58, schrieb Lev Stipakov:
Quoted 11 lines
Hi Arne,
I am researching how "session id" can be added to packet. Could you please clarify the statement "If we choose the session id to be 3 or 7 byte we would not need the "hack" for the packets with
session id." ?I am currently at very beginning, so questions might look odd.
1) "3 or 7" - does it mean byte's ordinal number in packet or length of session id in bytes?
One header byte +3 byte or +7 byte = 32 bit aligment.
Quoted 2 lines
2) What you mean by "hack"? Do you mean new packet format or something else?
The byte juggling the compress does.
Quoted 4 lines
3) I am trying to comprehend protocol format reading
http://openvpn.net/index.php/open-source/documentation/security-
overview.html and looking at wireshark capture results. Where exactly session id field should be placed?
Not yet decided :)
Arne
Hi,
Quoted 2 lines · Arne Schwabe
Quoted 1 line
2) What you mean by "hack"? Do you mean new packet format or something else?
The byte juggling the compress does.
Actually the "compress byte swap hack" is for the de-crypted material, while *this* discussion is concernced about the encrypted material, which is also unaligned and also wants a byte swap hack :-)
What I'd like to see is a definition of the new data frame format from James (with and without session ID), and then we can go and hack that in
- but before we agree on the frame format, we don't really know what to implement.
Meeting topic... (Samuli, are you listening?).
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Hi!
Quoted 6 lines · Arne Schwabe
For negoating the packet format the client would submit something like
IV_CLNT_SUPPORT1 or similar (look at theIV_SNAPPY,IV_LZOfor compression) to tell the server the supported format and the server would push a packet-format 1 or something similar like that. For a first prototype implementation having only the packet-format 1 is probably good enough.
I'm sorry, but this a bit too much for me to help in this case. If support for testing is needed, I will do that!
Signature · 18 lines
With kind regards, André Valentin Projektkoordination / Systemadministration MarcanT GmbH, Ravensberger Str. 10 G, D - 33602 Bielefeld Fon: +49 (521) 95945-0 | Fax -18 URL: http://www.marcant.net | http://www.global-m2m.com Geschäftsführer: Thorsten Hojas Handelsregister: AG Bielefeld, HRB 35827 USt-ID Nr.: DE 190203238 ___________________________________________________________ CONFIDENTIALITY NOTICE The contents of this email are confidential to the ordinary user of the email address to which it was addressed and may also be privileged. If you are not the addressee of this email you may not copy, forward, disclose or otherwise use it or any part of it in any form whatsoever. If you have received this email in error please email the sender by replying to this message.