Skip to content

Commit

Permalink
Fix to avoid incompatible randomized DTLS ClientHello
Browse files Browse the repository at this point in the history
  • Loading branch information
rod-hynes committed Nov 12, 2024
1 parent d95a003 commit eabb3d0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
27 changes: 27 additions & 0 deletions replace/dtls/flight1handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,33 @@ func flight1Generate(ctx context.Context, c flightConn, state *State, _ *handsha
})
cipherSuites = cipherSuites[:cut(len(cipherSuites))]

// At least one ECC cipher suite needs to be retained for compatibilty
// with the server's ECC certificate. Select from the ECC cipher suites
// currently returned by defaultCipherSuites.

eccCipherSuites := []uint16{
uint16(TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256),
uint16(TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA),
uint16(TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384),
}
hasECC := false
checkECCLoop:
for _, cipherSuite := range cipherSuites {
for _, eccCipherSuite := range eccCipherSuites {
if cipherSuite == eccCipherSuite {
hasECC = true
break checkECCLoop
}
}
}
if !hasECC {
eccCipherSuite := eccCipherSuites[PRNG.Intn(len(eccCipherSuites))]
cipherSuites = append(cipherSuites, eccCipherSuite)
PRNG.Shuffle(len(cipherSuites), func(i, j int) {
cipherSuites[i], cipherSuites[j] = cipherSuites[j], cipherSuites[i]
})
}

for _, ext := range extensions {
switch e := ext.(type) {
case *extension.SupportedSignatureAlgorithms:
Expand Down
27 changes: 27 additions & 0 deletions vendor/github.com/pion/dtls/v2/flight1handler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eabb3d0

Please sign in to comment.