Skip to main content

Handshake

Trait Handshake 

Source
pub trait Handshake {
    type Error: Error;

    // Required methods
    fn run(&mut self, role: Role) -> Result<(), Self::Error>;
    fn peer_certificate(&self) -> Option<Vec<u8>>;
    fn profile(&self) -> Option<Profile>;
    fn export(&self, len: usize) -> Result<Vec<u8>, Self::Error>;
}
Expand description

A DTLS handshake on the media path, as much of one as RFC 5764 needs.

sipx does not implement DTLS. This is the seam: everything above it — the fingerprint check, the profile, the key split, the demultiplexing — is sipx’s, and an implementor of this trait supplies the record layer and the handshake. Keeping it a trait rather than a hard dependency is what lets the fingerprint verification be tested exhaustively without a certificate authority in the loop, and what stops the choice of DTLS library from reaching into the media session.

Required Associated Types§

Source

type Error: Error

Why the handshake failed.

Required Methods§

Source

fn run(&mut self, role: Role) -> Result<(), Self::Error>

Run the handshake to completion.

role comes from the negotiated a=setup and must not be guessed: a UA that starts a handshake it agreed to wait for meets one coming the other way.

Source

fn peer_certificate(&self) -> Option<Vec<u8>>

The peer’s certificate, DER-encoded, once the handshake has produced one.

This is what the SDP fingerprint is checked against, and why the trait exposes it rather than leaving verification to the implementation: RFC 8122 §6.2’s check is against a value that arrived in the signalling, which a DTLS library has no way to see.

Source

fn profile(&self) -> Option<Profile>

The profile both ends agreed on, from the use_srtp extension (RFC 5764 §4.1).

Source

fn export(&self, len: usize) -> Result<Vec<u8>, Self::Error>

Export len octets under EXPORTER_LABEL (RFC 5764 §4.2).

Implementors§