webrtc_srtp_kdf (webrtc v0.1.0)

View Source

SRTP key derivation (RFC 3711 §4.3) with the AES-CM PRF (RFC 3711 §4.3.3, RFC 6188 §7 for AES-256 master keys).

The key derivation rate is always 0 (RFC 5764 §4.1.2, RFC 7714 §11), so index DIV kdr is 0 and each session key is derived exactly once, when the context is created.

Master salts shorter than 112 bits (the 96-bit AES-GCM salt of RFC 7714) are extended with trailing zero octets before the XOR with the key id. This is the layout used by libsrtp and therefore by browsers; see docs/compliance/srtp.md (SRTP-KDF-4).

Summary

Functions

Derive Len octets for Label with kdr = 0 (RFC 3711 §4.3.1): x = (Label || 0^48) XOR master_salt, then PRF_n(k_master, x).

Len octets of AES counter mode keystream starting at block IV (RFC 3711 §4.1.1).

AES-CM PRF (RFC 3711 §4.3.3): AES counter mode keyed with the master key, IV = x * 2^16, output truncated to Len octets.

Derive all session keys of a profile from a master key and salt. For AEAD profiles the authentication keys are empty binaries.

Types

session_keys/0

-type session_keys() ::
          #{rtp_key := binary(),
            rtp_salt := binary(),
            rtp_auth_key := binary(),
            rtcp_key := binary(),
            rtcp_salt := binary(),
            rtcp_auth_key := binary(),
            rtp_hdr_key := binary(),
            rtp_hdr_salt := binary()}.

Functions

derive(Label, MasterKey, MasterSalt, Len)

-spec derive(0..255, binary(), binary(), non_neg_integer()) -> binary().

Derive Len octets for Label with kdr = 0 (RFC 3711 §4.3.1): x = (Label || 0^48) XOR master_salt, then PRF_n(k_master, x).

keystream(Key, IV, Len)

-spec keystream(binary(), <<_:128>>, non_neg_integer()) -> binary().

Len octets of AES counter mode keystream starting at block IV (RFC 3711 §4.1.1).

prf(MasterKey, _, Len)

-spec prf(binary(), <<_:112>>, non_neg_integer()) -> binary().

AES-CM PRF (RFC 3711 §4.3.3): AES counter mode keyed with the master key, IV = x * 2^16, output truncated to Len octets.

session_keys(Profile, MasterKey, MasterSalt)

-spec session_keys(webrtc_srtp_profile:profile(), binary(), binary()) -> session_keys().

Derive all session keys of a profile from a master key and salt. For AEAD profiles the authentication keys are empty binaries.