Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion v3_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (w *streamWrapper) Read(p []byte) (n int, err error) {
w.readHMAC = hmac.New(sha1.New, []byte(w.password))
w.readHMAC.Write(w.serverRandom)
w.readHMACKey = kdf(w.password, w.serverRandom)
w.isTLS13 = isServerHelloSupportTLS13(buffer[5:])
w.isTLS13 = isServerHelloSupportTLS13(buffer)
if !w.isTLS13 {
w.authorized = true
}
Expand Down
6 changes: 5 additions & 1 deletion v3_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ func isServerHelloSupportTLS13(frame []byte) bool {
if err != nil {
return false
}
for i := uint16(0); i < extensionListLength; i++ {
// extensionListLength is the total byte length of all extensions,
// NOT the number of extensions. Iterate by bytes consumed.
extensionsRead := uint16(0)
for extensionsRead < extensionListLength {
var extensionType uint16
err = binary.Read(reader, binary.BigEndian, &extensionType)
if err != nil {
Expand All @@ -121,6 +124,7 @@ func isServerHelloSupportTLS13(frame []byte) bool {
if err != nil {
return false
}
extensionsRead += 4 + extensionLength
if extensionType != 43 {
_, err = io.CopyN(io.Discard, reader, int64(extensionLength))
if err != nil {
Expand Down