ExSRTP.Policy (ExSRTP v0.4.1)

View Source

Module describing a policy of SRTP.

An SRTP policy defines the cryptographic parameters used to protect RTP and RTCP packets, including the master key, master salt, encryption and authentication profiles, and replay protection settings.

Fields

  • master_key (binary): The master key used for encryption and authentication. Must be 16 bytes long.

  • master_salt (binary | nil): The master salt used in key derivation. Defaults to 0.

  • profile (profile | nil): The SRTP profile for RTP and RTCP packets. Defaults to :aes_cm_128_hmac_sha1_80 if not specified.

  • rtp_replay_window_size (non_neg_integer | nil): The size of the replay protection window for RTP packets. Defaults to 64 if not specified.

  • rtcp_replay_window_size (non_neg_integer | nil): The size of the replay protection window for RTCP packets. Defaults to 128 if not specified.

Summary

Types

master_key()

@type master_key() :: binary()

master_salt()

@type master_salt() :: binary()

profile()

@type profile() ::
  :aes_cm_128_hmac_sha1_80 | :aes_cm_128_hmac_sha1_32 | :aes_gcm_128_16_auth

t()

@type t() :: %ExSRTP.Policy{
  master_key: master_key(),
  master_salt: master_salt() | nil,
  profile: profile() | nil,
  rtcp_replay_window_size: non_neg_integer() | nil,
  rtp_replay_window_size: non_neg_integer() | nil
}

Functions

crypto_profile_from_dtls_srtp_protection_profile(b)

@spec crypto_profile_from_dtls_srtp_protection_profile(
  value :: pos_integer() | {pos_integer(), pos_integer()}
) :: {:ok, profile()} | {:error, :unsupported_crypto_profile}

Relevant specification: https://www.iana.org/assignments/srtp-protection/srtp-protection.xhtml

iex> ExSRTP.Policy.crypto_profile_from_dtls_srtp_protection_profile(0x01)
{:ok, :aes_cm_128_hmac_sha1_80}

iex> ExSRTP.Policy.crypto_profile_from_dtls_srtp_protection_profile(0x02)
{:ok, :aes_cm_128_hmac_sha1_32}

iex> ExSRTP.Policy.crypto_profile_from_dtls_srtp_protection_profile(0x07)
{:ok, :aes_gcm_128_16_auth}

iex> ExSRTP.Policy.crypto_profile_from_dtls_srtp_protection_profile(0x03)
{:error, :unsupported_crypto_profile}

iex> ExSRTP.Policy.crypto_profile_from_dtls_srtp_protection_profile({0x00, 0x01})
{:ok, :aes_cm_128_hmac_sha1_80}

iex> ExSRTP.Policy.crypto_profile_from_dtls_srtp_protection_profile({0x00, 0x03})
{:error, :unsupported_crypto_profile}