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

Function PRF

tls12/tls12.go:14–22  ·  view source on GitHub ↗

PRF implements the TLS 1.2 pseudo-random function, as defined in RFC 5246, Section 5 and allowed by SP 800-135, Revision 1, Section 4.2.2.

(hash func() H, secret []byte, label string, seed []byte, keyLen int)

Source from the content-addressed store, hash-verified

12// PRF implements the TLS 1.2 pseudo-random function, as defined in RFC 5246,
13// Section 5 and allowed by SP 800-135, Revision 1, Section 4.2.2.
14func PRF[H hash.Hash](hash func() H, secret []byte, label string, seed []byte, keyLen int) []byte {
15 labelAndSeed := make([]byte, len(label)+len(seed))
16 copy(labelAndSeed, label)
17 copy(labelAndSeed[len(label):], seed)
18
19 result := make([]byte, keyLen)
20 pHash(hash, result, secret, labelAndSeed)
21 return result
22}
23
24// pHash implements the P_hash function, as defined in RFC 5246, Section 5.
25func pHash[H hash.Hash](hash1 func() H, result, secret, seed []byte) {

Callers 2

prf12Function · 0.92
MasterSecretFunction · 0.85

Calls 1

pHashFunction · 0.70

Tested by

no test coverage detected