Skip to main content

Module handshake_sm

Module handshake_sm 

Source
Expand description

Shared types for the sans-IO HSv5 handshake state machine — draft-sharabayko-srt-01 §4.3 (Handshake Messages) / §4.3.1 (Caller-Listener Handshake).

This module holds the pieces crate::caller::CallerHandshake and crate::listener::ListenerHandshake share: the negotiation input (HandshakeConfig), the negotiation output (NegotiatedParams), the event type both engines emit (HandshakeOutput), and the Handshake Rejection Reason codes (§4.3, Table 7) as a typed RejectionReason.

This module also holds the crypto-feature-gated §6.1.5 Key Material Exchange helpers (CryptoConfig, build_key_material_extension, recover_sek, echo_key_material_as_response, verify_km_echo) shared by crate::caller::CallerHandshake / crate::listener::ListenerHandshake — see CryptoConfig’s doc and specs/rules/srt-crypto.md. Congestion control beyond LiveCC packet pacing is an explicit follow-up — see the crate root docs.

Structs§

CryptoConfigcrypto
Opt-in §6 payload-encryption config for one side of a Caller-Listener handshake (draft-sharabayko-srt-01 §6.1.5, Key Material Exchange — curated at specs/rules/srt-crypto.md). None on HandshakeConfig::crypto (the default) disables the encryption path entirely: no Key Material extension is sent, and a peer that sends one unexpectedly is rejected (RejectionReason::Unsecure).
HandshakeConfig
Local configuration for one side of a Caller-Listener handshake — the values this engine advertises (draft-sharabayko-srt-01 §3.2.1, §3.2.1.1, §3.2.1.3, §3.2.1.4).
NegotiatedParams
The outcome of a Caller-Listener handshake, once both TSBPD delays and flags have been reconciled per draft-sharabayko-srt-01 §4.3.1.2 (“The value for latency is always agreed to be the greater of those reported by each party”).

Enums§

HandshakeOutput
An event produced by crate::caller::CallerHandshake::feed / crate::caller::CallerHandshake::start / crate::listener::ListenerHandshake::feed / either engine’s tick.
RejectionReason
Handshake Rejection Reason (draft-sharabayko-srt-01 §4.3, Table 7). Sent in place of a normal Handshake Type value (1000 + code, decoded via HandshakeType::Reserved) when a connection attempt is refused.

Constants§

HANDSHAKE_VERSION_4
A base protocol version number of 4 — the value the Caller’s INDUCTION handshake MUST always carry (draft-sharabayko-srt-01 §4.3.1.1), kept for UDT compatibility.
HANDSHAKE_VERSION_5
A base protocol version number of 5 — HSv5, used by every handshake message from the Listener’s INDUCTION response onward (§4.3.1.1/§4.3.1.2).
INDUCTION_LEGACY_SOCKET_TYPE
The Extension Field value the Caller sets on its very first INDUCTION handshake (§4.3.1.1: “Extension Field: 2”). This is not the §3.2.1 Table 3 Extension Flags bitmask (whose KMREQ bit happens to share the same numeric value) — it is a legacy UDT socket-type field (UDT_DGRAM) carried over because the INDUCTION handshake is version-4-shaped for UDT compatibility.
REJECTION_CODE_BASE
The base wire value of the Handshake Rejection Reason codes (draft-sharabayko-srt-01 §4.3, Table 7): a rejected connection’s Handshake Type field carries 1000 + <code>.
SRT_MAGIC_CODE
The Extension Field value the Listener echoes on its INDUCTION response so the Caller can recognise it as an SRT (not legacy UDT) party (draft-sharabayko-srt-01 §4.3.1.1: “SRT magic code 0x4A17”).

Functions§

derive_cookie
A simple, deterministic, non-cryptographic mix for deriving a SYN Cookie from caller-supplied inputs (draft-sharabayko-srt-01 §4.3.1.1: “a cookie that is crafted based on host, port and current time with 1 minute accuracy”). The draft specifies the semantic inputs, not a wire algorithm; this crate’s core never reads a clock, so time_bucket (e.g. UNIX time / 60) must come from the caller/driver.