XGW.Trunk.Crypto (xgw v0.1.0)

Copy Markdown View Source

Static-key SRTP for inter-edge trunk pipes.

What problem this solves

Trunk edges exchange write-key pairs over the control plane, then protect RTP/RTCP on the UDP pipe without DTLS. Each edge encrypts with its local write key and decrypts with the far edge's write key.

RFCs

  • RFC 3711 -- SRTP encrypt / decrypt

Summary

Functions

Lab alias: shared master material for both directions (local == remote).

Encrypts RTP; returns ciphertext and updated session.

Decrypts SRTP to %Rtp{}.

Functions

new(master_key, master_salt)

@spec new(binary(), binary()) :: XGW.SRTPSession.t()

Lab alias: shared master material for both directions (local == remote).

new(local_write_key, local_write_salt, remote_write_key, remote_write_salt)

@spec new(binary(), binary(), binary(), binary()) :: XGW.SRTPSession.t()

Builds an XGW.SRTPSession from directional write keys.

Encrypt uses local_write_* (SRTP server write). Decrypt uses remote_write_* (SRTP client write). The far edge passes the swapped pair.

protect_rtcp(session, rtcp)

@spec protect_rtcp(XGW.SRTPSession.t(), XMediaLib.Rtcp.t()) ::
  {:ok, binary(), XGW.SRTPSession.t()} | {:error, XGW.SRTPSession.t()}

Encrypts RTCP.

protect_rtp(session, rtp)

@spec protect_rtp(XGW.SRTPSession.t(), XMediaLib.Rtp.t()) ::
  {:ok, binary(), XGW.SRTPSession.t()} | {:error, XGW.SRTPSession.t()}

Encrypts RTP; returns ciphertext and updated session.

unprotect_rtcp(session, ciphertext)

@spec unprotect_rtcp(XGW.SRTPSession.t(), binary()) ::
  {:ok, term(), XGW.SRTPSession.t()} | {:error, XGW.SRTPSession.t()}

Decrypts SRTCP.

unprotect_rtp(session, ciphertext)

@spec unprotect_rtp(XGW.SRTPSession.t(), binary()) ::
  {:ok, XMediaLib.Rtp.t(), XGW.SRTPSession.t()} | {:error, XGW.SRTPSession.t()}

Decrypts SRTP to %Rtp{}.