@ -20,6 +20,7 @@ import (
"time"
"time"
"boringssl.googlesource.com/boringssl/ssl/test/runner/hpke"
"boringssl.googlesource.com/boringssl/ssl/test/runner/hpke"
"golang.org/x/crypto/cryptobyte"
)
)
// serverHandshakeState contains details of a server handshake in progress.
// serverHandshakeState contains details of a server handshake in progress.
@ -2443,18 +2444,18 @@ func checkClientHellosEqual(a, b []byte, isDTLS bool, ignoreExtensions []uint16)
}
}
// Skip the handshake message header.
// Skip the handshake message header.
aReader := byteReader ( a [ 4 : ] )
aReader := cryptobyte . String ( a [ 4 : ] )
bReader := byteReader ( b [ 4 : ] )
bReader := cryptobyte . String ( b [ 4 : ] )
var aVers , bVers uint16
var aVers , bVers uint16
var aRandom , bRandom [ ] byte
var aRandom , bRandom [ ] byte
var aSessionID , bSessionID [ ] byte
var aSessionID , bSessionID [ ] byte
if ! aReader . readU 16( & aVers ) ||
if ! aReader . ReadUint 16( & aVers ) ||
! bReader . readU 16( & bVers ) ||
! bReader . ReadUint 16( & bVers ) ||
! aReader . r eadBytes( & aRandom , 32 ) ||
! aReader . R eadBytes( & aRandom , 32 ) ||
! bReader . r eadBytes( & bRandom , 32 ) ||
! bReader . R eadBytes( & bRandom , 32 ) ||
! aReader . readU8LengthPrefixedBytes ( & aSessionID ) ||
! readUint8LengthPrefixedBytes ( & aReader , & aSessionID ) ||
! bReader . readU8LengthPrefixedBytes ( & bSessionID ) {
! readUint8LengthPrefixedBytes ( & bReader , & bSessionID ) {
return errors . New ( "tls: could not parse ClientHello" )
return errors . New ( "tls: could not parse ClientHello" )
}
}
@ -2474,17 +2475,17 @@ func checkClientHellosEqual(a, b []byte, isDTLS bool, ignoreExtensions []uint16)
// cookie altogether. If we implement DTLS 1.3, we'll need to ensure
// cookie altogether. If we implement DTLS 1.3, we'll need to ensure
// that parsing logic above this function rejects this cookie.
// that parsing logic above this function rejects this cookie.
var aCookie , bCookie [ ] byte
var aCookie , bCookie [ ] byte
if ! aReader . readU8LengthPrefixedBytes ( & aCookie ) ||
if ! readUint8LengthPrefixedBytes ( & aReader , & aCookie ) ||
! bReader . readU8LengthPrefixedBytes ( & bCookie ) {
! readUint8LengthPrefixedBytes ( & bReader , & bCookie ) {
return errors . New ( "tls: could not parse ClientHello" )
return errors . New ( "tls: could not parse ClientHello" )
}
}
}
}
var aCipherSuites , bCipherSuites , aCompressionMethods , bCompressionMethods [ ] byte
var aCipherSuites , bCipherSuites , aCompressionMethods , bCompressionMethods [ ] byte
if ! aReader . readU16LengthPrefixedBytes ( & aCipherSuites ) ||
if ! readUint16LengthPrefixedBytes ( & aReader , & aCipherSuites ) ||
! bReader . readU16LengthPrefixedBytes ( & bCipherSuites ) ||
! readUint16LengthPrefixedBytes ( & bReader , & bCipherSuites ) ||
! aReader . readU8LengthPrefixedBytes ( & aCompressionMethods ) ||
! readUint8LengthPrefixedBytes ( & aReader , & aCompressionMethods ) ||
! bReader . readU8LengthPrefixedBytes ( & bCompressionMethods ) {
! readUint8LengthPrefixedBytes ( & bReader , & bCompressionMethods ) {
return errors . New ( "tls: could not parse ClientHello" )
return errors . New ( "tls: could not parse ClientHello" )
}
}
if ! bytes . Equal ( aCipherSuites , bCipherSuites ) {
if ! bytes . Equal ( aCipherSuites , bCipherSuites ) {
@ -2499,9 +2500,9 @@ func checkClientHellosEqual(a, b []byte, isDTLS bool, ignoreExtensions []uint16)
return nil
return nil
}
}
var aExtensions , bExtensions byteReader
var aExtensions , bExtensions cryptobyte . String
if ! aReader . readU 16LengthPrefixed( & aExtensions ) ||
if ! aReader . ReadUint 16LengthPrefixed( & aExtensions ) ||
! bReader . readU 16LengthPrefixed( & bExtensions ) ||
! bReader . ReadUint 16LengthPrefixed( & bExtensions ) ||
len ( aReader ) != 0 ||
len ( aReader ) != 0 ||
len ( bReader ) != 0 {
len ( bReader ) != 0 {
return errors . New ( "tls: could not parse ClientHello" )
return errors . New ( "tls: could not parse ClientHello" )
@ -2510,8 +2511,8 @@ func checkClientHellosEqual(a, b []byte, isDTLS bool, ignoreExtensions []uint16)
for len ( aExtensions ) != 0 {
for len ( aExtensions ) != 0 {
var aID uint16
var aID uint16
var aBody [ ] byte
var aBody [ ] byte
if ! aExtensions . readU 16( & aID ) ||
if ! aExtensions . ReadUint 16( & aID ) ||
! aExtensions . readU16LengthPrefixedBytes ( & aBody ) {
! readUint16LengthPrefixedBytes ( & aExtensions , & aBody ) {
return errors . New ( "tls: could not parse ClientHello" )
return errors . New ( "tls: could not parse ClientHello" )
}
}
if _ , ok := ignoreExtensionsSet [ aID ] ; ok {
if _ , ok := ignoreExtensionsSet [ aID ] ; ok {
@ -2524,8 +2525,8 @@ func checkClientHellosEqual(a, b []byte, isDTLS bool, ignoreExtensions []uint16)
}
}
var bID uint16
var bID uint16
var bBody [ ] byte
var bBody [ ] byte
if ! bExtensions . readU 16( & bID ) ||
if ! bExtensions . ReadUint 16( & bID ) ||
! bExtensions . readU16LengthPrefixedBytes ( & bBody ) {
! readUint16LengthPrefixedBytes ( & bExtensions , & bBody ) {
return errors . New ( "tls: could not parse ClientHello" )
return errors . New ( "tls: could not parse ClientHello" )
}
}
if _ , ok := ignoreExtensionsSet [ bID ] ; ok {
if _ , ok := ignoreExtensionsSet [ bID ] ; ok {
@ -2546,8 +2547,8 @@ func checkClientHellosEqual(a, b []byte, isDTLS bool, ignoreExtensions []uint16)
for len ( bExtensions ) != 0 {
for len ( bExtensions ) != 0 {
var id uint16
var id uint16
var body [ ] byte
var body [ ] byte
if ! bExtensions . readU 16( & id ) ||
if ! bExtensions . ReadUint 16( & id ) ||
! bExtensions . readU16LengthPrefixedBytes ( & body ) {
! readUint16LengthPrefixedBytes ( & bExtensions , & body ) {
return errors . New ( "tls: could not parse ClientHello" )
return errors . New ( "tls: could not parse ClientHello" )
}
}
if _ , ok := ignoreExtensionsSet [ id ] ; ! ok {
if _ , ok := ignoreExtensionsSet [ id ] ; ! ok {