Skip to main content

CryptoConfig

Struct CryptoConfig 

Source
pub struct CryptoConfig {
    pub passphrase: Vec<u8>,
    pub salt: [u8; 16],
    pub sek: Vec<u8>,
}
Available on crate feature 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 random_u64 helper for the SYN Cookie secret. 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.

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.

Trait Implementations§

Source§

impl Clone for CryptoConfig

Source§

fn clone(&self) -> CryptoConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CryptoConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for CryptoConfig

Source§

fn eq(&self, other: &CryptoConfig) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CryptoConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.