Skip to content

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

Merged
merged 4 commits into from
May 1, 2025
Merged

Add kernel connection API #2370

merged 4 commits into from
May 1, 2025

Conversation

swlynch99
Copy link
Contributor

This is an attempt at addressing #2362 by following the API suggested there.

It introduces a new ExternalConnection type which allows users to pass received session tickets back to rustls and perform key updates. An ExternalConnection can be constructed from an Unbuffered(Client|Server)Connection by calling dangerous_into_external_connection which will return both an ExtractedSecrets and an ExternalConnection. 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 ExternalState trait and a State::into_external_state conversion method. ExternalState is implemented for the ExpectTraffic state 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 ExternalConnection with a kTLS connection. It ends up serving more as an example in getting kTLS to work using rustls than actually using ExternalConnection, since ExternalConnection has 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

@swlynch99 swlynch99 force-pushed the external-connection branch from aed5d2e to ba28d0c Compare March 8, 2025 23:57
Copy link
Contributor Author

@swlynch99 swlynch99 left a 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.

Copy link

codecov bot commented Mar 9, 2025

Codecov Report

Attention: Patch coverage is 64.31535% with 86 lines in your changes missing coverage. Please review.

Project coverage is 95.57%. Comparing base (ffac73a) to head (e8c9bb0).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
rustls/src/conn/kernel.rs 55.55% 24 Missing ⚠️
rustls/src/client/tls13.rs 59.64% 23 Missing ⚠️
rustls/src/server/tls13.rs 34.61% 17 Missing ⚠️
rustls/src/client/tls12.rs 47.05% 9 Missing ⚠️
rustls/src/server/tls12.rs 57.14% 6 Missing ⚠️
rustls/src/conn.rs 86.20% 4 Missing ⚠️
rustls/src/common_state.rs 0.00% 3 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@swlynch99 swlynch99 force-pushed the external-connection branch from ba28d0c to 328b854 Compare March 9, 2025 01:37
@ctz
Copy link
Member

ctz commented Mar 12, 2025

First, I think the dangerous_into_external_connection() API is an excellent way to do this and maybe I'd go further to suggest that this PR could deprecate the dangerous_extract_secrets() API, and eviscerate its internal implementation (eg, by making dangerous_extract_secrets() just do let (secrets, _) = self.dangerous_into_external_connection()?; Ok(secrets)).

I think there is space here to reduce the public API scope of ExternalConnection quite a bit. Observing the idea that KTLS users are exchanging complexity for big performance and density improvements, I think that committing to keeping things like the peer's certificate around while servicing the connection is not in keeping with that goal. So I would suggest removing much of that API surface for now -- since the caller needs to ensure the handshake is complete before calling dangerous_into_external_connection(), if they need the peer certificate, handshake shape, ALPN, etc, they can obtain this before the conversion. (That doesn't stop us from having to store it internally, but gives us some future leeway in how we do that to improve density.)

@djc
Copy link
Member

djc commented Mar 12, 2025

Agreed. Also, a bit of bikeshedding: I don't love External as it feels a little generic. Was thinking maybe Traffic would be a good prefix for this that is a little more meaningful in communicating how it's different?

@swlynch99 swlynch99 force-pushed the external-connection branch from 7dcce81 to 0d3c502 Compare March 13, 2025 08:12
@swlynch99
Copy link
Contributor Author

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 made ExternalConnection generic over Data so that users with a server-side connection cannot call handle_new_session_ticket. This is currently just a facade using PhantomData over non-generic internals but it gives freedom in the future if something needs access to Data. My main motivation for this, though, is disallowing calls to handle_new_session_ticket on server side connections.
  • I have removed a bunch of the public API methods from ExternalConnection.
  • I have reimplemented dangerous_into_secrets on top of dangerous_into_external_connection. The one change in behaviour is that it now emits an error if there are messages stored in sendable_tls instead of giving unusable secrets.

I'd go further to suggest that this PR could deprecate the dangerous_extract_secrets() API, and eviscerate its internal implementation.

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 think there is space here to reduce the public API scope of ExternalConnection quite a bit.

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 ExternalConnection, unfortunately, since the quic data is ~600B and everything else is ~80B.

I don't love External as it feels a little generic. Was thinking maybe Traffic would be a good prefix for this that is a little more meaningful in communicating how it's different?

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 ExternalConnection was something like "it's a connection that's managed externally to rustls" -> ExternalConnection. Not sure if that makes it better or worse.

TrafficConnection sounds a little off to me. It might be because all the other prefixes are adjectives?. As an alternative, what if we just called it Connection like in the quic module? Then you have external::Connection, external::ClientConnection, and external::ServerConnection. I'm not sure if that's better, on second thought, but I'll leave it here as an alternative.

@djc
Copy link
Member

djc commented Mar 13, 2025

TrafficConnection sounds a little off to me. It might be because all the other prefixes are adjectives?. As an alternative, what if we just called it Connection like in the quic module? Then you have external::Connection, external::ClientConnection, and external::ServerConnection. I'm not sure if that's better, on second thought, but I'll leave it here as an alternative.

That's fair. I think my beef with "external" is that it leaves open the question of "external to what"?

@cpu cpu mentioned this pull request Mar 14, 2025
1 task
@swlynch99
Copy link
Contributor Author

@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 TrafficConnection and traffic then I'll do so, if you think it is ok staying as ExternalConnection + external, then I'll leave it as is. I don't have a strong enough opinion on this to stall the PR over it :)

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 dangerous_external_secrets which I will do after naming is settled. Let me know if there is anything I can do to make the review easier, as I realize this is a big PR. Otherwise, I'll leave this until you guys have bandwidth to review.

@djc djc mentioned this pull request Mar 25, 2025
27 tasks
@ctz
Copy link
Member

ctz commented Apr 4, 2025

I don't mind the ExternalConnection naming, but WDYT about KernelConnection?

@swlynch99
Copy link
Contributor Author

I don't have an issue with KernelConnection. I suspect the only user of it is going to be kTLS so I'm happy with that. If you guys are ok with it as well then I'll go ahead and change it.

@swlynch99 swlynch99 force-pushed the external-connection branch 3 times, most recently from 6ce6118 to 5ed7a7d Compare April 4, 2025 18:37
@swlynch99
Copy link
Contributor Author

I have gone ahead and done the rename. I have also deprecated dangerous_extract_secrets in favour of the new dangerous_into_kernel_connection method. Finally, I have cleaned up the commit history into something a bit more coherent.

@djc
Copy link
Member

djc commented Apr 9, 2025

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.

@swlynch99 swlynch99 force-pushed the external-connection branch 3 times, most recently from fac5a48 to c3ad775 Compare April 11, 2025 18:33
@swlynch99 swlynch99 changed the title Add external connection API Add kernel connection API Apr 18, 2025
@swlynch99
Copy link
Contributor Author

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.

Copy link
Member

@ctz ctz left a 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

@swlynch99 swlynch99 force-pushed the external-connection branch 3 times, most recently from 6268f7e to cf4e9a4 Compare April 28, 2025 19:42
@swlynch99
Copy link
Contributor Author

I think that's everything resolved. I have also rebased on main, so everything should be up to date.

Copy link

rustls-benchmarking bot commented Apr 29, 2025

Benchmark results

Instruction counts

Significant differences

⚠️ There are significant instruction count differences

Click to expand
Scenario Baseline Candidate Diff Threshold
handshake_no_resume_aws_lc_rs_1.3_ecdsap384_aes_server 2917004 2910471 -6533 (-0.22%) 0.20%

Other differences

Click to expand
Scenario Baseline Candidate Diff Threshold
handshake_no_resume_aws_lc_rs_1.3_rsa_chacha_server 11563709 11616866 53157 (0.46%) 0.97%
handshake_no_resume_aws_lc_rs_1.2_rsa_aes_server 10472624 10437521 -35103 (-0.34%) 1.14%
handshake_no_resume_aws_lc_rs_1.3_ecdsap384_chacha_client 9960580 9941078 -19502 (-0.20%) 0.90%
handshake_no_resume_aws_lc_rs_1.3_ecdsap384_aes_client 9988050 9970248 -17802 (-0.18%) 1.27%
handshake_session_id_aws_lc_rs_1.2_rsa_aes_client 3874767 3877047 2280 (0.06%) 0.20%
handshake_session_id_ring_1.2_rsa_aes_client 4304664 4307004 2340 (0.05%) 0.20%
handshake_tickets_aws_lc_rs_1.2_rsa_aes_client 4216960 4219240 2280 (0.05%) 0.20%
handshake_tickets_ring_1.2_rsa_aes_client 4568298 4570638 2340 (0.05%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_ecdsap256_aes_client 4748632 4746289 -2343 (-0.05%) 0.56%
handshake_tickets_aws_lc_rs_1.3_rsa_aes_client 78704941 78742559 37618 (0.05%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_ecdsap256_chacha_client 4749798 4747651 -2147 (-0.05%) 0.36%
handshake_tickets_ring_1.2_rsa_aes_server 4758860 4760900 2040 (0.04%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_ecdsap256_chacha_server 2003145 2003980 835 (0.04%) 1.43%
handshake_session_id_aws_lc_rs_1.3_rsa_chacha_client 78433728 78465442 31714 (0.04%) 0.20%
handshake_session_id_ring_1.2_rsa_aes_server 4299134 4300814 1680 (0.04%) 0.24%
handshake_session_id_aws_lc_rs_1.3_rsa_aes_client 78508378 78481044 -27334 (-0.03%) 0.20%
handshake_session_id_aws_lc_rs_1.3_ecdsap384_aes_client 78499287 78525722 26435 (0.03%) 0.20%
handshake_session_id_aws_lc_rs_1.3_ecdsap384_chacha_client 78403974 78429465 25491 (0.03%) 0.20%
handshake_tickets_aws_lc_rs_1.3_rsa_aes_server 56588672 56606138 17466 (0.03%) 0.20%
handshake_session_id_aws_lc_rs_1.3_rsa_chacha_server 55204588 55219195 14607 (0.03%) 0.20%
handshake_session_id_aws_lc_rs_1.3_rsa_aes_server 55290339 55275745 -14594 (-0.03%) 0.20%
handshake_session_id_aws_lc_rs_1.2_rsa_aes_server 3868845 3869745 900 (0.02%) 0.27%
handshake_tickets_aws_lc_rs_1.2_rsa_aes_server 5010484 5011624 1140 (0.02%) 0.20%
handshake_session_id_aws_lc_rs_1.3_ecdsap384_aes_server 55293709 55306129 12420 (0.02%) 0.20%
handshake_session_id_aws_lc_rs_1.3_ecdsap384_chacha_server 55197631 55209647 12016 (0.02%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_rsa_aes_server 11570105 11572455 2350 (0.02%) 1.71%
handshake_tickets_aws_lc_rs_1.3_ecdsap384_chacha_client 78674150 78690070 15920 (0.02%) 0.20%
handshake_tickets_aws_lc_rs_1.3_ecdsap256_chacha_client 78688349 78674058 -14291 (-0.02%) 0.20%
transfer_no_resume_ring_1.2_rsa_aes_server 46189315 46197234 7919 (0.02%) 0.20%
transfer_no_resume_ring_1.3_rsa_aes_server 46284280 46292210 7930 (0.02%) 0.20%
transfer_no_resume_ring_1.3_ecdsap256_aes_server 46291022 46298943 7921 (0.02%) 0.20%
transfer_no_resume_ring_1.3_ecdsap384_aes_server 46294533 46302453 7920 (0.02%) 0.20%
transfer_no_resume_aws_lc_rs_1.2_rsa_aes_server 46397780 46405698 7918 (0.02%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap384_aes_server 46450204 46458123 7919 (0.02%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_rsa_aes_server 46452709 46460624 7915 (0.02%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap256_aes_server 46460615 46468531 7916 (0.02%) 0.20%
handshake_tickets_aws_lc_rs_1.3_rsa_chacha_client 78696988 78684307 -12681 (-0.02%) 0.20%
handshake_tickets_aws_lc_rs_1.3_ecdsap384_aes_client 78716937 78728651 11714 (0.01%) 0.20%
handshake_tickets_aws_lc_rs_1.3_ecdsap384_chacha_server 56554207 56562217 8010 (0.01%) 0.20%
handshake_tickets_aws_lc_rs_1.3_rsa_chacha_server 56556899 56549560 -7339 (-0.01%) 0.20%
handshake_tickets_aws_lc_rs_1.3_ecdsap256_chacha_server 56559859 56552934 -6925 (-0.01%) 0.20%
handshake_tickets_aws_lc_rs_1.3_ecdsap384_aes_server 56603310 56609278 5968 (0.01%) 0.20%
transfer_no_resume_ring_1.3_rsa_chacha_server 80533879 80541809 7930 (0.01%) 0.20%
transfer_no_resume_ring_1.3_ecdsap384_chacha_server 80545423 80553344 7921 (0.01%) 0.20%
transfer_no_resume_ring_1.3_ecdsap256_chacha_server 80540623 80548543 7920 (0.01%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap384_chacha_server 80634523 80642445 7922 (0.01%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap256_chacha_server 80645573 80653496 7923 (0.01%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_rsa_chacha_server 80637664 80645586 7922 (0.01%) 0.20%
handshake_tickets_aws_lc_rs_1.3_ecdsap256_aes_client 78686166 78678722 -7444 (-0.01%) 0.20%
handshake_no_resume_ring_1.3_ecdsap256_chacha_client 3305061 3304842 -219 (-0.01%) 0.26%
handshake_session_id_aws_lc_rs_1.3_ecdsap256_aes_client 78491564 78496569 5005 (0.01%) 0.20%
handshake_tickets_aws_lc_rs_1.3_ecdsap256_aes_server 56586435 56582969 -3466 (-0.01%) 0.20%
handshake_no_resume_aws_lc_rs_1.2_rsa_aes_client 1718956 1719060 104 (0.01%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_ecdsap256_aes_server 2001385 2001489 104 (0.01%) 1.44%
handshake_no_resume_ring_1.3_rsa_aes_client 2333334 2333229 -105 (-0.00%) 0.20%
handshake_no_resume_ring_1.3_rsa_chacha_client 2338983 2338878 -105 (-0.00%) 0.20%
handshake_no_resume_ring_1.2_rsa_aes_client 2245503 2245597 94 (0.00%) 0.20%
handshake_session_id_aws_lc_rs_1.3_ecdsap256_chacha_server 55214288 55212041 -2247 (-0.00%) 0.20%
handshake_tickets_ring_1.3_rsa_chacha_server 32449094 32447924 -1170 (-0.00%) 0.20%
handshake_tickets_ring_1.3_ecdsap256_chacha_server 32452140 32450970 -1170 (-0.00%) 0.20%
handshake_session_id_aws_lc_rs_1.3_ecdsap256_chacha_client 78430984 78428160 -2824 (-0.00%) 0.20%
handshake_tickets_ring_1.3_rsa_aes_server 32551049 32549879 -1170 (-0.00%) 0.20%
handshake_tickets_ring_1.3_ecdsap256_aes_server 32554095 32552925 -1170 (-0.00%) 0.20%
handshake_tickets_ring_1.3_ecdsap384_chacha_server 32452098 32450958 -1140 (-0.00%) 0.20%
handshake_tickets_ring_1.3_ecdsap384_aes_server 32554008 32552868 -1140 (-0.00%) 0.20%
handshake_session_id_ring_1.3_ecdsap384_chacha_server 31991783 31990673 -1110 (-0.00%) 0.20%
handshake_session_id_ring_1.3_ecdsap384_aes_server 32113433 32112323 -1110 (-0.00%) 0.20%
handshake_session_id_ring_1.3_rsa_chacha_server 31988623 31987543 -1080 (-0.00%) 0.20%
handshake_session_id_ring_1.3_ecdsap256_chacha_server 31991584 31990504 -1080 (-0.00%) 0.20%
handshake_session_id_ring_1.3_rsa_aes_server 32110273 32109193 -1080 (-0.00%) 0.20%
handshake_session_id_ring_1.3_ecdsap256_aes_server 32113234 32112154 -1080 (-0.00%) 0.20%
handshake_session_id_aws_lc_rs_1.3_ecdsap256_aes_server 55293058 55294781 1723 (0.00%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_rsa_chacha_client 3585484 3585399 -85 (-0.00%) 0.20%
handshake_no_resume_ring_1.3_ecdsap256_aes_server 1295549 1295521 -28 (-0.00%) 0.20%
handshake_no_resume_ring_1.3_ecdsap256_chacha_server 1296746 1296718 -28 (-0.00%) 0.20%
handshake_session_id_ring_1.3_ecdsap384_chacha_client 30830135 30830769 634 (0.00%) 0.20%
handshake_session_id_ring_1.3_ecdsap384_aes_client 30921425 30922059 634 (0.00%) 0.20%
handshake_session_id_ring_1.3_ecdsap256_chacha_client 30832888 30833518 630 (0.00%) 0.20%
handshake_session_id_ring_1.3_rsa_chacha_client 30837074 30837704 630 (0.00%) 0.20%
handshake_session_id_ring_1.3_ecdsap256_aes_client 30924178 30924808 630 (0.00%) 0.20%
handshake_session_id_ring_1.3_rsa_aes_client 30928364 30928994 630 (0.00%) 0.20%
handshake_tickets_ring_1.3_ecdsap384_chacha_client 31148357 31148991 634 (0.00%) 0.20%
handshake_tickets_ring_1.3_ecdsap384_aes_client 31219607 31220241 634 (0.00%) 0.20%
handshake_tickets_ring_1.3_ecdsap256_chacha_client 31151592 31152222 630 (0.00%) 0.20%
handshake_tickets_ring_1.3_rsa_chacha_client 31155650 31156280 630 (0.00%) 0.20%
handshake_tickets_ring_1.3_ecdsap256_aes_client 31222863 31223493 630 (0.00%) 0.20%
handshake_tickets_ring_1.3_rsa_aes_client 31226921 31227551 630 (0.00%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_rsa_aes_client 3578911 3578966 55 (0.00%) 0.20%
handshake_no_resume_aws_lc_rs_1.3_ecdsap384_chacha_server 2913616 2913600 -16 (-0.00%) 0.20%
handshake_no_resume_ring_1.3_ecdsap384_aes_server 7227184 7227152 -32 (-0.00%) 0.20%
handshake_no_resume_ring_1.3_ecdsap384_chacha_server 7229151 7229121 -30 (-0.00%) 0.20%
handshake_no_resume_ring_1.2_rsa_aes_server 10996746 10996791 45 (0.00%) 0.20%
handshake_no_resume_ring_1.3_ecdsap384_chacha_client 34743199 34743102 -97 (-0.00%) 0.20%
handshake_no_resume_ring_1.3_ecdsap256_aes_client 3303463 3303472 9 (0.00%) 0.26%
handshake_no_resume_ring_1.3_rsa_aes_server 11124883 11124855 -28 (-0.00%) 0.20%
handshake_no_resume_ring_1.3_rsa_chacha_server 11130644 11130616 -28 (-0.00%) 0.20%
handshake_no_resume_ring_1.3_ecdsap384_aes_client 34741460 34741378 -82 (-0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_rsa_aes_client 58256236 58256221 -15 (-0.00%) 0.20%
transfer_no_resume_ring_1.2_rsa_aes_client 58041272 58041282 10 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap256_aes_client 58231415 58231406 -9 (-0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsap384_chacha_client 92668095 92668084 -11 (-0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap384_aes_client 58231955 58231949 -6 (-0.00%) 0.20%
transfer_no_resume_ring_1.3_rsa_chacha_client 92690553 92690562 9 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.2_rsa_aes_client 58163193 58163188 -5 (-0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap384_chacha_client 92696594 92696589 -5 (-0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsap256_aes_client 58122625 58122627 2 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_ecdsap256_chacha_client 92696056 92696059 3 (0.00%) 0.20%
transfer_no_resume_aws_lc_rs_1.3_rsa_chacha_client 92722145 92722147 2 (0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsap384_aes_client 58129837 58129838 1 (0.00%) 0.20%
transfer_no_resume_ring_1.3_rsa_aes_client 58154236 58154236 0 (0.00%) 0.20%
transfer_no_resume_ring_1.3_ecdsap256_chacha_client 92658961 92658961 0 (0.00%) 0.20%

Wall-time

Significant differences

There are no significant wall-time differences

Other differences

Click to expand
Scenario Baseline Candidate Diff Threshold
transfer_no_resume_aws_lc_rs_1.3_ecdsap256_aes 4.77 ms 4.66 ms -0.11 ms (-2.36%) 5.05%
transfer_no_resume_aws_lc_rs_1.2_rsa_aes 5.17 ms 5.06 ms -0.11 ms (-2.18%) 6.25%
transfer_no_resume_aws_lc_rs_1.3_rsa_aes 5.44 ms 5.32 ms -0.11 ms (-2.11%) 5.42%
transfer_no_resume_ring_1.3_ecdsap256_aes 5.46 ms 5.35 ms -0.11 ms (-2.04%) 4.11%
transfer_no_resume_ring_1.3_rsa_aes 5.96 ms 5.84 ms -0.12 ms (-1.95%) 3.72%
transfer_no_resume_aws_lc_rs_1.3_ecdsap384_aes 5.46 ms 5.35 ms -0.11 ms (-1.95%) 4.39%
transfer_no_resume_ring_1.2_rsa_aes 5.89 ms 5.77 ms -0.11 ms (-1.95%) 4.81%
handshake_no_resume_ring_1.3_ecdsap256_chacha 479.06 µs 472.33 µs -6.72 µs (-1.40%) 2.80%
transfer_no_resume_ring_1.3_ecdsap384_aes 8.57 ms 8.45 ms -0.12 ms (-1.38%) 2.12%
handshake_no_resume_aws_lc_rs_1.3_ecdsap256_chacha 671.67 µs 662.41 µs -9.26 µs (-1.38%) 3.75%
handshake_no_resume_aws_lc_rs_1.3_ecdsap256_aes 671.55 µs 662.40 µs -9.16 µs (-1.36%) 3.75%
handshake_tickets_aws_lc_rs_1.2_rsa_aes 1.84 ms 1.82 ms -0.03 ms (-1.36%) 3.42%
handshake_no_resume_ring_1.3_ecdsap256_aes 480.72 µs 475.00 µs -5.72 µs (-1.19%) 2.60%
transfer_no_resume_ring_1.3_ecdsap256_chacha 13.03 ms 12.92 ms -0.12 ms (-0.88%) 1.95%
transfer_no_resume_aws_lc_rs_1.3_ecdsap256_chacha 13.25 ms 13.13 ms -0.11 ms (-0.85%) 1.72%
transfer_no_resume_aws_lc_rs_1.3_ecdsap384_chacha 13.93 ms 13.82 ms -0.12 ms (-0.84%) 1.81%
transfer_no_resume_ring_1.3_rsa_chacha 13.52 ms 13.41 ms -0.11 ms (-0.83%) 1.77%
transfer_no_resume_aws_lc_rs_1.3_rsa_chacha 13.92 ms 13.81 ms -0.11 ms (-0.81%) 2.14%
handshake_tickets_aws_lc_rs_1.3_ecdsap256_chacha 10.79 ms 10.72 ms -0.08 ms (-0.73%) 2.04%
transfer_no_resume_ring_1.3_ecdsap384_chacha 16.14 ms 16.02 ms -0.11 ms (-0.70%) 1.27%
handshake_session_id_aws_lc_rs_1.3_ecdsap256_chacha 10.59 ms 10.52 ms -0.07 ms (-0.70%) 1.60%
handshake_no_resume_ring_1.2_rsa_aes 963.79 µs 957.23 µs -6.55 µs (-0.68%) 1.06%
handshake_tickets_ring_1.3_ecdsap256_chacha 5.59 ms 5.56 ms -0.04 ms (-0.64%) 1.00%
handshake_session_id_aws_lc_rs_1.3_rsa_chacha 11.28 ms 11.20 ms -0.07 ms (-0.64%) 1.51%
handshake_session_id_aws_lc_rs_1.3_ecdsap384_chacha 11.26 ms 11.19 ms -0.07 ms (-0.62%) 1.12%
handshake_no_resume_aws_lc_rs_1.3_rsa_chacha 1.34 ms 1.33 ms -0.01 ms (-0.62%) 8.94%
handshake_tickets_aws_lc_rs_1.3_ecdsap384_chacha 11.47 ms 11.40 ms -0.07 ms (-0.62%) 2.13%
handshake_tickets_aws_lc_rs_1.3_rsa_chacha 11.47 ms 11.41 ms -0.07 ms (-0.58%) 1.88%
handshake_session_id_aws_lc_rs_1.3_ecdsap256_aes 10.62 ms 10.56 ms -0.06 ms (-0.58%) 1.87%
handshake_no_resume_ring_1.3_rsa_chacha 967.88 µs 962.33 µs -5.55 µs (-0.57%) 1.37%
handshake_no_resume_ring_1.3_rsa_aes 967.96 µs 962.57 µs -5.39 µs (-0.56%) 1.31%
handshake_session_id_aws_lc_rs_1.3_ecdsap384_aes 11.30 ms 11.24 ms -0.06 ms (-0.53%) 1.25%
handshake_session_id_ring_1.3_rsa_aes 6.05 ms 6.01 ms -0.03 ms (-0.52%) 1.00%
handshake_session_id_aws_lc_rs_1.3_rsa_aes 11.31 ms 11.25 ms -0.06 ms (-0.52%) 1.26%
handshake_session_id_ring_1.3_ecdsap256_chacha 5.52 ms 5.49 ms -0.03 ms (-0.51%) 1.00%
handshake_tickets_ring_1.3_rsa_chacha 6.08 ms 6.04 ms -0.03 ms (-0.50%) 1.00%
handshake_session_id_aws_lc_rs_1.2_rsa_aes 1.65 ms 1.66 ms 0.01 ms (0.50%) 3.72%
handshake_tickets_ring_1.3_ecdsap256_aes 5.62 ms 5.59 ms -0.03 ms (-0.49%) 1.18%
handshake_tickets_aws_lc_rs_1.3_ecdsap256_aes 10.80 ms 10.75 ms -0.05 ms (-0.48%) 1.90%
handshake_tickets_ring_1.3_rsa_aes 6.11 ms 6.08 ms -0.03 ms (-0.47%) 1.05%
handshake_session_id_ring_1.3_ecdsap256_aes 5.55 ms 5.52 ms -0.03 ms (-0.47%) 1.10%
handshake_session_id_ring_1.3_rsa_chacha 6.01 ms 5.98 ms -0.03 ms (-0.46%) 1.00%
handshake_no_resume_aws_lc_rs_1.3_rsa_aes 1.34 ms 1.33 ms -0.01 ms (-0.45%) 5.67%
handshake_tickets_aws_lc_rs_1.3_ecdsap384_aes 11.49 ms 11.44 ms -0.05 ms (-0.45%) 1.37%
handshake_no_resume_aws_lc_rs_1.2_rsa_aes 1.10 ms 1.09 ms -0.00 ms (-0.41%) 6.24%
handshake_no_resume_aws_lc_rs_1.3_ecdsap384_chacha 1.35 ms 1.34 ms -0.01 ms (-0.41%) 1.56%
handshake_tickets_aws_lc_rs_1.3_rsa_aes 11.48 ms 11.43 ms -0.05 ms (-0.41%) 2.46%
handshake_tickets_ring_1.3_ecdsap384_chacha 8.69 ms 8.66 ms -0.03 ms (-0.38%) 1.00%
handshake_no_resume_aws_lc_rs_1.3_ecdsap384_aes 1.36 ms 1.35 ms -0.00 ms (-0.36%) 1.51%
handshake_session_id_ring_1.3_ecdsap384_aes 8.65 ms 8.61 ms -0.03 ms (-0.35%) 1.00%
handshake_session_id_ring_1.3_ecdsap384_chacha 8.62 ms 8.59 ms -0.03 ms (-0.33%) 1.00%
handshake_tickets_ring_1.3_ecdsap384_aes 8.72 ms 8.69 ms -0.03 ms (-0.33%) 1.00%
handshake_no_resume_ring_1.3_ecdsap384_aes 3.58 ms 3.58 ms -0.01 ms (-0.26%) 1.00%
handshake_session_id_ring_1.2_rsa_aes 1.52 ms 1.52 ms 0.00 ms (0.23%) 2.24%
handshake_tickets_ring_1.2_rsa_aes 1.61 ms 1.60 ms -0.00 ms (-0.21%) 1.61%
handshake_no_resume_ring_1.3_ecdsap384_chacha 3.58 ms 3.58 ms -0.01 ms (-0.17%) 1.00%

Additional information

Historical results

Checkout details:

Copy link
Member

@djc djc left a 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.
@swlynch99 swlynch99 force-pushed the external-connection branch from cf4e9a4 to e8c9bb0 Compare April 30, 2025 23:02
@djc djc enabled auto-merge May 1, 2025 04:58
@djc djc added this pull request to the merge queue May 1, 2025
Merged via the queue into rustls:main with commit 9509626 May 1, 2025
30 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better support for kTLS
3 participants