Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@philipch07
Copy link
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

codecov bot commented Oct 26, 2025

Codecov Report

❌ Patch coverage is 91.01124% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.26%. Comparing base (7b68bd9) to head (a0986ed).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
pkg/protocol/extension/key_share.go 93.10% 3 Missing and 3 partials ⚠️
pkg/protocol/extension/extension.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #749      +/-   ##
==========================================
+ Coverage   79.13%   81.26%   +2.12%     
==========================================
  Files         102      102              
  Lines        6917     5679    -1238     
==========================================
- Hits         5474     4615     -859     
+ Misses       1068      683     -385     
- Partials      375      381       +6     
Flag Coverage Δ
go 81.26% <91.01%> (+2.10%) ⬆️
wasm ?

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
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
@JoeTurki
Copy link
Member

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

Copy link
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.

Comment on lines +50 to +57
seenGroups := []elliptic.Curve{}

for _, e := range k.ClientShares {
if slices.Contains(seenGroups, e.Group) {
return nil, errDuplicateKeyShare
}

seenGroups = append(seenGroups, e.Group)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think it would be better to have seenGroups be a map instead of a slice since we only use it to check for the existence of a group and we never have to traverse it?

Comment on lines +116 to +132
seenGroups := []elliptic.Curve{}
for !peek.Empty() {
var entry KeyShareEntry
var groupU16 uint16
var raw cryptobyte.String

if !peek.ReadUint16(&groupU16) || !peek.ReadUint16LengthPrefixed(&raw) {
return errInvalidKeyShareFormat
}

group := elliptic.Curve(groupU16)

if slices.Contains(seenGroups, group) {
return errDuplicateKeyShare
}

seenGroups = append(seenGroups, group)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

And same for here?

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