// Package fipstls12 implements the TLS 1.2 PRF and extended-master-secret // derivation (RFC 5246 §5, RFC 7627). It is a shim for the GOROOT-private // crypto/internal/fips140/tls12, using public crypto/hmac and dropping the // FIPS service-indicator bookkeeping (which has no wire effect).
package fipstls12 import ( ) // PRF implements the TLS 1.2 pseudo-random function. func [ hash.Hash]( func() , []byte, string, []byte, int) []byte { := make([]byte, len()+len()) copy(, ) copy([len():], ) := make([]byte, ) pHash(, , , ) return } // pHash implements the P_hash function from RFC 5246 §5. func pHash[ hash.Hash]( func() , , , []byte) { := func() hash.Hash { return () } := hmac.New(, ) .Write() := .Sum(nil) for len() > 0 { .Reset() .Write() .Write() := .Sum(nil) := copy(, ) = [:] .Reset() .Write() = .Sum(nil) } } const masterSecretLength = 48 const extendedMasterSecretLabel = "extended master secret" // MasterSecret implements the TLS 1.2 extended master secret derivation // (RFC 7627). func [ hash.Hash]( func() , , []byte) []byte { return PRF(, , extendedMasterSecretLabel, , masterSecretLength) }