flight

package
v4.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package flight contains shared internal flight state and helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendConnectionIDExtensions

func AppendConnectionIDExtensions(
	values []extension.Value,
	cid []byte,
	enableRRC bool,
) []extension.Value

AppendConnectionIDExtensions appends a connection ID and, when enabled, RRC.

func CipherSuiteIDs

func CipherSuiteIDs(cipherSuites []dtlsconfig.CipherSuite) []uint16

func ClientHelloVersions

func ClientHelloVersions(hello *handshake.MessageClientHello) []protocol.Version

ClientHelloVersions returns the offered versions, using the legacy version only when supported_versions is absent.

func CommitSRTP

func CommitSRTP(state *dtlsstate.Common, decision negotiation.SRTPDecision)

CommitSRTP publishes a validated SRTP decision.

func DefaultCompressionMethods

func DefaultCompressionMethods() []*protocol.CompressionMethod

DefaultCompressionMethods returns the supported compression methods.

func FinalizeClientHello

FinalizeClientHello applies the hook and prevents it from enabling RRC when the configured CID path-migration policy does not permit RRC.

func FinalizeServerHello

FinalizeServerHello applies the hook and prevents it from enabling RRC when the configured CID path-migration policy does not permit RRC.

func FindCipherSuiteByID

func FindCipherSuiteByID(id uint16, suites []dtlsconfig.CipherSuite) (dtlsconfig.CipherSuite, bool)

FindCipherSuiteByID resolves a peer wire identifier to the configured local descriptor / factory.

func FindMatchingCipherSuite

func FindMatchingCipherSuite(a, b []dtlsconfig.CipherSuite) (dtlsconfig.CipherSuite, bool)

func SignatureSchemeIDs

func SignatureSchemeIDs(algorithms []signaturehash.Algorithm) []uint16

SignatureSchemeIDs converts negotiated signature algorithms to their identifiers for the payload-oriented extension codecs.

func SignatureSchemes

func SignatureSchemes(ids []uint16) []signaturehash.Algorithm

SignatureSchemes converts known identifiers into algorithms used by negotiation. Unknown identifiers remain preserved by the extension value and are ignored here.

func ValidateHookedConnectionIDLength

func ValidateHookedConnectionIDLength(values []extension.Value, cfg *dtlsconfig.HandshakeConfig, hookConfigured bool) error

ValidateHookedConnectionIDLength checks that a hello hook preserves the configured receive-cid length.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache() *Cache

func (*Cache) DecodeProtectedHandshakeItem

func (h *Cache) DecodeProtectedHandshakeItem(item *HandshakeCacheItem, expectedType handshake.Type, expectedSequence uint16, decoder HandshakeCacheDecoder) (*handshake.Handshake, error)

DecodeProtectedHandshakeItem decodes and retains one DTLS 1.3 protected handshake message, or returns the retained value by an earlier pull.

func (*Cache) DiscardBefore

func (h *Cache) DiscardBefore(epoch uint64, sequence int, isClient bool)

func (*Cache) DiscardRemoteAfter

func (h *Cache) DiscardRemoteAfter(sequence uint16, isClient bool)

DiscardRemoteAfter removes speculative messages received after the hello that selected DTLS 1.3. They arrived before version-specific epoch checks.

func (*Cache) Finish12

func (h *Cache) Finish12()

Finish12 freezes the completed transcript while allowing final-flight retransmission.

func (*Cache) FullPullMapItems

func (h *Cache) FullPullMapItems(startSeq int, cipherSuite dtlsconfig.CipherSuite, rules ...HandshakeCachePullRule) HandshakeCachePullResult

func (*Cache) FullPullMapOneOfItems

func (h *Cache) FullPullMapOneOfItems(startSeq int, cipherSuite dtlsconfig.CipherSuite, rules ...HandshakeCachePullRule) HandshakeCachePullResult

FullPullMapOneOfItems decodes exactly one of the allowed messages at startSeq. A different message from the same peer and epoch is an unexpected_message failure.

func (*Cache) IsClientHelloRetransmit

func (h *Cache) IsClientHelloRetransmit(content []byte) bool

IsClientHelloRetransmit recognizes a complete, unchanged copy of the latest epoch-zero ClientHello, even when its fragmentation differs. Content starts with a handshake header; the caller must check the record epoch and sender.

func (*Cache) Pull

func (h *Cache) Pull(rules ...HandshakeCachePullRule) []*HandshakeCacheItem

Pull returns a list handshakes that match the requested rules. The list will contain null entries for rules that can't be satisfied. Multiple entries may match a rule, but only the last match is returned (ie ClientHello with cookies).

func (*Cache) PullAndMerge

func (h *Cache) PullAndMerge(rules ...HandshakeCachePullRule) []byte

PullAndMerge calls pull and then merges the results, ignoring any null entries.

func (*Cache) PullExact

func (h *Cache) PullExact(messageSequence uint16, isClient bool) (*HandshakeCacheItem, bool)

PullExact returns the handshake message with the requested sequence and sender.

func (*Cache) PullSequential

func (h *Cache) PullSequential(
	startSeq int,
	rules ...HandshakeCachePullRule,
) HandshakeCacheItemPullResult

PullSequential selects messages at consecutive sequence numbers. Missing messages are incomplete.

func (*Cache) Push

func (h *Cache) Push(data []byte, epoch uint64, messageSequence uint16, typ handshake.Type, isClient bool)

func (*Cache) PushBounded12

func (h *Cache) PushBounded12(data []byte, epoch uint64, sequence uint16, typ handshake.Type, isClient bool) error

PushBounded12 retains a DTLS 1.2 transcript within a fixed per-connection budget. DTLS 1.3 has a separate post-handshake message lifecycle.

func (*Cache) SessionHash

func (h *Cache) SessionHash(hf prf.HashFunc, epoch uint64, additional ...[]byte) ([]byte, error)

SessionHash returns the session hash for Extended Master Secret support https://tools.ietf.org/html/draft-ietf-tls-session-hash-06#section-4

type Conn

type Conn interface {
	HandleQueuedPackets(context.Context) error
	SessionKey() []byte
}

type DecodedHandshakeCacheItem

type DecodedHandshakeCacheItem struct {
	Raw    *HandshakeCacheItem
	Parsed *handshake.Handshake
}

DecodedHandshakeCacheItem retains the original cache bytes for the transcript and the single parsed representation used by handshake logic.

func (DecodedHandshakeCacheItem) Validate

func (i DecodedHandshakeCacheItem) Validate() error

Validate checks that the raw and parsed views identify the same complete handshake message.

type HandshakeCacheDecoder

type HandshakeCacheDecoder func([]byte) (*handshake.Handshake, error)

HandshakeCacheDecoder decodes a complete cached handshake message.

type HandshakeCacheItem

type HandshakeCacheItem struct {
	Typ             handshake.Type
	IsClient        bool
	Epoch           uint64
	MessageSequence uint16
	Data            []byte
	// contains filtered or unexported fields
}

type HandshakeCacheItemPullResult

type HandshakeCacheItemPullResult struct {
	NextSequence int
	Items        []*HandshakeCacheItem
	Ready        bool
	// Err always wraps an *alert.Alert.
	Err error
}

HandshakeCacheItemPullResult is an ordered cache selection before message payloads are decoded. Items is aligned with the requested pull rules.

type HandshakeCachePullResult

type HandshakeCachePullResult struct {
	NextSequence int
	Messages     map[handshake.Type]handshake.Message
	Items        []DecodedHandshakeCacheItem
	Ready        bool
	// Err always wraps an *alert.Alert.
	Err error
}

HandshakeCachePullResult distinguishes an incomplete flight from a complete malformed message. Err is non-nil only when a selected complete message could not be decoded or failed cache/header validation.

type HandshakeCachePullRule

type HandshakeCachePullRule struct {
	Typ      handshake.Type
	Epoch    uint64
	IsClient bool
	Optional bool
}

type HandshakeFragment

type HandshakeFragment struct {
	Header  handshake.Header
	Padding uint
}

type Outbound

type Outbound struct {
	Epoch      uint64
	Content    protocol.Content
	Protection Protection
	TrackACK   bool
	// HandshakeFragmentOffsets limits a retransmission to offset:length pairs.
	HandshakeFragmentOffsets map[uint32]uint32
	HandshakeFragments       []HandshakeFragment

	// CertificateVerifySigner is local-only metadata used to populate an
	// outbound CertificateVerify after the handshake messages have been committed.
	CertificateVerifySigner crypto.Signer
}

Outbound describes semantic record intent.

type Protection

type Protection uint8

Protection describes the protection required for an outbound record.

const (
	ProtectionPlaintext Protection = iota
	ProtectionCiphertext
)

Directories

Path Synopsis
Package flight12 contains DTLS 1.2 flight handlers.
Package flight12 contains DTLS 1.2 flight handlers.
Package flight13 contains DTLS 1.3 flight handlers.
Package flight13 contains DTLS 1.3 flight handlers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL