Skip to content

Add the key share extension#749

Merged
theodorsm merged 5 commits intomasterfrom
pch07/add-key-share-ext
Jan 7, 2026
Merged

Add the key share extension#749
theodorsm merged 5 commits intomasterfrom
pch07/add-key-share-ext

Conversation

@philipch07
Copy link
Copy Markdown
Contributor

@philipch07 philipch07 commented Oct 12, 2025

Description

This adds the supported_versions extension feature in accordance with DTLS v1.3 which refers to TLS 1.3 section 4.2.8, 4.2.8.1, and 4.2.8.2.

Note about the ci failures:
This currently uses a global variable to test that my current logic is valid, so it will break all the DTLS v1.2 tests. At the moment, this is blocked by #738 as it requires a proper config/switch. I'm not sure what the best way of setting the toggle would be in extensions.go, but hopefully my current approach makes some sense.

Reference issue

Closes #743.

@philipch07 philipch07 linked an issue Oct 12, 2025 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 26, 2025

Codecov Report

❌ Patch coverage is 90.80460% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.43%. Comparing base (7a57e26) to head (293cc15).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/protocol/extension/key_share.go 92.94% 3 Missing and 3 partials ⚠️
pkg/protocol/extension/extension.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #749      +/-   ##
==========================================
+ Coverage   81.34%   81.43%   +0.09%     
==========================================
  Files         101      102       +1     
  Lines        5602     5689      +87     
==========================================
+ Hits         4557     4633      +76     
- Misses        672      679       +7     
- Partials      373      377       +4     
Flag Coverage Δ
go 81.43% <90.80%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@theodorsm
Copy link
Copy Markdown
Member

theodorsm commented Oct 27, 2025

Thanks for this draft! I have made some adjustments to your suggestion.

I have taken inspiration from the TLS 1.3 implementation in the standard library where they reuse TLS 1.2 types and extensions rather than renaming or creating new - this simplified the implementation a lot. Additionally, I think we should only stick to the groups supported by the standard library and the TLS 1.3 implementation.

Tests were a bit flaky with marshaling and unmarshaling in the same test. Therefore, I added tests with raw bytes captured from the NSS stack of Firefox with Wireshark (pro tip: you can copy bytes as a Go literal) and some handcrafted bytes.

@theodorsm theodorsm marked this pull request as ready for review October 27, 2025 00:18
@theodorsm theodorsm force-pushed the pch07/add-key-share-ext branch from 27c0863 to a0986ed Compare October 27, 2025 00:24
@theodorsm theodorsm requested review from JoTurk and Sean-Der October 27, 2025 00:35
@JoTurk
Copy link
Copy Markdown
Member

JoTurk commented Oct 27, 2025

@philipch07 @theodorsm thank you <3 i'm going to read the spec and submit a review this week 👍

Copy link
Copy Markdown
Contributor Author

@philipch07 philipch07 left a comment

Choose a reason for hiding this comment

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

@theodorsm Thank you for the changes!! It's much cleaner now and I like the approach that you took regarding the renaming.

I wonder if there's a way that we can be extra clear in the docs about the renaming since the filename may be misleading for readers, but I don't have an answer to that off the top of my head. The comments that you added are still very useful.

@theodorsm theodorsm force-pushed the pch07/add-key-share-ext branch from faa49a2 to 4cfd7cd Compare October 27, 2025 21:47
@theodorsm
Copy link
Copy Markdown
Member

theodorsm commented Oct 27, 2025

@philipch07 thanks for the feedback. Regarding naming, we could change it to something like supported_groups_and_elliptic_curves. I think the comment is enough, as it will be shown to a developer using this package in the generated documentation and by LSP servers.

@philipch07
Copy link
Copy Markdown
Contributor Author

@theodorsm That sounds good to me, and thanks for the updates. I'm looking forward to @joeturki's review and then I think we should be good to go if you're feeling good about it! I'm really happy to see the progress so far :)

Copy link
Copy Markdown
Member

@JoTurk JoTurk left a comment

Choose a reason for hiding this comment

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

two comments. sorry i lost track of this.

@theodorsm
Copy link
Copy Markdown
Member

@JoTurk, thanks for the review! (no worries about forgetting) I have fixed your comments.

@theodorsm theodorsm requested a review from JoTurk January 6, 2026 18:16
@philipch07
Copy link
Copy Markdown
Contributor Author

@theodorsm Thanks for updating this! Sorry I was busy recently. I would approve it but I can't since I'm the PR author 😅

Copy link
Copy Markdown
Member

@JoTurk JoTurk left a comment

Choose a reason for hiding this comment

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

Thank you for the fixes theo, and welcome back :)

@theodorsm theodorsm force-pushed the pch07/add-key-share-ext branch from afa0502 to 293cc15 Compare January 7, 2026 12:50
@theodorsm theodorsm merged commit e0d3160 into master Jan 7, 2026
19 of 20 checks passed
@theodorsm theodorsm deleted the pch07/add-key-share-ext branch January 7, 2026 12:54
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.

DTLS v1.3 key_share extension

3 participants