Rename EncryptedExtensions in Go in preparation for TLS 1.3.

TLS 1.3 defines its own EncryptedExtensions message. The existing one is
for Channel ID which probably should not have tried to generalize
itself.

Change-Id: I4f48bece98510eb54e64fbf3df6c2a7332bc0261
Reviewed-on: https://boringssl-review.googlesource.com/8566
Reviewed-by: David Benjamin <davidben@google.com>
This commit is contained in:
David Benjamin 2016-06-30 18:56:53 -04:00
parent cecee27c99
commit 24599a89c0
5 changed files with 33 additions and 33 deletions

View File

@ -49,21 +49,21 @@ const (
// TLS handshake message types.
const (
typeHelloRequest uint8 = 0
typeClientHello uint8 = 1
typeServerHello uint8 = 2
typeHelloVerifyRequest uint8 = 3
typeNewSessionTicket uint8 = 4
typeCertificate uint8 = 11
typeServerKeyExchange uint8 = 12
typeCertificateRequest uint8 = 13
typeServerHelloDone uint8 = 14
typeCertificateVerify uint8 = 15
typeClientKeyExchange uint8 = 16
typeFinished uint8 = 20
typeCertificateStatus uint8 = 22
typeNextProtocol uint8 = 67 // Not IANA assigned
typeEncryptedExtensions uint8 = 203 // Not IANA assigned
typeHelloRequest uint8 = 0
typeClientHello uint8 = 1
typeServerHello uint8 = 2
typeHelloVerifyRequest uint8 = 3
typeNewSessionTicket uint8 = 4
typeCertificate uint8 = 11
typeServerKeyExchange uint8 = 12
typeCertificateRequest uint8 = 13
typeServerHelloDone uint8 = 14
typeCertificateVerify uint8 = 15
typeClientKeyExchange uint8 = 16
typeFinished uint8 = 20
typeCertificateStatus uint8 = 22
typeNextProtocol uint8 = 67 // Not IANA assigned
typeChannelID uint8 = 203 // Not IANA assigned
)
// TLS compression types.

View File

@ -1107,8 +1107,8 @@ func (c *Conn) readHandshake() (interface{}, error) {
m = new(finishedMsg)
case typeHelloVerifyRequest:
m = new(helloVerifyRequestMsg)
case typeEncryptedExtensions:
m = new(encryptedExtensionsMsg)
case typeChannelID:
m = new(channelIDMsg)
default:
return nil, c.in.setErrorLocked(c.sendAlert(alertUnexpectedMessage))
}

View File

@ -880,7 +880,7 @@ func (hs *clientHandshakeState) sendFinished(out []byte, isResume bool) error {
}
if hs.serverHello.channelIDRequested {
encryptedExtensions := new(encryptedExtensionsMsg)
channelIDMsg := new(channelIDMsg)
if c.config.ChannelID.Curve != elliptic.P256() {
return fmt.Errorf("tls: Channel ID is not on P-256.")
}
@ -897,14 +897,14 @@ func (hs *clientHandshakeState) sendFinished(out []byte, isResume bool) error {
writeIntPadded(channelID[32:64], c.config.ChannelID.Y)
writeIntPadded(channelID[64:96], r)
writeIntPadded(channelID[96:128], s)
encryptedExtensions.channelID = channelID
channelIDMsg.channelID = channelID
c.channelID = &c.config.ChannelID.PublicKey
encryptedExtensionsBytes := encryptedExtensions.marshal()
hs.writeHash(encryptedExtensionsBytes, seqno)
channelIDMsgBytes := channelIDMsg.marshal()
hs.writeHash(channelIDMsgBytes, seqno)
seqno++
postCCSBytes = append(postCCSBytes, encryptedExtensionsBytes...)
postCCSBytes = append(postCCSBytes, channelIDMsgBytes...)
}
finished := new(finishedMsg)

View File

@ -1641,12 +1641,12 @@ func (m *helloVerifyRequestMsg) unmarshal(data []byte) bool {
return true
}
type encryptedExtensionsMsg struct {
type channelIDMsg struct {
raw []byte
channelID []byte
}
func (m *encryptedExtensionsMsg) marshal() []byte {
func (m *channelIDMsg) marshal() []byte {
if m.raw != nil {
return m.raw
}
@ -1654,7 +1654,7 @@ func (m *encryptedExtensionsMsg) marshal() []byte {
length := 2 + 2 + len(m.channelID)
x := make([]byte, 4+length)
x[0] = typeEncryptedExtensions
x[0] = typeChannelID
x[1] = uint8(length >> 16)
x[2] = uint8(length >> 8)
x[3] = uint8(length)
@ -1667,7 +1667,7 @@ func (m *encryptedExtensionsMsg) marshal() []byte {
return x
}
func (m *encryptedExtensionsMsg) unmarshal(data []byte) bool {
func (m *channelIDMsg) unmarshal(data []byte) bool {
if len(data) != 4+2+2+128 {
return false
}

View File

@ -793,15 +793,15 @@ func (hs *serverHandshakeState) readFinished(out []byte, isResume bool) error {
if err != nil {
return err
}
encryptedExtensions, ok := msg.(*encryptedExtensionsMsg)
channelIDMsg, ok := msg.(*channelIDMsg)
if !ok {
c.sendAlert(alertUnexpectedMessage)
return unexpectedMessageError(encryptedExtensions, msg)
return unexpectedMessageError(channelIDMsg, msg)
}
x := new(big.Int).SetBytes(encryptedExtensions.channelID[0:32])
y := new(big.Int).SetBytes(encryptedExtensions.channelID[32:64])
r := new(big.Int).SetBytes(encryptedExtensions.channelID[64:96])
s := new(big.Int).SetBytes(encryptedExtensions.channelID[96:128])
x := new(big.Int).SetBytes(channelIDMsg.channelID[0:32])
y := new(big.Int).SetBytes(channelIDMsg.channelID[32:64])
r := new(big.Int).SetBytes(channelIDMsg.channelID[64:96])
s := new(big.Int).SetBytes(channelIDMsg.channelID[96:128])
if !elliptic.P256().IsOnCurve(x, y) {
return errors.New("tls: invalid channel ID public key")
}
@ -815,7 +815,7 @@ func (hs *serverHandshakeState) readFinished(out []byte, isResume bool) error {
}
c.channelID = channelID
hs.writeClientHash(encryptedExtensions.marshal())
hs.writeClientHash(channelIDMsg.marshal())
}
msg, err := c.readHandshake()