Documentation
¶
Overview ¶
Package tlssynth builds synthetic TLS handshake bytes for tests and for generating sample captures.
It deliberately does not import tlsparse and defines its own codepoint constants. A test oracle that shares definitions with the code under test cannot catch a wrong constant: rename a value in the parser and a shared table follows it silently. Keeping the two independent means the builders encode what the RFCs say, and the parser has to agree with that.
Index ¶
- Constants
- Variables
- func CertificateMsg(chain [][]byte) []byte
- func ClientHello(s ClientHelloSpec) []byte
- func CryptoFrame(offset uint64, data []byte) []byte
- func HandshakeMsg(typ uint8, body []byte) []byte
- func KeyShareLen(group uint16) int
- func QUICInitial(dcid, scid []byte, server bool, packetNumber uint32, frames []byte, padTo int) []byte
- func Records(contentType uint8, payload []byte, chunk int) []byte
- func ServerHello(s ServerHelloSpec) []byte
- func ServerKeyExchangeECDHE(group uint16) []byte
- type ClientHelloSpec
- type ServerHelloSpec
Constants ¶
const ( RecordHandshake uint8 = 22 RecordChangeCipherSpec uint8 = 20 RecordApplicationData uint8 = 23 MsgClientHello uint8 = 1 MsgServerHello uint8 = 2 MsgCertificate uint8 = 11 MsgServerKeyExchange uint8 = 12 MsgServerHelloDone uint8 = 14 )
Codepoints used by the builders, written out independently of the parser.
const QUICVersion1 uint32 = 0x00000001
QUICVersion1 is the version generated packets carry.
Variables ¶
var HelloRetryRequestRandom = []byte{
0xcf, 0x21, 0xad, 0x74, 0xe5, 0x9a, 0x61, 0x11,
0xbe, 0x1d, 0x8c, 0x02, 0x1e, 0x65, 0xb8, 0x91,
0xc2, 0xa2, 0x11, 0x16, 0x7a, 0xbb, 0x8c, 0x5e,
0x07, 0x9e, 0x09, 0xe2, 0xc8, 0xa8, 0x33, 0x9c,
}
HelloRetryRequestRandom is the fixed Random marking a HelloRetryRequest (RFC 8446 section 4.1.3): SHA-256 of "HelloRetryRequest".
Functions ¶
func CertificateMsg ¶
CertificateMsg builds a TLS 1.2 Certificate message body from raw DER.
func ClientHello ¶
func ClientHello(s ClientHelloSpec) []byte
ClientHello builds a ClientHello message body, without the handshake header.
func CryptoFrame ¶
CryptoFrame wraps handshake bytes in a QUIC CRYPTO frame at an offset.
func HandshakeMsg ¶
HandshakeMsg prefixes a body with its four-byte handshake header.
func KeyShareLen ¶
KeyShareLen returns a realistic public key length for a group. The post-quantum sizes are the reason a PQ ClientHello does not fit in one TCP segment: X25519MLKEM768 alone is 1216 bytes of client share.
func QUICInitial ¶
func QUICInitial(dcid, scid []byte, server bool, packetNumber uint32, frames []byte, padTo int) []byte
QUICInitial builds one protected Initial packet carrying frames.
padTo pads the packet with PADDING frames, as a client's first Initial must be (RFC 9000 requires at least 1200 bytes); pass 0 for none.
func Records ¶
Records wraps a byte stream in TLS records of at most chunk bytes each. A chunk smaller than the payload exercises handshake fragmentation.
func ServerHello ¶
func ServerHello(s ServerHelloSpec) []byte
ServerHello builds a ServerHello message body, without the handshake header.
func ServerKeyExchangeECDHE ¶
ServerKeyExchangeECDHE builds a TLS 1.2 ECDHE ServerKeyExchange body. It is the only place a TLS 1.2 handshake names its key exchange group.
Types ¶
type ClientHelloSpec ¶
type ClientHelloSpec struct {
LegacyVersion uint16
Ciphers []uint16
Compression []uint8
SNI string
ALPN []string
SupportedVersions []uint16
Groups []uint16
SigAlgs []uint16
ECH bool
QUIC bool
OmitExtensions bool
// NoGREASE suppresses the injected GREASE values, for building a
// non-browser client.
NoGREASE bool
}
ClientHelloSpec describes a ClientHello to build. GREASE values are added automatically in the places a real BoringSSL client puts them.