Fix Client Certificate Verification when Using Extended Master Secret

This commit is contained in:
Dunya Kokoschka 2022-11-17 16:58:12 +00:00
parent 1b3a9ad4c5
commit 0bf125eab6
2 changed files with 5 additions and 3 deletions

View file

@ -600,6 +600,9 @@ func (hs *clientHandshakeState) doFullHandshake() error {
}
}
/* sessionHash does not include CertificateVerify */
sessionHash := hs.finishedHash.Sum()
if chainToSend != nil && len(chainToSend.Certificate) > 0 {
certVerify := &certificateVerifyMsg{}
@ -649,7 +652,7 @@ func (hs *clientHandshakeState) doFullHandshake() error {
}
if hs.hello.ems && hs.serverHello.ems {
hs.masterSecret = extendedMasterFromPreMasterSecret(c.vers, hs.suite, preMasterSecret, hs.finishedHash)
hs.masterSecret = extendedMasterFromPreMasterSecret(c.vers, hs.suite, preMasterSecret, sessionHash)
} else {
hs.masterSecret = masterFromPreMasterSecret(c.vers, hs.suite, preMasterSecret, hs.hello.random, hs.serverHello.random)
}

View file

@ -530,8 +530,7 @@ var extendedMasterSecretLabel = []byte("extended master secret")
// extendedMasterFromPreMasterSecret generates the master secret from the pre-master
// secret and session hash. See https://tools.ietf.org/html/rfc7627#section-4
func extendedMasterFromPreMasterSecret(version uint16, suite *cipherSuite, preMasterSecret []byte, fh finishedHash) []byte {
sessionHash := fh.Sum()
func extendedMasterFromPreMasterSecret(version uint16, suite *cipherSuite, preMasterSecret []byte, sessionHash []byte) []byte {
masterSecret := make([]byte, masterSecretLength)
prfForVersion(version, suite)(masterSecret, preMasterSecret, extendedMasterSecretLabel, sessionHash)
return masterSecret