-
Notifications
You must be signed in to change notification settings - Fork 753
Add kernel connection API #2370
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
Conversation
aed5d2e to
ba28d0c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few things I'm not quite sure about so I'm putting those here as comments.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2370 +/- ##
==========================================
- Coverage 95.96% 95.57% -0.39%
==========================================
Files 94 95 +1
Lines 22634 22843 +209
==========================================
+ Hits 21721 21833 +112
- Misses 913 1010 +97 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ba28d0c to
328b854
Compare
|
First, I think the I think there is space here to reduce the public API scope of |
|
Agreed. Also, a bit of bikeshedding: I don't love |
7dcce81 to
0d3c502
Compare
|
I'm going to make changes as new commits for now since it is easier to see what is changing. I'll rework things into a more coherent commit history before this gets merged. Quick summary of the new changes before I respond to individual comments:
I have done all of this except the deprecation. I'll add a commit for the deprecation bit once we've decided on the final name for the type.
I have reduced the API surface down to just the negotiated protocol version and the chosen cipher suite. The protocol version needs to be kept anyways and the cipher suite is the only way to get the confidentiality limit (and is needed for kTLS besides). This has not appreciably reduced the size of
Up front, I don't have a strong preference here. This is your bikeshed so ultimately you get the final say :) My thought process behind
|
That's fair. I think my beef with "external" is that it leaves open the question of "external to what"? |
|
@djc I've been thinking on and off about the naming for the last few days and have not been able to come up with a better name. So I'm putting this back on your side of the court: if you want me to rename type+module to I will say that when I named it my thought process was that it is a connection that is "external to rustls". i.e. that the user has to implement the connection themselves, whereas for the other connection types the user just provides/receives bytes and rustls handles the rest. I think I have addressed all the points brought up so far. The only thing left is deprecating |
|
I don't mind the |
|
I don't have an issue with |
6ce6118 to
5ed7a7d
Compare
|
I have gone ahead and done the rename. I have also deprecated |
|
I think this is generally the right direction. I'm on the fence about the example code -- while it's nice to have a worked example, it seems to spend a lot of code on the details of the kernel API, while the API surface we have to maintain in order to make it work appears to be substantially smaller. |
fac5a48 to
c3ad775
Compare
|
Pinging on this. I think I have addressed and/or responded to all the comments, so I'm leaving this comment mostly to mark that I consider this PR to be waiting on a reviewer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few remaining small nits, then i am happy and grateful to approve this
6268f7e to
cf4e9a4
Compare
|
I think that's everything resolved. I have also rebased on |
Benchmark resultsInstruction countsSignificant differencesClick to expand
Other differencesClick to expand
Wall-timeSignificant differencesThere are no significant wall-time differences Other differencesClick to expand
Additional informationCheckout details:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all your work on this!
For kTLS we want to be able to interact with rustls in order to refresh traffic keys and save session tickets for future usage. The remaining parts of the TLS protocol are possible to implement externally provided that the user is willing to put in enough effort. This commit introduces a new API that provides exactly 3 capabilities to the user: 1. Refresh the TX traffic secrets. 2. Refresh the RX traffic secrets. 3. Handle a provided new_session_ticket message and save said session ticket for later use. That's it. Everything else needs to be implemented by the library user.
While dangerous_extract_secrets allows users to extract secrets from a connection there is more to implementing a TLS connection than just encryption and decryption. Just getting the ExtractedSecrets does not allow for handling TLS 1.3 key updates or session tickets. As such, this commit deprecates it in favour of dangerous_into_kernel_connection, which does support both of those things.
cf4e9a4 to
e8c9bb0
Compare
This is an attempt at addressing #2362 by following the API suggested there.
It introduces a new
ExternalConnectiontype which allows users to pass received session tickets back to rustls and perform key updates. AnExternalConnectioncan be constructed from anUnbuffered(Client|Server)Connectionby callingdangerous_into_external_connectionwhich will return both anExtractedSecretsand anExternalConnection. It does not include support any other connection types at this time. However, it should be easy enough to extend in the future as more as new features become needed.Internally this is implemented by adding a new
ExternalStatetrait and aState::into_external_stateconversion method.ExternalStateis implemented for theExpectTrafficstate for tls 1.2 and 1.3, and for server and client modes, respectively.I have also included a complete example that shows how to use
ExternalConnectionwith a kTLS connection. It ends up serving more as an example in getting kTLS to work using rustls than actually usingExternalConnection, sinceExternalConnectionhas a pretty minimal API surface, but I think it works better that way.This PR ended up being quite a bit larger than I thought it would be initially. If there's anything I can do that would help make this easier to review (e.g. moving the ktls example to a separate PR), please let me know.
Closes #2362