webrtc_srtp_profile (webrtc v0.1.0)

View Source

SRTP protection profiles for DTLS-SRTP (RFC 5764 §4.1.2, RFC 7714 §14.2) and the layout of the exported keying material (RFC 5764 §4.2).

Only profiles allowed in WebRTC are supported: the NULL cipher profiles (0x0005, 0x0006) are rejected (RFC 8827 §6.5).

The DTLS layer uses this module to:

  1. pick a profile from the peer's use_srtp list with from_id/1 and supported/0;
  2. export key_material_length(Profile) bytes with the label returned by exporter_label/0 and an empty context;
  3. split the result with split_keying_material/2.

Summary

Functions

TLS exporter label for DTLS-SRTP (RFC 5764 §4.2). The context value is empty.

Map a DTLS use_srtp protection profile id (2 octets) to a profile. Unknown and NULL cipher profiles return {error, unsupported_profile}.

Number of octets to export: 2 * (master_key_len + master_salt_len).

Transform parameters of a profile. Lengths are in octets.

Split exported keying material laid out as client_key | server_key | client_salt | server_salt (RFC 5764 §4.2). Raises badarg when the size does not match the profile.

Supported profiles in preference order. AEAD profiles come first (RFC 8827 §6.5: implementations SHOULD favor AEAD).

Types

params/0

-type params() ::
          #{id := 0..65535,
            transform := cm | gcm,
            master_key_len := pos_integer(),
            master_salt_len := pos_integer(),
            auth_key_len := non_neg_integer(),
            rtp_tag_len := pos_integer(),
            rtcp_tag_len := pos_integer()}.

profile/0

-type profile() ::
          srtp_aes128_cm_hmac_sha1_80 | srtp_aes128_cm_hmac_sha1_32 | srtp_aead_aes_128_gcm |
          srtp_aead_aes_256_gcm.

Functions

exporter_label()

-spec exporter_label() -> binary().

TLS exporter label for DTLS-SRTP (RFC 5764 §4.2). The context value is empty.

from_id(_)

-spec from_id(0..65535 | <<_:16>>) -> {ok, profile()} | {error, unsupported_profile}.

Map a DTLS use_srtp protection profile id (2 octets) to a profile. Unknown and NULL cipher profiles return {error, unsupported_profile}.

id(Profile)

-spec id(profile()) -> 0..65535.

key_material_length(Profile)

-spec key_material_length(profile()) -> pos_integer().

Number of octets to export: 2 * (master_key_len + master_salt_len).

params(Other)

-spec params(profile()) -> params().

Transform parameters of a profile. Lengths are in octets.

split_keying_material(Profile, Bin)

-spec split_keying_material(profile(), binary()) ->
                               {ClientKey :: binary(),
                                ClientSalt :: binary(),
                                ServerKey :: binary(),
                                ServerSalt :: binary()}.

Split exported keying material laid out as client_key | server_key | client_salt | server_salt (RFC 5764 §4.2). Raises badarg when the size does not match the profile.

supported()

-spec supported() -> [profile()].

Supported profiles in preference order. AEAD profiles come first (RFC 8827 §6.5: implementations SHOULD favor AEAD).