@ -60,7 +60,7 @@ func fixClientHellos(hello *clientHelloMsg, in []byte) ([]byte, error) {
}
}
hello . random = newHello . random
hello . random = newHello . random
hello . sessionId = newHello . sessionId
hello . sessionID = newHello . sessionID
// Replace |ret|'s key shares with those of |hello|. For simplicity, we
// Replace |ret|'s key shares with those of |hello|. For simplicity, we
// require their lengths match, which is satisfied by matching the
// require their lengths match, which is satisfied by matching the
@ -280,9 +280,9 @@ func (c *Conn) clientHandshake() error {
hello . cipherSuites = make ( [ ] uint16 , 0 , len ( possibleCipherSuites ) )
hello . cipherSuites = make ( [ ] uint16 , 0 , len ( possibleCipherSuites ) )
NextCipherSuite :
NextCipherSuite :
for _ , suiteId := range possibleCipherSuites {
for _ , suiteID := range possibleCipherSuites {
for _ , suite := range cipherSuites {
for _ , suite := range cipherSuites {
if suite . id != suiteId {
if suite . id != suiteID {
continue
continue
}
}
// Don't advertise TLS 1.2-only cipher suites unless
// Don't advertise TLS 1.2-only cipher suites unless
@ -290,7 +290,7 @@ NextCipherSuite:
if maxVersion < VersionTLS12 && suite . flags & suiteTLS12 != 0 {
if maxVersion < VersionTLS12 && suite . flags & suiteTLS12 != 0 {
continue
continue
}
}
hello . cipherSuites = append ( hello . cipherSuites , suiteId )
hello . cipherSuites = append ( hello . cipherSuites , suiteID )
continue NextCipherSuite
continue NextCipherSuite
}
}
}
}
@ -399,20 +399,20 @@ NextCipherSuite:
// A random session ID is used to detect when the
// A random session ID is used to detect when the
// server accepted the ticket and is resuming a session
// server accepted the ticket and is resuming a session
// (see RFC 5077).
// (see RFC 5077).
sessionId Len := 16
sessionID Len := 16
if c . config . Bugs . TicketSessionIDLength != 0 {
if c . config . Bugs . TicketSessionIDLength != 0 {
sessionId Len = c . config . Bugs . TicketSessionIDLength
sessionID Len = c . config . Bugs . TicketSessionIDLength
}
}
if c . config . Bugs . EmptyTicketSessionID {
if c . config . Bugs . EmptyTicketSessionID {
sessionId Len = 0
sessionID Len = 0
}
}
hello . sessionId = make ( [ ] byte , sessionId Len )
hello . sessionID = make ( [ ] byte , sessionID Len )
if _ , err := io . ReadFull ( c . config . rand ( ) , hello . sessionId ) ; err != nil {
if _ , err := io . ReadFull ( c . config . rand ( ) , hello . sessionID ) ; err != nil {
c . sendAlert ( alertInternalError )
c . sendAlert ( alertInternalError )
return errors . New ( "tls: short read from Rand: " + err . Error ( ) )
return errors . New ( "tls: short read from Rand: " + err . Error ( ) )
}
}
} else {
} else {
hello . sessionId = session . sessionId
hello . sessionID = session . sessionID
}
}
}
}
}
}
@ -421,15 +421,15 @@ NextCipherSuite:
// ID. Although BoringSSL always enables compatibility mode, other
// ID. Although BoringSSL always enables compatibility mode, other
// implementations make it conditional on the ClientHello. We test
// implementations make it conditional on the ClientHello. We test
// BoringSSL's expected behavior with SendClientHelloSessionID.
// BoringSSL's expected behavior with SendClientHelloSessionID.
if len ( hello . sessionId ) == 0 && maxVersion >= VersionTLS13 {
if len ( hello . sessionID ) == 0 && maxVersion >= VersionTLS13 {
hello . sessionId = make ( [ ] byte , 32 )
hello . sessionID = make ( [ ] byte , 32 )
if _ , err := io . ReadFull ( c . config . rand ( ) , hello . sessionId ) ; err != nil {
if _ , err := io . ReadFull ( c . config . rand ( ) , hello . sessionID ) ; err != nil {
c . sendAlert ( alertInternalError )
c . sendAlert ( alertInternalError )
return errors . New ( "tls: short read from Rand: " + err . Error ( ) )
return errors . New ( "tls: short read from Rand: " + err . Error ( ) )
}
}
}
}
if c . config . Bugs . MockQUICTransport != nil && ! c . config . Bugs . CompatModeWithQUIC {
if c . config . Bugs . MockQUICTransport != nil && ! c . config . Bugs . CompatModeWithQUIC {
hello . sessionId = [ ] byte { }
hello . sessionID = [ ] byte { }
}
}
if c . config . Bugs . SendCipherSuites != nil {
if c . config . Bugs . SendCipherSuites != nil {
@ -448,7 +448,7 @@ NextCipherSuite:
hello . hasEarlyData = false
hello . hasEarlyData = false
}
}
if c . config . Bugs . SendClientHelloSessionID != nil {
if c . config . Bugs . SendClientHelloSessionID != nil {
hello . sessionId = c . config . Bugs . SendClientHelloSessionID
hello . sessionID = c . config . Bugs . SendClientHelloSessionID
}
}
var helloBytes [ ] byte
var helloBytes [ ] byte
@ -459,7 +459,7 @@ NextCipherSuite:
vers : hello . vers ,
vers : hello . vers ,
cipherSuites : hello . cipherSuites ,
cipherSuites : hello . cipherSuites ,
// No session resumption for V2ClientHello.
// No session resumption for V2ClientHello.
sessionId : nil ,
sessionID : nil ,
challenge : hello . random [ 1 : ] ,
challenge : hello . random [ 1 : ] ,
}
}
helloBytes = v2Hello . marshal ( )
helloBytes = v2Hello . marshal ( )
@ -837,7 +837,7 @@ NextCipherSuite:
if c . config . Bugs . RequireSessionTickets && len ( hs . session . sessionTicket ) == 0 {
if c . config . Bugs . RequireSessionTickets && len ( hs . session . sessionTicket ) == 0 {
return errors . New ( "tls: new session used session IDs instead of tickets" )
return errors . New ( "tls: new session used session IDs instead of tickets" )
}
}
if c . config . Bugs . RequireSessionIDs && len ( hs . session . sessionId ) == 0 {
if c . config . Bugs . RequireSessionIDs && len ( hs . session . sessionID ) == 0 {
return errors . New ( "tls: new session used session tickets instead of IDs" )
return errors . New ( "tls: new session used session tickets instead of IDs" )
}
}
sessionCache . Put ( cacheKey , hs . session )
sessionCache . Put ( cacheKey , hs . session )
@ -858,7 +858,7 @@ NextCipherSuite:
func ( hs * clientHandshakeState ) doTLS13Handshake ( ) error {
func ( hs * clientHandshakeState ) doTLS13Handshake ( ) error {
c := hs . c
c := hs . c
if ! bytes . Equal ( hs . hello . sessionId , hs . serverHello . sessionId ) {
if ! bytes . Equal ( hs . hello . sessionID , hs . serverHello . sessionID ) {
return errors . New ( "tls: session IDs did not match." )
return errors . New ( "tls: session IDs did not match." )
}
}
@ -1805,14 +1805,14 @@ func (hs *clientHandshakeState) processServerExtensions(serverExtensions *server
}
}
func ( hs * clientHandshakeState ) serverResumedSession ( ) bool {
func ( hs * clientHandshakeState ) serverResumedSession ( ) bool {
// If the server responded with the same sessionId then it means the
// If the server responded with the same sessionID then it means the
// sessionTicket is being used to resume a TLS session.
// sessionTicket is being used to resume a TLS session.
//
//
// Note that, if hs.hello.sessionId is a non-nil empty array, this will
// Note that, if hs.hello.sessionID is a non-nil empty array, this will
// accept an empty session ID from the server as resumption. See
// accept an empty session ID from the server as resumption. See
// EmptyTicketSessionID.
// EmptyTicketSessionID.
return hs . session != nil && hs . hello . sessionId != nil &&
return hs . session != nil && hs . hello . sessionID != nil &&
bytes . Equal ( hs . serverHello . sessionId , hs . hello . sessionId )
bytes . Equal ( hs . serverHello . sessionID , hs . hello . sessionID )
}
}
func ( hs * clientHandshakeState ) processServerHello ( ) ( bool , error ) {
func ( hs * clientHandshakeState ) processServerHello ( ) ( bool , error ) {
@ -1903,8 +1903,8 @@ func (hs *clientHandshakeState) readSessionTicket() error {
if c . config . Bugs . ExpectNewTicket {
if c . config . Bugs . ExpectNewTicket {
return errors . New ( "tls: expected new ticket" )
return errors . New ( "tls: expected new ticket" )
}
}
if hs . session == nil && len ( hs . serverHello . sessionId ) > 0 {
if hs . session == nil && len ( hs . serverHello . sessionID ) > 0 {
session . sessionId = hs . serverHello . sessionId
session . sessionID = hs . serverHello . sessionID
hs . session = session
hs . session = session
}
}
return nil
return nil