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>
diff --git a/ssl/test/runner/common.go b/ssl/test/runner/common.go
index ae974d0..733debd 100644
--- a/ssl/test/runner/common.go
+++ b/ssl/test/runner/common.go
@@ -284,7 +284,7 @@
// ClientSessionState contains the state needed by clients to resume TLS
// sessions.
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
vers uint16 // SSL/TLS version negotiated for the session
wireVersion uint16 // Wire SSL/TLS version negotiated for the session
@@ -325,10 +325,10 @@
type ServerSessionCache interface {
// Get searches for a sessionState associated with the given session
// 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(sessionId string, session *sessionState)
+ Put(sessionID string, session *sessionState)
}
// CertCompressionAlg is a certificate compression algorithm, specified as a
@@ -1726,9 +1726,9 @@
// used on this connection, or zero if there are no special requirements.
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.
- SendCertCompressionAlgId uint16
+ SendCertCompressionAlgID uint16
// SendCertUncompressedLength, if not zero, sets the uncompressed length that
// will be sent in the compressed certificate message.
@@ -2099,12 +2099,12 @@
lruSessionCache
}
-func (c *lruServerSessionCache) Put(sessionId string, session *sessionState) {
- c.lruSessionCache.Put(sessionId, session)
+func (c *lruServerSessionCache) Put(sessionID string, session *sessionState) {
+ c.lruSessionCache.Put(sessionID, session)
}
-func (c *lruServerSessionCache) Get(sessionId string) (*sessionState, bool) {
- cs, ok := c.lruSessionCache.Get(sessionId)
+func (c *lruServerSessionCache) Get(sessionID string) (*sessionState, bool) {
+ cs, ok := c.lruSessionCache.Get(sessionID)
if !ok {
return nil, false
}
diff --git a/ssl/test/runner/handshake_client.go b/ssl/test/runner/handshake_client.go
index 6bbdc61..586cbe5 100644
--- a/ssl/test/runner/handshake_client.go
+++ b/ssl/test/runner/handshake_client.go
@@ -60,7 +60,7 @@
}
hello.random = newHello.random
- hello.sessionId = newHello.sessionId
+ hello.sessionID = newHello.sessionID
// Replace |ret|'s key shares with those of |hello|. For simplicity, we
// require their lengths match, which is satisfied by matching the
@@ -280,9 +280,9 @@
hello.cipherSuites = make([]uint16, 0, len(possibleCipherSuites))
NextCipherSuite:
- for _, suiteId := range possibleCipherSuites {
+ for _, suiteID := range possibleCipherSuites {
for _, suite := range cipherSuites {
- if suite.id != suiteId {
+ if suite.id != suiteID {
continue
}
// Don't advertise TLS 1.2-only cipher suites unless
@@ -290,7 +290,7 @@
if maxVersion < VersionTLS12 && suite.flags&suiteTLS12 != 0 {
continue
}
- hello.cipherSuites = append(hello.cipherSuites, suiteId)
+ hello.cipherSuites = append(hello.cipherSuites, suiteID)
continue NextCipherSuite
}
}
@@ -399,20 +399,20 @@
// A random session ID is used to detect when the
// server accepted the ticket and is resuming a session
// (see RFC 5077).
- sessionIdLen := 16
+ sessionIDLen := 16
if c.config.Bugs.TicketSessionIDLength != 0 {
- sessionIdLen = c.config.Bugs.TicketSessionIDLength
+ sessionIDLen = c.config.Bugs.TicketSessionIDLength
}
if c.config.Bugs.EmptyTicketSessionID {
- sessionIdLen = 0
+ sessionIDLen = 0
}
- hello.sessionId = make([]byte, sessionIdLen)
- if _, err := io.ReadFull(c.config.rand(), hello.sessionId); err != nil {
+ hello.sessionID = make([]byte, sessionIDLen)
+ if _, err := io.ReadFull(c.config.rand(), hello.sessionID); err != nil {
c.sendAlert(alertInternalError)
return errors.New("tls: short read from Rand: " + err.Error())
}
} else {
- hello.sessionId = session.sessionId
+ hello.sessionID = session.sessionID
}
}
}
@@ -421,15 +421,15 @@
// ID. Although BoringSSL always enables compatibility mode, other
// implementations make it conditional on the ClientHello. We test
// BoringSSL's expected behavior with SendClientHelloSessionID.
- if len(hello.sessionId) == 0 && maxVersion >= VersionTLS13 {
- hello.sessionId = make([]byte, 32)
- if _, err := io.ReadFull(c.config.rand(), hello.sessionId); err != nil {
+ if len(hello.sessionID) == 0 && maxVersion >= VersionTLS13 {
+ hello.sessionID = make([]byte, 32)
+ if _, err := io.ReadFull(c.config.rand(), hello.sessionID); err != nil {
c.sendAlert(alertInternalError)
return errors.New("tls: short read from Rand: " + err.Error())
}
}
if c.config.Bugs.MockQUICTransport != nil && !c.config.Bugs.CompatModeWithQUIC {
- hello.sessionId = []byte{}
+ hello.sessionID = []byte{}
}
if c.config.Bugs.SendCipherSuites != nil {
@@ -448,7 +448,7 @@
hello.hasEarlyData = false
}
if c.config.Bugs.SendClientHelloSessionID != nil {
- hello.sessionId = c.config.Bugs.SendClientHelloSessionID
+ hello.sessionID = c.config.Bugs.SendClientHelloSessionID
}
var helloBytes []byte
@@ -459,7 +459,7 @@
vers: hello.vers,
cipherSuites: hello.cipherSuites,
// No session resumption for V2ClientHello.
- sessionId: nil,
+ sessionID: nil,
challenge: hello.random[1:],
}
helloBytes = v2Hello.marshal()
@@ -837,7 +837,7 @@
if c.config.Bugs.RequireSessionTickets && len(hs.session.sessionTicket) == 0 {
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")
}
sessionCache.Put(cacheKey, hs.session)
@@ -858,7 +858,7 @@
func (hs *clientHandshakeState) doTLS13Handshake() error {
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.")
}
@@ -1805,14 +1805,14 @@
}
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.
//
- // 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
// EmptyTicketSessionID.
- return hs.session != nil && hs.hello.sessionId != nil &&
- bytes.Equal(hs.serverHello.sessionId, hs.hello.sessionId)
+ return hs.session != nil && hs.hello.sessionID != nil &&
+ bytes.Equal(hs.serverHello.sessionID, hs.hello.sessionID)
}
func (hs *clientHandshakeState) processServerHello() (bool, error) {
@@ -1903,8 +1903,8 @@
if c.config.Bugs.ExpectNewTicket {
return errors.New("tls: expected new ticket")
}
- if hs.session == nil && len(hs.serverHello.sessionId) > 0 {
- session.sessionId = hs.serverHello.sessionId
+ if hs.session == nil && len(hs.serverHello.sessionID) > 0 {
+ session.sessionID = hs.serverHello.sessionID
hs.session = session
}
return nil
diff --git a/ssl/test/runner/handshake_messages.go b/ssl/test/runner/handshake_messages.go
index 0e60797..443f5ab 100644
--- a/ssl/test/runner/handshake_messages.go
+++ b/ssl/test/runner/handshake_messages.go
@@ -296,7 +296,7 @@
isDTLS bool
vers uint16
random []byte
- sessionId []byte
+ sessionID []byte
cookie []byte
cipherSuites []uint16
compressionMethods []uint8
@@ -366,8 +366,8 @@
hello := handshakeMsg.addU24LengthPrefixed()
hello.addU16(m.vers)
hello.addBytes(m.random)
- sessionId := hello.addU8LengthPrefixed()
- sessionId.addBytes(m.sessionId)
+ sessionID := hello.addU8LengthPrefixed()
+ sessionID.addBytes(m.sessionID)
if m.isDTLS {
cookie := hello.addU8LengthPrefixed()
cookie.addBytes(m.cookie)
@@ -770,8 +770,8 @@
reader := byteReader(data[4:])
if !reader.readU16(&m.vers) ||
!reader.readBytes(&m.random, 32) ||
- !reader.readU8LengthPrefixedBytes(&m.sessionId) ||
- len(m.sessionId) > 32 {
+ !reader.readU8LengthPrefixedBytes(&m.sessionID) ||
+ len(m.sessionID) > 32 {
return false
}
if m.isDTLS {
@@ -1094,7 +1094,7 @@
supportedVersOverride uint16
omitSupportedVers bool
random []byte
- sessionId []byte
+ sessionID []byte
cipherSuite uint16
hasKeyShare bool
keyShare keyShareEntry
@@ -1133,8 +1133,8 @@
}
hello.addBytes(m.random)
- sessionId := hello.addU8LengthPrefixed()
- sessionId.addBytes(m.sessionId)
+ sessionID := hello.addU8LengthPrefixed()
+ sessionID.addBytes(m.sessionID)
hello.addU16(m.cipherSuite)
hello.addU8(m.compressionMethod)
@@ -1206,7 +1206,7 @@
if !ok {
return false
}
- if !reader.readU8LengthPrefixedBytes(&m.sessionId) ||
+ if !reader.readU8LengthPrefixedBytes(&m.sessionID) ||
!reader.readU16(&m.cipherSuite) ||
!reader.readU8(&m.compressionMethod) {
return false
@@ -1714,7 +1714,7 @@
raw []byte
vers uint16
isServerHello bool
- sessionId []byte
+ sessionID []byte
cipherSuite uint16
compressionMethod uint8
hasSelectedGroup bool
@@ -1734,8 +1734,8 @@
retryRequest := retryRequestMsg.addU24LengthPrefixed()
retryRequest.addU16(VersionTLS12)
retryRequest.addBytes(tls13HelloRetryRequest)
- sessionId := retryRequest.addU8LengthPrefixed()
- sessionId.addBytes(m.sessionId)
+ sessionID := retryRequest.addU8LengthPrefixed()
+ sessionID.addBytes(m.sessionID)
retryRequest.addU16(m.cipherSuite)
retryRequest.addU8(m.compressionMethod)
@@ -1781,7 +1781,7 @@
var random []byte
var compressionMethod byte
if !reader.readBytes(&random, 32) ||
- !reader.readU8LengthPrefixedBytes(&m.sessionId) ||
+ !reader.readU8LengthPrefixedBytes(&m.sessionID) ||
!reader.readU16(&m.cipherSuite) ||
!reader.readU8(&compressionMethod) ||
compressionMethod != 0 {
@@ -2583,7 +2583,7 @@
raw []byte
vers uint16
cipherSuites []uint16
- sessionId []byte
+ sessionID []byte
challenge []byte
}
@@ -2592,7 +2592,7 @@
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[0] = 1
@@ -2600,8 +2600,8 @@
x[2] = uint8(m.vers)
x[3] = uint8((len(m.cipherSuites) * 3) >> 8)
x[4] = uint8(len(m.cipherSuites) * 3)
- x[5] = uint8(len(m.sessionId) >> 8)
- x[6] = uint8(len(m.sessionId))
+ x[5] = uint8(len(m.sessionID) >> 8)
+ x[6] = uint8(len(m.sessionID))
x[7] = uint8(len(m.challenge) >> 8)
x[8] = uint8(len(m.challenge))
y := x[9:]
@@ -2611,8 +2611,8 @@
y[i*3+2] = uint8(spec)
}
y = y[len(m.cipherSuites)*3:]
- copy(y, m.sessionId)
- y = y[len(m.sessionId):]
+ copy(y, m.sessionID)
+ y = y[len(m.sessionID):]
copy(y, m.challenge)
m.raw = x
diff --git a/ssl/test/runner/handshake_server.go b/ssl/test/runner/handshake_server.go
index e75a984..85561fc 100644
--- a/ssl/test/runner/handshake_server.go
+++ b/ssl/test/runner/handshake_server.go
@@ -289,11 +289,11 @@
}
}
- 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")
}
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")
}
if len(hs.clientHello.sessionTicket) > 0 {
@@ -376,7 +376,7 @@
hs.hello = &serverHelloMsg{
isDTLS: c.isDTLS,
vers: c.wireVersion,
- sessionId: hs.clientHello.sessionId,
+ sessionID: hs.clientHello.sessionID,
compressionMethod: config.Bugs.SendCompressionMethod,
versOverride: config.Bugs.SendServerHelloVersion,
supportedVersOverride: config.Bugs.SendServerSupportedVersionExtension,
@@ -553,7 +553,7 @@
}
helloRetryRequest := &helloRetryRequestMsg{
vers: c.wireVersion,
- sessionId: hs.clientHello.sessionId,
+ sessionID: hs.clientHello.sessionID,
cipherSuite: cipherSuite,
compressionMethod: config.Bugs.SendCompressionMethod,
duplicateExtensions: config.Bugs.DuplicateHelloRetryRequestExtensions,
@@ -932,7 +932,7 @@
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
}
@@ -1250,7 +1250,7 @@
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")
}
@@ -1305,11 +1305,11 @@
// For test purposes, check that the peer never offers a session when
// 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")
}
- 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")
}
@@ -1556,8 +1556,8 @@
}
var ok bool
- sessionId := string(hs.clientHello.sessionId)
- if hs.sessionState, ok = c.config.ServerSessionCache.Get(sessionId); !ok {
+ sessionID := string(hs.clientHello.sessionID)
+ if hs.sessionState, ok = c.config.ServerSessionCache.Get(sessionID); !ok {
return false
}
}
@@ -1613,7 +1613,7 @@
}
// We echo the client's session ID in the ServerHello to let it know
// 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
if c.config.Bugs.SendSCTListOnResume != nil {
@@ -1671,14 +1671,14 @@
// Generate a session ID if we're to save the session.
if !hs.hello.extensions.ticketSupported && config.ServerSessionCache != nil {
- hs.hello.sessionId = make([]byte, 32)
- if _, err := io.ReadFull(config.rand(), hs.hello.sessionId); err != nil {
+ hs.hello.sessionID = make([]byte, 32)
+ if _, err := io.ReadFull(config.rand(), hs.hello.sessionID); err != nil {
c.sendAlert(alertInternalError)
return errors.New("tls: short read from Rand: " + err.Error())
}
}
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)
@@ -2013,8 +2013,8 @@
}
if !hs.hello.extensions.ticketSupported || hs.c.config.Bugs.SkipNewSessionTicket {
- if c.config.ServerSessionCache != nil && len(hs.hello.sessionId) != 0 {
- c.config.ServerSessionCache.Put(string(hs.hello.sessionId), &state)
+ if c.config.ServerSessionCache != nil && len(hs.hello.sessionID) != 0 {
+ c.config.ServerSessionCache.Put(string(hs.hello.sessionID), &state)
}
return nil
}
diff --git a/ssl/test/runner/runner.go b/ssl/test/runner/runner.go
index 04d4d3e..e3931d7 100644
--- a/ssl/test/runner/runner.go
+++ b/ssl/test/runner/runner.go
@@ -15940,8 +15940,8 @@
}
const (
- shrinkingAlgId = 0xff01
- expandingAlgId = 0xff02
+ shrinkingAlgID = 0xff01
+ expandingAlgID = 0xff02
)
for _, ver := range tlsVersions {
@@ -15990,7 +15990,7 @@
config: Config{
MinVersion: ver.version,
MaxVersion: ver.version,
- CertCompressionAlgs: map[uint16]CertCompressionAlg{expandingAlgId: expanding},
+ CertCompressionAlgs: map[uint16]CertCompressionAlg{expandingAlgID: expanding},
},
})
@@ -16004,9 +16004,9 @@
config: Config{
MinVersion: ver.version,
MaxVersion: ver.version,
- CertCompressionAlgs: map[uint16]CertCompressionAlg{expandingAlgId: expanding},
+ CertCompressionAlgs: map[uint16]CertCompressionAlg{expandingAlgID: expanding},
Bugs: ProtocolBugs{
- ExpectedCompressedCert: expandingAlgId,
+ ExpectedCompressedCert: expandingAlgID,
},
},
})
@@ -16018,15 +16018,15 @@
config: Config{
MinVersion: ver.version,
MaxVersion: ver.version,
- CertCompressionAlgs: map[uint16]CertCompressionAlg{shrinkingAlgId: shrinking},
+ CertCompressionAlgs: map[uint16]CertCompressionAlg{shrinkingAlgID: shrinking},
Bugs: ProtocolBugs{
- ExpectedCompressedCert: shrinkingAlgId,
+ ExpectedCompressedCert: shrinkingAlgID,
},
},
})
// With both algorithms configured, the server should pick its most
- // preferable. (Which is expandingAlgId.)
+ // preferable. (Which is expandingAlgID.)
testCases = append(testCases, testCase{
testType: serverTest,
name: "CertCompressionPriority-" + ver.name,
@@ -16035,11 +16035,11 @@
MinVersion: ver.version,
MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{
- shrinkingAlgId: shrinking,
- expandingAlgId: expanding,
+ shrinkingAlgID: shrinking,
+ expandingAlgID: expanding,
},
Bugs: ProtocolBugs{
- ExpectedCompressedCert: expandingAlgId,
+ ExpectedCompressedCert: expandingAlgID,
},
},
})
@@ -16052,10 +16052,10 @@
MinVersion: ver.version,
MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{
- expandingAlgId: expanding,
+ expandingAlgID: expanding,
},
Bugs: ProtocolBugs{
- ExpectedCompressedCert: expandingAlgId,
+ ExpectedCompressedCert: expandingAlgID,
},
},
})
@@ -16068,27 +16068,27 @@
MinVersion: ver.version,
MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{
- shrinkingAlgId: shrinking,
+ shrinkingAlgID: shrinking,
},
Bugs: ProtocolBugs{
- ExpectedCompressedCert: shrinkingAlgId,
+ ExpectedCompressedCert: shrinkingAlgID,
},
},
})
testCases = append(testCases, testCase{
testType: clientTest,
- name: "CertCompressionBadAlgIdClient-" + ver.name,
+ name: "CertCompressionBadAlgIDClient-" + ver.name,
flags: []string{"-install-cert-compression-algs"},
config: Config{
MinVersion: ver.version,
MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{
- shrinkingAlgId: shrinking,
+ shrinkingAlgID: shrinking,
},
Bugs: ProtocolBugs{
- ExpectedCompressedCert: shrinkingAlgId,
- SendCertCompressionAlgId: 1234,
+ ExpectedCompressedCert: shrinkingAlgID,
+ SendCertCompressionAlgID: 1234,
},
},
shouldFail: true,
@@ -16103,10 +16103,10 @@
MinVersion: ver.version,
MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{
- shrinkingAlgId: shrinking,
+ shrinkingAlgID: shrinking,
},
Bugs: ProtocolBugs{
- ExpectedCompressedCert: shrinkingAlgId,
+ ExpectedCompressedCert: shrinkingAlgID,
SendCertUncompressedLength: 12,
},
},
@@ -16122,10 +16122,10 @@
MinVersion: ver.version,
MaxVersion: ver.version,
CertCompressionAlgs: map[uint16]CertCompressionAlg{
- shrinkingAlgId: shrinking,
+ shrinkingAlgID: shrinking,
},
Bugs: ProtocolBugs{
- ExpectedCompressedCert: shrinkingAlgId,
+ ExpectedCompressedCert: shrinkingAlgID,
SendCertUncompressedLength: 1 << 20,
},
},