Use ID instead of Id in Go.

A linter was complaining about some instance, so just fix the lot of it.

Change-Id: I7e23cbada6e42da887d740b84a05de9f104a86ab
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45284
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
grpc-202302
David Benjamin 4 years ago committed by CQ bot account: commit-bot@chromium.org
parent 4a196ccf9a
commit ae2bb64173
  1. 18
      ssl/test/runner/common.go
  2. 48
      ssl/test/runner/handshake_client.go
  3. 38
      ssl/test/runner/handshake_messages.go
  4. 32
      ssl/test/runner/handshake_server.go
  5. 46
      ssl/test/runner/runner.go

@ -284,7 +284,7 @@ const (
// ClientSessionState contains the state needed by clients to resume TLS // ClientSessionState contains the state needed by clients to resume TLS
// sessions. // sessions.
type ClientSessionState struct { type ClientSessionState struct {
sessionId []uint8 // Session ID supplied by the server. nil if the session has a ticket. sessionID []uint8 // Session ID supplied by the server. nil if the session has a ticket.
sessionTicket []uint8 // Encrypted ticket used for session resumption with server sessionTicket []uint8 // Encrypted ticket used for session resumption with server
vers uint16 // SSL/TLS version negotiated for the session vers uint16 // SSL/TLS version negotiated for the session
wireVersion uint16 // Wire SSL/TLS version negotiated for the session wireVersion uint16 // Wire SSL/TLS version negotiated for the session
@ -325,10 +325,10 @@ type ClientSessionCache interface {
type ServerSessionCache interface { type ServerSessionCache interface {
// Get searches for a sessionState associated with the given session // Get searches for a sessionState associated with the given session
// ID. On return, ok is true if one was found. // ID. On return, ok is true if one was found.
Get(sessionId string) (session *sessionState, ok bool) Get(sessionID string) (session *sessionState, ok bool)
// Put adds the sessionState to the cache with the given session ID. // Put adds the sessionState to the cache with the given session ID.
Put(sessionId string, session *sessionState) Put(sessionID string, session *sessionState)
} }
// CertCompressionAlg is a certificate compression algorithm, specified as a // CertCompressionAlg is a certificate compression algorithm, specified as a
@ -1726,9 +1726,9 @@ type ProtocolBugs struct {
// used on this connection, or zero if there are no special requirements. // used on this connection, or zero if there are no special requirements.
ExpectedCompressedCert uint16 ExpectedCompressedCert uint16
// SendCertCompressionAlgId, if not zero, sets the algorithm ID that will be // SendCertCompressionAlgID, if not zero, sets the algorithm ID that will be
// sent in the compressed certificate message. // sent in the compressed certificate message.
SendCertCompressionAlgId uint16 SendCertCompressionAlgID uint16
// SendCertUncompressedLength, if not zero, sets the uncompressed length that // SendCertUncompressedLength, if not zero, sets the uncompressed length that
// will be sent in the compressed certificate message. // will be sent in the compressed certificate message.
@ -2099,12 +2099,12 @@ type lruServerSessionCache struct {
lruSessionCache lruSessionCache
} }
func (c *lruServerSessionCache) Put(sessionId string, session *sessionState) { func (c *lruServerSessionCache) Put(sessionID string, session *sessionState) {
c.lruSessionCache.Put(sessionId, session) c.lruSessionCache.Put(sessionID, session)
} }
func (c *lruServerSessionCache) Get(sessionId string) (*sessionState, bool) { func (c *lruServerSessionCache) Get(sessionID string) (*sessionState, bool) {
cs, ok := c.lruSessionCache.Get(sessionId) cs, ok := c.lruSessionCache.Get(sessionID)
if !ok { if !ok {
return nil, false return nil, false
} }

@ -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).
sessionIdLen := 16 sessionIDLen := 16
if c.config.Bugs.TicketSessionIDLength != 0 { if c.config.Bugs.TicketSessionIDLength != 0 {
sessionIdLen = c.config.Bugs.TicketSessionIDLength sessionIDLen = c.config.Bugs.TicketSessionIDLength
} }
if c.config.Bugs.EmptyTicketSessionID { if c.config.Bugs.EmptyTicketSessionID {
sessionIdLen = 0 sessionIDLen = 0
} }
hello.sessionId = make([]byte, sessionIdLen) hello.sessionID = make([]byte, sessionIDLen)
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

@ -296,7 +296,7 @@ type clientHelloMsg struct {
isDTLS bool isDTLS bool
vers uint16 vers uint16
random []byte random []byte
sessionId []byte sessionID []byte
cookie []byte cookie []byte
cipherSuites []uint16 cipherSuites []uint16
compressionMethods []uint8 compressionMethods []uint8
@ -366,8 +366,8 @@ func (m *clientHelloMsg) marshal() []byte {
hello := handshakeMsg.addU24LengthPrefixed() hello := handshakeMsg.addU24LengthPrefixed()
hello.addU16(m.vers) hello.addU16(m.vers)
hello.addBytes(m.random) hello.addBytes(m.random)
sessionId := hello.addU8LengthPrefixed() sessionID := hello.addU8LengthPrefixed()
sessionId.addBytes(m.sessionId) sessionID.addBytes(m.sessionID)
if m.isDTLS { if m.isDTLS {
cookie := hello.addU8LengthPrefixed() cookie := hello.addU8LengthPrefixed()
cookie.addBytes(m.cookie) cookie.addBytes(m.cookie)
@ -770,8 +770,8 @@ func (m *clientHelloMsg) unmarshal(data []byte) bool {
reader := byteReader(data[4:]) reader := byteReader(data[4:])
if !reader.readU16(&m.vers) || if !reader.readU16(&m.vers) ||
!reader.readBytes(&m.random, 32) || !reader.readBytes(&m.random, 32) ||
!reader.readU8LengthPrefixedBytes(&m.sessionId) || !reader.readU8LengthPrefixedBytes(&m.sessionID) ||
len(m.sessionId) > 32 { len(m.sessionID) > 32 {
return false return false
} }
if m.isDTLS { if m.isDTLS {
@ -1094,7 +1094,7 @@ type serverHelloMsg struct {
supportedVersOverride uint16 supportedVersOverride uint16
omitSupportedVers bool omitSupportedVers bool
random []byte random []byte
sessionId []byte sessionID []byte
cipherSuite uint16 cipherSuite uint16
hasKeyShare bool hasKeyShare bool
keyShare keyShareEntry keyShare keyShareEntry
@ -1133,8 +1133,8 @@ func (m *serverHelloMsg) marshal() []byte {
} }
hello.addBytes(m.random) hello.addBytes(m.random)
sessionId := hello.addU8LengthPrefixed() sessionID := hello.addU8LengthPrefixed()
sessionId.addBytes(m.sessionId) sessionID.addBytes(m.sessionID)
hello.addU16(m.cipherSuite) hello.addU16(m.cipherSuite)
hello.addU8(m.compressionMethod) hello.addU8(m.compressionMethod)
@ -1206,7 +1206,7 @@ func (m *serverHelloMsg) unmarshal(data []byte) bool {
if !ok { if !ok {
return false return false
} }
if !reader.readU8LengthPrefixedBytes(&m.sessionId) || if !reader.readU8LengthPrefixedBytes(&m.sessionID) ||
!reader.readU16(&m.cipherSuite) || !reader.readU16(&m.cipherSuite) ||
!reader.readU8(&m.compressionMethod) { !reader.readU8(&m.compressionMethod) {
return false return false
@ -1714,7 +1714,7 @@ type helloRetryRequestMsg struct {
raw []byte raw []byte
vers uint16 vers uint16
isServerHello bool isServerHello bool
sessionId []byte sessionID []byte
cipherSuite uint16 cipherSuite uint16
compressionMethod uint8 compressionMethod uint8
hasSelectedGroup bool hasSelectedGroup bool
@ -1734,8 +1734,8 @@ func (m *helloRetryRequestMsg) marshal() []byte {
retryRequest := retryRequestMsg.addU24LengthPrefixed() retryRequest := retryRequestMsg.addU24LengthPrefixed()
retryRequest.addU16(VersionTLS12) retryRequest.addU16(VersionTLS12)
retryRequest.addBytes(tls13HelloRetryRequest) retryRequest.addBytes(tls13HelloRetryRequest)
sessionId := retryRequest.addU8LengthPrefixed() sessionID := retryRequest.addU8LengthPrefixed()
sessionId.addBytes(m.sessionId) sessionID.addBytes(m.sessionID)
retryRequest.addU16(m.cipherSuite) retryRequest.addU16(m.cipherSuite)
retryRequest.addU8(m.compressionMethod) retryRequest.addU8(m.compressionMethod)
@ -1781,7 +1781,7 @@ func (m *helloRetryRequestMsg) unmarshal(data []byte) bool {
var random []byte var random []byte
var compressionMethod byte var compressionMethod byte
if !reader.readBytes(&random, 32) || if !reader.readBytes(&random, 32) ||
!reader.readU8LengthPrefixedBytes(&m.sessionId) || !reader.readU8LengthPrefixedBytes(&m.sessionID) ||
!reader.readU16(&m.cipherSuite) || !reader.readU16(&m.cipherSuite) ||
!reader.readU8(&compressionMethod) || !reader.readU8(&compressionMethod) ||
compressionMethod != 0 { compressionMethod != 0 {
@ -2583,7 +2583,7 @@ type v2ClientHelloMsg struct {
raw []byte raw []byte
vers uint16 vers uint16
cipherSuites []uint16 cipherSuites []uint16
sessionId []byte sessionID []byte
challenge []byte challenge []byte
} }
@ -2592,7 +2592,7 @@ func (m *v2ClientHelloMsg) marshal() []byte {
return m.raw return m.raw
} }
length := 1 + 2 + 2 + 2 + 2 + len(m.cipherSuites)*3 + len(m.sessionId) + len(m.challenge) length := 1 + 2 + 2 + 2 + 2 + len(m.cipherSuites)*3 + len(m.sessionID) + len(m.challenge)
x := make([]byte, length) x := make([]byte, length)
x[0] = 1 x[0] = 1
@ -2600,8 +2600,8 @@ func (m *v2ClientHelloMsg) marshal() []byte {
x[2] = uint8(m.vers) x[2] = uint8(m.vers)
x[3] = uint8((len(m.cipherSuites) * 3) >> 8) x[3] = uint8((len(m.cipherSuites) * 3) >> 8)
x[4] = uint8(len(m.cipherSuites) * 3) x[4] = uint8(len(m.cipherSuites) * 3)
x[5] = uint8(len(m.sessionId) >> 8) x[5] = uint8(len(m.sessionID) >> 8)
x[6] = uint8(len(m.sessionId)) x[6] = uint8(len(m.sessionID))
x[7] = uint8(len(m.challenge) >> 8) x[7] = uint8(len(m.challenge) >> 8)
x[8] = uint8(len(m.challenge)) x[8] = uint8(len(m.challenge))
y := x[9:] y := x[9:]
@ -2611,8 +2611,8 @@ func (m *v2ClientHelloMsg) marshal() []byte {
y[i*3+2] = uint8(spec) y[i*3+2] = uint8(spec)
} }
y = y[len(m.cipherSuites)*3:] y = y[len(m.cipherSuites)*3:]
copy(y, m.sessionId) copy(y, m.sessionID)
y = y[len(m.sessionId):] y = y[len(m.sessionID):]
copy(y, m.challenge) copy(y, m.challenge)
m.raw = x m.raw = x

@ -289,11 +289,11 @@ func (hs *serverHandshakeState) readClientHello() error {
} }
} }
if config.Bugs.MockQUICTransport != nil && len(hs.clientHello.sessionId) > 0 { if config.Bugs.MockQUICTransport != nil && len(hs.clientHello.sessionID) > 0 {
return fmt.Errorf("tls: QUIC client did not disable compatibility mode") return fmt.Errorf("tls: QUIC client did not disable compatibility mode")
} }
if config.Bugs.ExpectNoTLS12Session { if config.Bugs.ExpectNoTLS12Session {
if len(hs.clientHello.sessionId) > 0 && c.vers >= VersionTLS13 { if len(hs.clientHello.sessionID) > 0 && c.vers >= VersionTLS13 {
return fmt.Errorf("tls: client offered an unexpected session ID") return fmt.Errorf("tls: client offered an unexpected session ID")
} }
if len(hs.clientHello.sessionTicket) > 0 { if len(hs.clientHello.sessionTicket) > 0 {
@ -376,7 +376,7 @@ func (hs *serverHandshakeState) doTLS13Handshake() error {
hs.hello = &serverHelloMsg{ hs.hello = &serverHelloMsg{
isDTLS: c.isDTLS, isDTLS: c.isDTLS,
vers: c.wireVersion, vers: c.wireVersion,
sessionId: hs.clientHello.sessionId, sessionID: hs.clientHello.sessionID,
compressionMethod: config.Bugs.SendCompressionMethod, compressionMethod: config.Bugs.SendCompressionMethod,
versOverride: config.Bugs.SendServerHelloVersion, versOverride: config.Bugs.SendServerHelloVersion,
supportedVersOverride: config.Bugs.SendServerSupportedVersionExtension, supportedVersOverride: config.Bugs.SendServerSupportedVersionExtension,
@ -553,7 +553,7 @@ ResendHelloRetryRequest:
} }
helloRetryRequest := &helloRetryRequestMsg{ helloRetryRequest := &helloRetryRequestMsg{
vers: c.wireVersion, vers: c.wireVersion,
sessionId: hs.clientHello.sessionId, sessionID: hs.clientHello.sessionID,
cipherSuite: cipherSuite, cipherSuite: cipherSuite,
compressionMethod: config.Bugs.SendCompressionMethod, compressionMethod: config.Bugs.SendCompressionMethod,
duplicateExtensions: config.Bugs.DuplicateHelloRetryRequestExtensions, duplicateExtensions: config.Bugs.DuplicateHelloRetryRequestExtensions,
@ -932,7 +932,7 @@ ResendHelloRetryRequest:
return fmt.Errorf("expected to send compressed cert with alg %d, but picked %d", expected, id) return fmt.Errorf("expected to send compressed cert with alg %d, but picked %d", expected, id)
} }
if override := config.Bugs.SendCertCompressionAlgId; override != 0 { if override := config.Bugs.SendCertCompressionAlgID; override != 0 {
id = override id = override
} }
@ -1250,7 +1250,7 @@ func (hs *serverHandshakeState) processClientHello() (isResume bool, err error)
copy(hs.hello.random[len(hs.hello.random)-8:], downgradeJDK11) copy(hs.hello.random[len(hs.hello.random)-8:], downgradeJDK11)
} }
if len(hs.clientHello.sessionId) == 0 && c.config.Bugs.ExpectClientHelloSessionID { if len(hs.clientHello.sessionID) == 0 && c.config.Bugs.ExpectClientHelloSessionID {
return false, errors.New("tls: expected non-empty session ID from client") return false, errors.New("tls: expected non-empty session ID from client")
} }
@ -1305,11 +1305,11 @@ Curves:
// For test purposes, check that the peer never offers a session when // For test purposes, check that the peer never offers a session when
// renegotiating. // renegotiating.
if c.cipherSuite != nil && len(hs.clientHello.sessionId) > 0 && c.config.Bugs.FailIfResumeOnRenego { if c.cipherSuite != nil && len(hs.clientHello.sessionID) > 0 && c.config.Bugs.FailIfResumeOnRenego {
return false, errors.New("tls: offered resumption on renegotiation") return false, errors.New("tls: offered resumption on renegotiation")
} }
if c.config.Bugs.FailIfSessionOffered && (len(hs.clientHello.sessionTicket) > 0 || len(hs.clientHello.sessionId) > 0) { if c.config.Bugs.FailIfSessionOffered && (len(hs.clientHello.sessionTicket) > 0 || len(hs.clientHello.sessionID) > 0) {
return false, errors.New("tls: client offered a session ticket or ID") return false, errors.New("tls: client offered a session ticket or ID")
} }
@ -1556,8 +1556,8 @@ func (hs *serverHandshakeState) checkForResumption() bool {
} }
var ok bool var ok bool
sessionId := string(hs.clientHello.sessionId) sessionID := string(hs.clientHello.sessionID)
if hs.sessionState, ok = c.config.ServerSessionCache.Get(sessionId); !ok { if hs.sessionState, ok = c.config.ServerSessionCache.Get(sessionID); !ok {
return false return false
} }
} }
@ -1613,7 +1613,7 @@ func (hs *serverHandshakeState) doResumeHandshake() error {
} }
// We echo the client's session ID in the ServerHello to let it know // We echo the client's session ID in the ServerHello to let it know
// that we're doing a resumption. // that we're doing a resumption.
hs.hello.sessionId = hs.clientHello.sessionId hs.hello.sessionID = hs.clientHello.sessionID
hs.hello.extensions.ticketSupported = c.config.Bugs.RenewTicketOnResume hs.hello.extensions.ticketSupported = c.config.Bugs.RenewTicketOnResume
if c.config.Bugs.SendSCTListOnResume != nil { if c.config.Bugs.SendSCTListOnResume != nil {
@ -1671,14 +1671,14 @@ func (hs *serverHandshakeState) doFullHandshake() error {
// Generate a session ID if we're to save the session. // Generate a session ID if we're to save the session.
if !hs.hello.extensions.ticketSupported && config.ServerSessionCache != nil { if !hs.hello.extensions.ticketSupported && config.ServerSessionCache != nil {
hs.hello.sessionId = make([]byte, 32) hs.hello.sessionID = make([]byte, 32)
if _, err := io.ReadFull(config.rand(), hs.hello.sessionId); err != nil { if _, err := io.ReadFull(config.rand(), hs.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 config.Bugs.EchoSessionIDInFullHandshake { if config.Bugs.EchoSessionIDInFullHandshake {
hs.hello.sessionId = hs.clientHello.sessionId hs.hello.sessionID = hs.clientHello.sessionID
} }
hs.finishedHash = newFinishedHash(c.wireVersion, c.isDTLS, hs.suite) hs.finishedHash = newFinishedHash(c.wireVersion, c.isDTLS, hs.suite)
@ -2013,8 +2013,8 @@ func (hs *serverHandshakeState) sendSessionTicket() error {
} }
if !hs.hello.extensions.ticketSupported || hs.c.config.Bugs.SkipNewSessionTicket { if !hs.hello.extensions.ticketSupported || hs.c.config.Bugs.SkipNewSessionTicket {
if c.config.ServerSessionCache != nil && len(hs.hello.sessionId) != 0 { if c.config.ServerSessionCache != nil && len(hs.hello.sessionID) != 0 {
c.config.ServerSessionCache.Put(string(hs.hello.sessionId), &state) c.config.ServerSessionCache.Put(string(hs.hello.sessionID), &state)
} }
return nil return nil
} }

@ -15940,8 +15940,8 @@ func addCertCompressionTests() {
} }
const ( const (
shrinkingAlgId = 0xff01 shrinkingAlgID = 0xff01
expandingAlgId = 0xff02 expandingAlgID = 0xff02
) )
for _, ver := range tlsVersions { for _, ver := range tlsVersions {
@ -15990,7 +15990,7 @@ func addCertCompressionTests() {
config: Config{ config: Config{
MinVersion: ver.version, MinVersion: ver.version,
MaxVersion: ver.version, MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{expandingAlgId: expanding}, CertCompressionAlgs: map[uint16]CertCompressionAlg{expandingAlgID: expanding},
}, },
}) })
@ -16004,9 +16004,9 @@ func addCertCompressionTests() {
config: Config{ config: Config{
MinVersion: ver.version, MinVersion: ver.version,
MaxVersion: ver.version, MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{expandingAlgId: expanding}, CertCompressionAlgs: map[uint16]CertCompressionAlg{expandingAlgID: expanding},
Bugs: ProtocolBugs{ Bugs: ProtocolBugs{
ExpectedCompressedCert: expandingAlgId, ExpectedCompressedCert: expandingAlgID,
}, },
}, },
}) })
@ -16018,15 +16018,15 @@ func addCertCompressionTests() {
config: Config{ config: Config{
MinVersion: ver.version, MinVersion: ver.version,
MaxVersion: ver.version, MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{shrinkingAlgId: shrinking}, CertCompressionAlgs: map[uint16]CertCompressionAlg{shrinkingAlgID: shrinking},
Bugs: ProtocolBugs{ Bugs: ProtocolBugs{
ExpectedCompressedCert: shrinkingAlgId, ExpectedCompressedCert: shrinkingAlgID,
}, },
}, },
}) })
// With both algorithms configured, the server should pick its most // With both algorithms configured, the server should pick its most
// preferable. (Which is expandingAlgId.) // preferable. (Which is expandingAlgID.)
testCases = append(testCases, testCase{ testCases = append(testCases, testCase{
testType: serverTest, testType: serverTest,
name: "CertCompressionPriority-" + ver.name, name: "CertCompressionPriority-" + ver.name,
@ -16035,11 +16035,11 @@ func addCertCompressionTests() {
MinVersion: ver.version, MinVersion: ver.version,
MaxVersion: ver.version, MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{ CertCompressionAlgs: map[uint16]CertCompressionAlg{
shrinkingAlgId: shrinking, shrinkingAlgID: shrinking,
expandingAlgId: expanding, expandingAlgID: expanding,
}, },
Bugs: ProtocolBugs{ Bugs: ProtocolBugs{
ExpectedCompressedCert: expandingAlgId, ExpectedCompressedCert: expandingAlgID,
}, },
}, },
}) })
@ -16052,10 +16052,10 @@ func addCertCompressionTests() {
MinVersion: ver.version, MinVersion: ver.version,
MaxVersion: ver.version, MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{ CertCompressionAlgs: map[uint16]CertCompressionAlg{
expandingAlgId: expanding, expandingAlgID: expanding,
}, },
Bugs: ProtocolBugs{ Bugs: ProtocolBugs{
ExpectedCompressedCert: expandingAlgId, ExpectedCompressedCert: expandingAlgID,
}, },
}, },
}) })
@ -16068,27 +16068,27 @@ func addCertCompressionTests() {
MinVersion: ver.version, MinVersion: ver.version,
MaxVersion: ver.version, MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{ CertCompressionAlgs: map[uint16]CertCompressionAlg{
shrinkingAlgId: shrinking, shrinkingAlgID: shrinking,
}, },
Bugs: ProtocolBugs{ Bugs: ProtocolBugs{
ExpectedCompressedCert: shrinkingAlgId, ExpectedCompressedCert: shrinkingAlgID,
}, },
}, },
}) })
testCases = append(testCases, testCase{ testCases = append(testCases, testCase{
testType: clientTest, testType: clientTest,
name: "CertCompressionBadAlgIdClient-" + ver.name, name: "CertCompressionBadAlgIDClient-" + ver.name,
flags: []string{"-install-cert-compression-algs"}, flags: []string{"-install-cert-compression-algs"},
config: Config{ config: Config{
MinVersion: ver.version, MinVersion: ver.version,
MaxVersion: ver.version, MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{ CertCompressionAlgs: map[uint16]CertCompressionAlg{
shrinkingAlgId: shrinking, shrinkingAlgID: shrinking,
}, },
Bugs: ProtocolBugs{ Bugs: ProtocolBugs{
ExpectedCompressedCert: shrinkingAlgId, ExpectedCompressedCert: shrinkingAlgID,
SendCertCompressionAlgId: 1234, SendCertCompressionAlgID: 1234,
}, },
}, },
shouldFail: true, shouldFail: true,
@ -16103,10 +16103,10 @@ func addCertCompressionTests() {
MinVersion: ver.version, MinVersion: ver.version,
MaxVersion: ver.version, MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{ CertCompressionAlgs: map[uint16]CertCompressionAlg{
shrinkingAlgId: shrinking, shrinkingAlgID: shrinking,
}, },
Bugs: ProtocolBugs{ Bugs: ProtocolBugs{
ExpectedCompressedCert: shrinkingAlgId, ExpectedCompressedCert: shrinkingAlgID,
SendCertUncompressedLength: 12, SendCertUncompressedLength: 12,
}, },
}, },
@ -16122,10 +16122,10 @@ func addCertCompressionTests() {
MinVersion: ver.version, MinVersion: ver.version,
MaxVersion: ver.version, MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{ CertCompressionAlgs: map[uint16]CertCompressionAlg{
shrinkingAlgId: shrinking, shrinkingAlgID: shrinking,
}, },
Bugs: ProtocolBugs{ Bugs: ProtocolBugs{
ExpectedCompressedCert: shrinkingAlgId, ExpectedCompressedCert: shrinkingAlgID,
SendCertUncompressedLength: 1 << 20, SendCertUncompressedLength: 1 << 20,
}, },
}, },

Loading…
Cancel
Save