Skip to content

feat: Add key update to ktls feature#5484

Merged
maddeleine merged 28 commits intoaws:mainfrom
maddeleine:ktls_keyupdate
Sep 24, 2025
Merged

feat: Add key update to ktls feature#5484
maddeleine merged 28 commits intoaws:mainfrom
maddeleine:ktls_keyupdate

Conversation

@maddeleine
Copy link
Copy Markdown
Contributor

@maddeleine maddeleine commented Aug 25, 2025

Release Summary:

Our kTLS feature can now perform key updates, meaning that kTLS is now safe to turn on in TLS1.3 when using the newest version of the linux kernel.

Resolved issues:

Technically this resolves #3711; I don't believe there is any more work to support kTLS in our library, besides some cleanup PRs I need to do.

Description of changes:

This code adds Key Update functionality to our kTLS feature since it is now available as a kernel patch. Enables us to read key update messages, update our keys, as well as send keyupdate messages.

Call-outs:

I decided against writing a feature probe for key updates. There isn't anything in the patch that is available to feature test and required to use ktls (my original feature probe used the snmp.h metrics, but again, you don't need that header file to do key updates). Additionally, we want this feature to be usable by people who are applying the keyupdate patch to older kernels. So I don't think we can make any assumptions about linux kernel version or linux header file availability.

Testing:

Adds key update to ktls self-talk tests. You can tell that my key update tests are running in CI because if you look at the self_talk test numbers for each job
KTLS job: s2n_self_talk_ktls_test.c ... PASSED 678 tests
KTLS_KeyUpdate job: s2n_self_talk_ktls_test.c ... PASSED 718 tests
So therefore we can tell that the keyupdate job is running more tests than the ktls job.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the s2n-core team label Aug 25, 2025
@lrstewart lrstewart removed the request for review from goatgoose August 25, 2025 23:30
@maddeleine maddeleine changed the title feat: Adding the ability to perform a key update in our ktls feature feat: Add key update to ktls feature Aug 26, 2025
@maddeleine maddeleine requested a review from lrstewart August 28, 2025 21:17
@lrstewart lrstewart self-requested a review September 17, 2025 20:28
Comment on lines +373 to +378
/* Check that the data requested for the ktls send call is not going over the encryption limit,
* as that would require multiple key updates.
* In TLS1.3, the key limit is 2^24.5 full-size records. A full-sized record is 16,384 bytes.
* So essentially 2^24 * 16,384 bytes(285 GB) can be sent before you need to key update.
* We can add logic for multiple key updates in a single ktls send call in the future,
* but it's not required at the moment. */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do this in a follow-up PR if you want, but: we need to add this limitation to our public documentation for ktls. Otherwise, customers won't know what's happening when they get the S2N_ERR_INVALID_ARGUMENT. We might also want to make it a more specific error than S2N_ERR_INVALID_ARGUMENT, if we're worried that the documentation won't be enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'll do it in a follow up PR.

maddeleine and others added 2 commits September 24, 2025 10:17
Co-authored-by: Lindsay Stewart <stewart.r.lindsay@gmail.com>
Co-authored-by: Lindsay Stewart <stewart.r.lindsay@gmail.com>
@maddeleine maddeleine added this pull request to the merge queue Sep 24, 2025
Merged via the queue into aws:main with commit 30f40f2 Sep 24, 2025
50 checks passed
@maddeleine maddeleine deleted the ktls_keyupdate branch September 24, 2025 20:47
dougch pushed a commit to dougch/s2n-tls that referenced this pull request Sep 26, 2025
Co-authored-by: Lindsay Stewart <stewart.r.lindsay@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracking issue: kTLS MVP

4 participants