pHash implements the P_hash function, as defined in RFC 4346, Section 5.
(result, secret, seed []byte, hash func() hash.Hash)
| 29 | |
| 30 | // pHash implements the P_hash function, as defined in RFC 4346, Section 5. |
| 31 | func pHash(result, secret, seed []byte, hash func() hash.Hash) { |
| 32 | h := hmac.New(hash, secret) |
| 33 | h.Write(seed) |
| 34 | a := h.Sum(nil) |
| 35 | |
| 36 | j := 0 |
| 37 | for j < len(result) { |
| 38 | h.Reset() |
| 39 | h.Write(a) |
| 40 | h.Write(seed) |
| 41 | b := h.Sum(nil) |
| 42 | copy(result[j:], b) |
| 43 | j += len(b) |
| 44 | |
| 45 | h.Reset() |
| 46 | h.Write(a) |
| 47 | a = h.Sum(nil) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // prf10 implements the TLS 1.0 pseudo-random function, as defined in RFC 2246, Section 5. |
| 52 | func prf10(secret []byte, label string, seed []byte, keyLen int) []byte { |