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

Function pHash

tls12/tls12.go:25–42  ·  view source on GitHub ↗

pHash implements the P_hash function, as defined in RFC 5246, Section 5.

(hash1 func() H, result, secret, seed []byte)

Source from the content-addressed store, hash-verified

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) {
26 h := hmac.New(any(hash1).(func() hash.Hash), secret)
27 h.Write(seed)
28 a := h.Sum(nil)
29
30 for len(result) > 0 {
31 h.Reset()
32 h.Write(a)
33 h.Write(seed)
34 b := h.Sum(nil)
35 n := copy(result, b)
36 result = result[n:]
37
38 h.Reset()
39 h.Write(a)
40 a = h.Sum(nil)
41 }
42}
43
44const masterSecretLength = 48
45const extendedMasterSecretLabel = "extended master secret"

Callers 1

PRFFunction · 0.70

Calls 3

ResetMethod · 0.80
WriteMethod · 0.65
SumMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…