crypto/tls: prepare for TLS 1.3 client handshake.
This change splits handshake processing for TLS 1.3, reindenting the TLS 1.2 code path and splitting initializationg of the handshake hash. No equivalent is added for processServerHello because session resumption is not supported yet.
This commit is contained in:
parent
9eb1d7faf7
commit
634f9a5858
7
13.go
7
13.go
@ -735,3 +735,10 @@ func (hs *serverHandshakeState) traceErr(err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (hs *clientHandshakeState) doTLS13Handshake() error {
|
||||||
|
// TODO key exchange phase
|
||||||
|
// TODO server params phase
|
||||||
|
// TODO auth phase
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -25,9 +25,14 @@ type clientHandshakeState struct {
|
|||||||
serverHello *serverHelloMsg
|
serverHello *serverHelloMsg
|
||||||
hello *clientHelloMsg
|
hello *clientHelloMsg
|
||||||
suite *cipherSuite
|
suite *cipherSuite
|
||||||
finishedHash finishedHash
|
|
||||||
masterSecret []byte
|
masterSecret []byte
|
||||||
session *ClientSessionState
|
session *ClientSessionState
|
||||||
|
|
||||||
|
// TLS 1.0-1.2 fields
|
||||||
|
finishedHash finishedHash
|
||||||
|
|
||||||
|
// TLS 1.3 fields
|
||||||
|
keySchedule *keySchedule13
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeClientHello(config *Config) (*clientHelloMsg, error) {
|
func makeClientHello(config *Config) (*clientHelloMsg, error) {
|
||||||
@ -214,7 +219,13 @@ func (hs *clientHandshakeState) handshake() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
isResume, err := hs.processServerHello()
|
var isResume bool
|
||||||
|
if c.vers >= VersionTLS13 {
|
||||||
|
hs.keySchedule = newKeySchedule13(hs.suite, c.config, hs.hello.random)
|
||||||
|
hs.keySchedule.write(hs.hello.marshal())
|
||||||
|
hs.keySchedule.write(hs.serverHello.marshal())
|
||||||
|
} else {
|
||||||
|
isResume, err = hs.processServerHello()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -231,9 +242,17 @@ func (hs *clientHandshakeState) handshake() error {
|
|||||||
|
|
||||||
hs.finishedHash.Write(hs.hello.marshal())
|
hs.finishedHash.Write(hs.hello.marshal())
|
||||||
hs.finishedHash.Write(hs.serverHello.marshal())
|
hs.finishedHash.Write(hs.serverHello.marshal())
|
||||||
|
}
|
||||||
|
|
||||||
c.buffering = true
|
c.buffering = true
|
||||||
if isResume {
|
if c.vers >= VersionTLS13 {
|
||||||
|
if err := hs.doTLS13Handshake(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := c.flush(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else if isResume {
|
||||||
if err := hs.establishKeys(); err != nil {
|
if err := hs.establishKeys(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user