Skip to content

Commit

Permalink
Merge pull request #655 from adotkhan/utls-fix
Browse files Browse the repository at this point in the history
Fix uTLS KeyShareExtensionCompat unmarshalling
  • Loading branch information
rod-hynes authored Sep 11, 2023
2 parents d942898 + d021af1 commit 728964f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions psiphon/common/protocol/customTLSProfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,19 @@ type GenericExtensionCompat utls.GenericExtension
type UtlsExtendedMasterSecretExtensionCompat utls.UtlsExtendedMasterSecretExtension
type UtlsGREASEExtensionCompat utls.UtlsGREASEExtension
type UtlsPaddingExtensionCompat utls.UtlsPaddingExtension
type KeyShareExtensionCompat utls.KeyShareExtension
type PSKKeyExchangeModesExtensionCompat utls.PSKKeyExchangeModesExtension
type SupportedVersionsExtensionCompat utls.SupportedVersionsExtension
type FakeChannelIDExtensionCompat utls.FakeChannelIDExtension
type UtlsCompressCertExtensionCompat utls.UtlsCompressCertExtension
type FakeRecordSizeLimitExtensionCompat utls.FakeRecordSizeLimitExtension
type ApplicationSettingsExtensionCompat utls.ApplicationSettingsExtension
type DelegatedCredentialsExtensionCompat utls.DelegatedCredentialsExtension
type KeyShareExtensionCompat struct {
KeyShares []struct {
Group utls.CurveID
Data []byte
}
}

// Validate checks that the profiles in CustomTLSProfiles are initialized and
// have no name conflicts.
Expand Down Expand Up @@ -222,7 +227,15 @@ func (e *UTLSExtension) GetUTLSExtension() (utls.TLSExtension, error) {
if err != nil {
return nil, errors.Trace(err)
}
extension := utls.KeyShareExtension(compat)
extension := utls.KeyShareExtension{
KeyShares: make([]utls.KeyShare, len(compat.KeyShares)),
}
for i, keyShare := range compat.KeyShares {
extension.KeyShares[i] = utls.KeyShare{
Group: keyShare.Group,
Data: keyShare.Data,
}
}
return &extension, nil
case "PSKKeyExchangeModes":
var compat PSKKeyExchangeModesExtensionCompat
Expand Down

0 comments on commit 728964f

Please sign in to comment.