Documentation ¶
Overview ¶
Package prf implements TLS 1.2 Pseudorandom functions
Index ¶
- func ExtendedMasterSecret(preMasterSecret, sessionHash []byte, h HashFunc) ([]byte, error)
- func MasterSecret(preMasterSecret, clientRandom, serverRandom []byte, h HashFunc) ([]byte, error)
- func PHash(secret, seed []byte, requestedLength int, h HashFunc) ([]byte, error)
- func PSKPreMasterSecret(psk []byte) []byte
- func PreMasterSecret(publicKey, privateKey []byte, curve elliptic.Curve) ([]byte, error)
- func VerifyDataClient(masterSecret, handshakeBodies []byte, h HashFunc) ([]byte, error)
- func VerifyDataServer(masterSecret, handshakeBodies []byte, h HashFunc) ([]byte, error)
- type EncryptionKeys
- type HashFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtendedMasterSecret ¶
ExtendedMasterSecret generates a Extended MasterSecret as defined in https://tools.ietf.org/html/rfc7627
func MasterSecret ¶
MasterSecret generates a TLS 1.2 MasterSecret
func PHash ¶
PHash is PRF is the SHA-256 hash function is used for all cipher suites defined in this TLS 1.2 document and in TLS documents published prior to this document when TLS 1.2 is negotiated. New cipher suites MUST explicitly specify a PRF and, in general, SHOULD use the TLS PRF with SHA-256 or a stronger standard hash function.
P_hash(secret, seed) = HMAC_hash(secret, A(1) + seed) + HMAC_hash(secret, A(2) + seed) + HMAC_hash(secret, A(3) + seed) + ...
A() is defined as:
A(0) = seed A(i) = HMAC_hash(secret, A(i-1))
P_hash can be iterated as many times as necessary to produce the required quantity of data. For example, if P_SHA256 is being used to create 80 bytes of data, it will have to be iterated three times (through A(3)), creating 96 bytes of output data; the last 16 bytes of the final iteration will then be discarded, leaving 80 bytes of output data.
func PSKPreMasterSecret ¶
PSKPreMasterSecret generates the PSK Premaster Secret The premaster secret is formed as follows: if the PSK is N octets long, concatenate a uint16 with the value N, N zero octets, a second uint16 with the value N, and the PSK itself.
func PreMasterSecret ¶
PreMasterSecret implements TLS 1.2 Premaster Secret generation given a keypair and a curve
func VerifyDataClient ¶
VerifyDataClient is caled on the Client Side to either verify or generate the VerifyData message
Types ¶
type EncryptionKeys ¶
type EncryptionKeys struct { MasterSecret []byte ClientMACKey []byte ServerMACKey []byte ClientWriteKey []byte ServerWriteKey []byte ClientWriteIV []byte ServerWriteIV []byte }
EncryptionKeys is all the state needed for a TLS CipherSuite
func GenerateEncryptionKeys ¶
func GenerateEncryptionKeys(masterSecret, clientRandom, serverRandom []byte, macLen, keyLen, ivLen int, h HashFunc) (*EncryptionKeys, error)
GenerateEncryptionKeys is the final step TLS 1.2 PRF. Given all state generated so far generates the final keys need for encryption
func (*EncryptionKeys) String ¶
func (e *EncryptionKeys) String() string