MCPcopy
hub / github.com/XTLS/REALITY / keysFromMasterSecret

Function keysFromMasterSecret

prf.go:135–154  ·  view source on GitHub ↗

keysFromMasterSecret generates the connection keys from the master secret, given the lengths of the MAC key, cipher key and IV, as defined in RFC 2246, Section 6.3.

(version uint16, suite *cipherSuite, masterSecret, clientRandom, serverRandom []byte, macLen, keyLen, ivLen int)

Source from the content-addressed store, hash-verified

133// secret, given the lengths of the MAC key, cipher key and IV, as defined in
134// RFC 2246, Section 6.3.
135func keysFromMasterSecret(version uint16, suite *cipherSuite, masterSecret, clientRandom, serverRandom []byte, macLen, keyLen, ivLen int) (clientMAC, serverMAC, clientKey, serverKey, clientIV, serverIV []byte) {
136 seed := make([]byte, 0, len(serverRandom)+len(clientRandom))
137 seed = append(seed, serverRandom...)
138 seed = append(seed, clientRandom...)
139
140 n := 2*macLen + 2*keyLen + 2*ivLen
141 keyMaterial := prfForVersion(version, suite)(masterSecret, keyExpansionLabel, seed, n)
142 clientMAC = keyMaterial[:macLen]
143 keyMaterial = keyMaterial[macLen:]
144 serverMAC = keyMaterial[:macLen]
145 keyMaterial = keyMaterial[macLen:]
146 clientKey = keyMaterial[:keyLen]
147 keyMaterial = keyMaterial[keyLen:]
148 serverKey = keyMaterial[:keyLen]
149 keyMaterial = keyMaterial[keyLen:]
150 clientIV = keyMaterial[:ivLen]
151 keyMaterial = keyMaterial[ivLen:]
152 serverIV = keyMaterial[:ivLen]
153 return
154}
155
156func newFinishedHash(version uint16, cipherSuite *cipherSuite) finishedHash {
157 var buffer []byte

Callers 2

establishKeysMethod · 0.85
establishKeysMethod · 0.85

Calls 1

prfForVersionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…