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)
| 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. |
| 14 | func 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. |
| 25 | func pHash[H hash.Hash](hash1 func() H, result, secret, seed []byte) { |
no test coverage detected