pub struct CryptoConfig {
pub passphrase: Vec<u8>,
pub salt: [u8; 16],
pub sek: Vec<u8>,
}crypto only.Expand description
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).
This crate’s sans-IO core never reads OS randomness — the same design
choice as derive_cookie’s caller-supplied time_bucket/secret
inputs, or crate::io’s OS-random SYN Cookie key.
Self::salt and, on the initiator, Self::sek must be freshly
generated by the caller/driver (e.g. a tokio adapter with access to a
real CSPRNG) for every new connection (§6.2.1: Salt = PRNG(128),
SEK = PRNG(KLen)) and never reused across connections.
§Secret hygiene (issue #1142)
The passphrase and SEK never appear in core::fmt::Debug output (it
prints only their lengths), PartialEq compares them in constant time,
and dropping a CryptoConfig (or calling Zeroize::zeroize) wipes them.
Fields§
§passphrase: Vec<u8>The pre-shared secret (§6.1.4). Must be identical on both peers, or
the responder’s KEK derivation recovers the wrong SEK and the RFC
3394 wrap’s integrity check fails
(RejectionReason::BadSecret on the Listener side).
salt: [u8; 16]A fresh, cryptographically random 128-bit Salt for this
connection (§6.2.1: Salt = PRNG(128)). See the struct doc for why
this crate does not generate it internally.
sek: Vec<u8>This side’s plaintext Stream Encrypting Key. Only meaningful on the
connection initiator (the Caller — §6.1.5: “sent by the connection
initiator … to the responder”). Must be a fresh, cryptographically
random 16/24/32-byte value (§6.2.1: SEK = PRNG(KLen)) matching
HandshakeConfig::encryption_field’s advertised cipher. Ignored on
the Listener/responder side (which instead recovers the SEK by
unwrapping the initiator’s Key Material) — may be left empty there.