-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proper DTLS support #7
Comments
For a potential API, we need to separate sync and async entirely, but we should and probably could keep a sync-based "central" struct which handles all the dirty work andsoforth. Note: These design ideas are superseded by ShadowJonathan/DusTLS#1 I'm currently thinking about these sync objects;
And these async objects;
With "multiplexing" i'm reflecting option 2 i had mentioned here, but i've not properly elaborated upon; Whoever is calling listen on the socket at any time, could be awaiting a Condvar (or something like it), or could be performing a raw If a thread is receiving a packet for a source it is not awaiting for, it pushes it to an internal buffer and notifies the corresponding thread to wake up to the new data, while it polls the socket again. This model could also become a base for the async tokio model, in which this would potentially be much more efficient (as awaiting a socket there is event-based). The same could be applied to All of this is needed because |
I've created the multiplexing library here; https://github.com/ShadowJonathan/exit-left |
Currently working on it here; https://github.com/shadowjonathan/dtls-rs |
It seems that DTLS support was more complex than i thought it would be from #3, so i'll use this issue to lay down my thoughts.
Basically, rust-openssl does not have good DTLS support, this is not a significant failure on
rust-openssl
's part, asopenssl
itself is not adhering to the RFC either.See the following section from the RFC;
And compare it to the manpage on
DTLSv1_listen
, to accept incoming DTLS sessions;Looking around a little more, i found an issue pertaining to DTLS support in python trio, which has the following to say about it;
And the following about
openssl
's multiplexing shortcomings;About packets;
About handshakes;
And about the MTU, which i think is the biggest issue here;
TLDR; DTLS startup times might be borked due to packets getting lost by a too-high MTU.
This is relevant for if we want to send packets over ipv4, which have a "worst case MTU" (as found here) of
576
, minus28
bytes of header overhead. This would only enabled sure-fire block-wise transfers of 512, which, together with the problems described in #6, could half the transfer speed. So potentially we would want to set up a "MTU prober" as well somewhere inbetween sending packets and finalizing the handshake, to maximise transfer speeds.I dont want to use Path MTU discovery for this, as it assumes a best-case scenario first, and then backs off when it doesn't encounter one, it could delay a handshake by several RTTs, and we want to be speedy.
The issue also makes me think that DTLS v1.3 is not really "compatible" with 1.0 and 1.2 to a degree, just like TLSv1.3, so support for that might be not "as simple" to multiplex and support simultaneously in an implementation.
Additionally, the issue also has this bit;
...which doesn't exactly inspire confidence to use openssl for this :(
The issue also talks about cookie validation, and how openssl is absolutely not helpful with that.
DTLS handshakes (according to the RFC) also look to be 2 RTTs, but potentially more as packets get lost (due to MTU or the likes).
go-coap
How does
go-coap
deal with this? Well, it uses a "custom" Golang DTLS implementation, completely separated from openssl, thus avoiding most of these issues.I think this doesn't bode entirely well for the ecosystem of DTLS, if this is the state of openssl support, and golang has to roll their own for their own support.
rustls
has an issue open for DTLS support, and i'm suspecting they're facing the same confusion/problems as openssl has for jamming DTLS in there, and the latest comment from a member there reflects this.There exists another implementation of dtls in rust, webrtc has one, but its API is... weird, it's certainly not geared towards low-level implementation such as what we're trying to do.
The text was updated successfully, but these errors were encountered: