mirror of
https://github.com/golang/go
synced 2024-11-18 04:14:49 -07:00
crypto/tls: len(clientRandom) used for serverRandom source
In keysFromMasterSecret(), don't copy from serverRandom into seed[:len(clientRandom)]. Actually, switch from an array to a slice in keysFromMasterSecret() and masterFromPreMasterSecret() so the length need not be given; that's how it's done elsewhere in the file. Fixes #13181 Change-Id: I92abaa892d1bba80c2d4f12776341cda7d538837 Reviewed-on: https://go-review.googlesource.com/16697 Run-TryBot: Adam Langley <agl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Adam Langley <agl@golang.org>
This commit is contained in:
parent
9f08b6c494
commit
9c8cd83753
@ -145,11 +145,12 @@ func prfForVersion(version uint16, suite *cipherSuite) func(result, secret, labe
|
|||||||
// masterFromPreMasterSecret generates the master secret from the pre-master
|
// masterFromPreMasterSecret generates the master secret from the pre-master
|
||||||
// secret. See http://tools.ietf.org/html/rfc5246#section-8.1
|
// secret. See http://tools.ietf.org/html/rfc5246#section-8.1
|
||||||
func masterFromPreMasterSecret(version uint16, suite *cipherSuite, preMasterSecret, clientRandom, serverRandom []byte) []byte {
|
func masterFromPreMasterSecret(version uint16, suite *cipherSuite, preMasterSecret, clientRandom, serverRandom []byte) []byte {
|
||||||
var seed [tlsRandomLength * 2]byte
|
seed := make([]byte, 0, len(clientRandom)+len(serverRandom))
|
||||||
copy(seed[0:len(clientRandom)], clientRandom)
|
seed = append(seed, clientRandom...)
|
||||||
copy(seed[len(clientRandom):], serverRandom)
|
seed = append(seed, serverRandom...)
|
||||||
|
|
||||||
masterSecret := make([]byte, masterSecretLength)
|
masterSecret := make([]byte, masterSecretLength)
|
||||||
prfForVersion(version, suite)(masterSecret, preMasterSecret, masterSecretLabel, seed[0:])
|
prfForVersion(version, suite)(masterSecret, preMasterSecret, masterSecretLabel, seed)
|
||||||
return masterSecret
|
return masterSecret
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,13 +158,13 @@ func masterFromPreMasterSecret(version uint16, suite *cipherSuite, preMasterSecr
|
|||||||
// secret, given the lengths of the MAC key, cipher key and IV, as defined in
|
// secret, given the lengths of the MAC key, cipher key and IV, as defined in
|
||||||
// RFC 2246, section 6.3.
|
// RFC 2246, section 6.3.
|
||||||
func keysFromMasterSecret(version uint16, suite *cipherSuite, masterSecret, clientRandom, serverRandom []byte, macLen, keyLen, ivLen int) (clientMAC, serverMAC, clientKey, serverKey, clientIV, serverIV []byte) {
|
func keysFromMasterSecret(version uint16, suite *cipherSuite, masterSecret, clientRandom, serverRandom []byte, macLen, keyLen, ivLen int) (clientMAC, serverMAC, clientKey, serverKey, clientIV, serverIV []byte) {
|
||||||
var seed [tlsRandomLength * 2]byte
|
seed := make([]byte, 0, len(serverRandom)+len(clientRandom))
|
||||||
copy(seed[0:len(clientRandom)], serverRandom)
|
seed = append(seed, serverRandom...)
|
||||||
copy(seed[len(serverRandom):], clientRandom)
|
seed = append(seed, clientRandom...)
|
||||||
|
|
||||||
n := 2*macLen + 2*keyLen + 2*ivLen
|
n := 2*macLen + 2*keyLen + 2*ivLen
|
||||||
keyMaterial := make([]byte, n)
|
keyMaterial := make([]byte, n)
|
||||||
prfForVersion(version, suite)(keyMaterial, masterSecret, keyExpansionLabel, seed[0:])
|
prfForVersion(version, suite)(keyMaterial, masterSecret, keyExpansionLabel, seed)
|
||||||
clientMAC = keyMaterial[:macLen]
|
clientMAC = keyMaterial[:macLen]
|
||||||
keyMaterial = keyMaterial[macLen:]
|
keyMaterial = keyMaterial[macLen:]
|
||||||
serverMAC = keyMaterial[:macLen]
|
serverMAC = keyMaterial[:macLen]
|
||||||
|
Loading…
Reference in New Issue
Block a user