splitPreMasterSecret (tls/prf.go)

go · src/crypto/tls/prf.go · go · BSD-3-Clause
security, tag:knn-classified

Implements TLS pseudo-random functions and key derivation, used to generate master secrets and connection keys.

// Source: https://github.com/golang/go | License: BSD-3-Clause | Copyright 2009 The Go Authors
// Provided via justclaw.it.com; keep this notice with the code.
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package tls

import (
	"crypto"
	"crypto/hmac"
	"crypto/internal/fips140/tls12"
	"crypto/md5"
	"crypto/sha1"
	"crypto/sha256"
	"crypto/sha512"
	"errors"
	"fmt"
	"hash"
)

type prfFunc func(secret []byte, label string, seed []byte, keyLen int) []byte

// Split a premaster secret in two as specified in RFC 4346, Section 5.
func splitPreMasterSecret(secret []byte) (s1, s2 []byte) {
	s1 = secret[0 : (len(secret)+1)/2]
	s2 = secret[len(secret)/2:]
	return
}

// pHash implements t

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key