webrtc_srtp_profile (webrtc v0.1.0)
View SourceSRTP 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:
- pick a profile from the peer's
use_srtplist withfrom_id/1andsupported/0; - export
key_material_length(Profile)bytes with the label returned byexporter_label/0and an empty context; - 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
-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()}.
-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
-spec exporter_label() -> binary().
TLS exporter label for DTLS-SRTP (RFC 5764 §4.2). The context value is empty.
-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}.
-spec id(profile()) -> 0..65535.
-spec key_material_length(profile()) -> pos_integer().
Number of octets to export: 2 * (master_key_len + master_salt_len).
Transform parameters of a profile. Lengths are in octets.
-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.
-spec supported() -> [profile()].
Supported profiles in preference order. AEAD profiles come first (RFC 8827 §6.5: implementations SHOULD favor AEAD).