SRTP and SRTCP (RFC 3711, RFC 7714, RFC 9335)

View Source

This page tracks the SRTP and SRTCP requirements implemented by src/srtp: packet protection (RFC 3711), AES-GCM (RFC 7714), encrypted CSRCs and header extensions (RFC 9335), keying from DTLS-SRTP (RFC 5764 §4.1.2 and §4.2) and the WebRTC profile rules (RFC 8827 §6.5). Read it before you rely on a profile or a replay and rekey behavior. Tests named *_tests: are in test/; prop_webrtc_srtp holds the PropEr properties.

RFC 3711: SRTP and SRTCP processing

IDSectionRequirementModuleTestStatus
SRTP-13.1Without cryptex only the RTP payload (with padding) is encrypted; header, CSRC list and header extension stay in the clear and are authenticatedwebrtc_srtp, webrtc_srtp_cipherwebrtcsrtp_tests:roundtrip_rtp_test, prop_webrtc_srtp:prop_rtp_roundtripUnit tested
SRTP-23.3.1Sender ROC starts at 0 and increments when SEQ wrapswebrtc_srtprollovertest, multiple_rollovers_testUnit tested
SRTP-33.3.1Receiver starts with ROC 0 and s_l set to the SEQ of the first packetwebrtc_srtprollovertestUnit tested
SRTP-43.3.1, App. AIndex estimate: v in {ROC-1, ROC, ROC+1}, closest to 2^16 * ROC + s_lwebrtc_srtpestimateindex_test, reorder_near_rollover_test, sender_reorder_near_rollover_testUnit tested
SRTP-53.3.1ROC and s_l updated only after the packet is authenticated, with the v / SEQ rulewebrtc_srtpforgeddoes_not_move_window_test, reorder_near_rollover_testUnit tested
SRTP-63.3.1A receiver joining a running stream is given the ROC out of bandwebrtc_srtp (set_roc/4)set_roc_testUnit tested
SRTP-73.3.1ROC is not reset on rekeywebrtc_srtp (roc/3, set_roc/4)set_roc_testNon-compliant / known limitation: a context does not rekey itself; the caller carries the ROC into the new context with roc/3 and set_roc/4. WebRTC does not rekey a DTLS-SRTP session.
SRTP-83.3.2Replay list as a sliding window of at least 64 entries (default 1024 for SRTP)webrtc_srtp_replaywebrtc_srtp_replay_tests, default_window_is_1024_testUnit tested
SRTP-93.3.2Accept only indices ahead of the window or inside it and not yet received; update after authenticationwebrtc_srtp_replay, webrtc_srtpwebrtcsrtp_replay_tests:model_test, rtp_replay_testUnit tested
SRTP-103.3Replayed packets MUST be discarded and SHOULD be loggedwebrtc_srtprtpreplay_testUnit tested (returns {error, replay} or {error, too_old}; logging is left to the caller)
SRTP-113.3Authentication checked before decryption; failed packets discardedwebrtc_srtp_ciphertamperrtp_test, wrongkey_test, prop_unprotect_mutatedUnit tested
SRTP-124.2Tag comparison does not leak timingwebrtc_srtp_cipher(crypto:hash_equals for HMAC, OpenSSL for GCM)Implemented, untested
SRTP-134.2SRTP MAC input is Authenticated Portion concatenated with ROCwebrtc_srtp_cipherlibsrtpaes_cm_rtp_test, rollover_testUnit tested
SRTP-144.2.1HMAC-SHA1 truncated to the 80 or 32 left-most bitswebrtc_srtp_cipherlibsrtp_aes_cm_rtp_test, sha1_32_tag_lengths_testUnit tested
SRTP-154.1.1AES-CM IV = (k_s 2^16) XOR (SSRC 2^64) XOR (i * 2^16)webrtc_srtp_cipherwebrtc_srtp_kdf_tests:b2_through_protect_testUnit tested
SRTP-164.1.1AES-CM keystream from RFC 3711 B.2webrtc_srtp_kdfwebrtc_srtp_kdf_tests:b2_keystream_testUnit tested
SRTP-174.1.1At most 2^16 keystream blocks per IVwebrtc_srtp_ciphercm_keystream_limit_testUnit tested
SRTP-184.1.1(ROC, SEQ, SSRC) never reused with one key on the send sidewebrtc_srtpsenderrefuses_index_reuse_testUnit tested
SRTP-193.4SRTCP appends E flag, 31-bit index and tag; index starts at 0 and increments per packetwebrtc_srtpsrtcp_index_sequence_test, libsrtp_aes_cm_rtcp_testUnit tested
SRTP-203.4, 4.1.1SRTCP encrypts from octet 9; IV uses the SSRC of the first header and the SRTCP indexwebrtc_srtp_cipherlibsrtpaes_cm_rtcp_test, roundtrip_rtcp_testUnit tested
SRTP-213.4SRTCP decrypts only when E = 1; E = 0 leaves the payload untouched but authenticatedwebrtc_srtp_cipherroundtriprtcp_test (E=false), rfc7714_17_3_testUnit tested
SRTP-223.4SRTCP message authentication is REQUIREDwebrtc_srtp_ciphertamperrtcp_testUnit tested
SRTP-233.4SRTCP replay protection with its own replay list (default 128)webrtc_srtprtcpreplay_testUnit tested
SRTP-243.4SRTCP index not reset after rekeywebrtc_srtp (set_rtcp_index/3)rfc7714_17_1_testNon-compliant / known limitation: as SRTP-7, the caller carries the index with set_rtcp_index/3.
SRTP-253.4avg_rtcp_size includes the SRTCP overheadNot implemented (belongs to the RTCP scheduler)
SRTP-263.3.1, 9.2No more than 2^48 SRTP and 2^31 SRTCP packets per key; then {error, key_exhausted}webrtc_srtpsrtpkey_exhausted_test, srtcpkey_exhausted_testUnit tested
SRTP-273.1, 8.1MKINot implemented: RFC 8827 §6.5 forbids MKI in WebRTC
SRTP-283.3, 3.4Malformed or truncated packets are refused without crashingwebrtc_srtptruncatedtest, malformedtest, prop_unprotect_random_binaryUnit tested
SRTP-293.3.2Receive state bounded: forget/2 drops an SSRC and keeps its highest SRTP and SRTCP indices for the last 1024 SSRCs forgotten, so earlier packets stay refused and the stream continues after them; at most 512 SSRCs with receive state ({error, too_many_streams})webrtc_srtp, webrtc_srtp_replayforget_test, forget_bounded_test, rx_streams_bounded_testUnit tested

RFC 3711: key derivation

IDSectionRequirementModuleTestStatus
SRTP-KDF-14.3.1Session keys from master key and salt with labels 0x00 to 0x02, kdr = 0webrtc_srtp_kdfb3_cipher_key_test, b3_cipher_salt_test, b3_auth_key_testUnit tested
SRTP-KDF-24.3.3AES-CM PRF: AES-CM keyed with the master key, IV = x * 2^16webrtc_srtp_kdfb3_prf_input_testUnit tested
SRTP-KDF-34.3.2SRTCP keys with labels 0x03 to 0x05webrtc_srtp_kdfsession_keys_cm_test, rtp_rtcp_keys_separate_testUnit tested
SRTP-KDF-44.3.1; RFC 7714 §11KDF with a 96-bit master salt (AES-GCM) and a 256-bit master key (AES_256_CM_PRF, RFC 6188)webrtc_srtp_kdfsession_keys_gcm_test, libsrtp_aes_gcm_rtp_testUnit tested. Note: the 96-bit salt is extended to 112 bits with trailing zero octets, as libsrtp does. A literal reading of the RFC 3711 right alignment would add leading zeros instead. Browsers use libsrtp, and the libsrtp reference packet matches.
SRTP-KDF-54.3.1Keys derived once per context, never per packetwebrtc_srtp(session keys and AEAD states built in new/4)Implemented, untested

RFC 7714: AES-GCM

IDSectionRequirementModuleTestStatus
GCM-18.1SRTP IV = (00 00, SSRC, ROC, SEQ) XOR saltwebrtc_srtp_cipherrfc7714_16_1_encrypt_test, rfc7714_16_2_encrypt_testUnit tested
GCM-28.2AAD is the RTP header with CSRCs and extension; plaintext is payload, padding and pad countwebrtc_srtp_cipherrfc771416_1_decrypt_test, roundtrip_rtp_testUnit tested
GCM-38.2Every SRTP packet is encrypted and authenticated, empty payloads includedwebrtc_srtp_cipherroundtriprtp_test (empty payload)Unit tested
GCM-48.3RFC 6904 header extension encryption with AES-GCM: AES-CM keystream, the encrypted extension stays in the associated data, encrypted before the AEAD runswebrtc_srtp, webrtc_srtp_cipherwebrtcsrtp_hdrext_tests:rfc6904_a2_test, tamperedtestUnit tested, E2E tested
GCM-58.4(ROC, SEQ, SSRC) checked by the SRTP implementation so an IV is never reusedwebrtc_srtpsenderrefuses_index_reuse_testUnit tested
GCM-68.4SSRC pools when several senders share a master keyNot implemented: DTLS-SRTP gives each direction its own master key; SSRC allocation belongs to the RTP layer
GCM-79.1SRTCP IV = (00 00, SSRC, 00 00, 0, index) XOR saltwebrtc_srtp_cipherrfc7714_17_1_test, rfc7714_17_2_testUnit tested
GCM-89.2E = 1: AAD is the first 8 octets and the ESRTCP word; tag before the ESRTCP wordwebrtc_srtp_cipherrfc7714_17_1_test, rfc7714_17_2_test, rfc7714_17_eflag_testUnit tested
GCM-99.3E = 0: whole packet and ESRTCP word are AAD, cipher is the tag alonewebrtc_srtp_cipherrfc7714_17_3_test, rfc7714_17_4_testUnit tested
GCM-109.4, 10At most 2^48 SRTP and 2^31 SRTCP invocations per keywebrtc_srtpsrtpkey_exhausted_test, srtcpkey_exhausted_testUnit tested
GCM-1110AEAD tag is 16 octets, IV 12 octetswebrtc_srtp_profile, webrtc_srtp_cipherrfc771416*Unit tested
GCM-1212Both AEAD_AES_128_GCM and AEAD_AES_256_GCM supportedwebrtc_srtp_profilerfc771416, rfc771417Unit tested

RFC 6904: encrypted header extension elements

IDSectionRequirementModuleTestStatus
HDREXT-13.3, 4Header key (label 6) and salt (label 7) derived with the session keys; the salt has the AES-CM length for every profile, as RFC 7714 §8.3 and libsrtp usewebrtc_srtp_kdfwebrtc_srtp_kdf_tests:rfc6904_header_keys_test (A.1)Unit tested
HDREXT-24Keystream: the AES-CM transform and IV of the payload with the header key and saltwebrtc_srtp_cipherwebrtc_srtp_hdrext_tests:keystream_test (A.2)Unit tested
HDREXT-34Only the data of the encrypted elements is encrypted: element headers, padding and clear elements unchanged; one-byte and two-byte forms; a block that does not parse is left alonewebrtc_srtprfc6904a2_test, mixed_test, two_byte_test, malformed_block_testUnit tested
HDREXT-44Encrypted before the tag; the receiver authenticates, then decryptswebrtc_srtptamperedtest, prop_webrtc_srtp:prop_rtp_roundtripUnit tested
HDREXT-54.1a=extmap:N urn:ietf:params:rtp-hdrext:encrypt <uri>; an offer may carry both forms, the answer keeps the encrypted one when we accept it, never both; an answer with both is refusedwebrtc_jsep_caps, webrtc_jsepwebrtc_jsep_tests:encrypted_audio_level_test, clear_fallback_test, plain_offer_test, both_forms_refused_testUnit tested, E2E tested
HDREXT-64.1Offers with the encrypted form only with encrypt_header_extensions => offer; the default accepts it when offered, false neitherwebrtc_jsep, webrtc_jsep_buildclear_fallback_test, webrtc_pc_interop_SUITE:erlang_offers_encrypted_audio_levelInteroperability tested (fallback): no peer we test negotiates the encrypted form; Firefox falls back to the clear level, Chromium 149 to none, aiortc 1.16 cannot parse the offer
HDREXT-7RFC 9335Independent from cryptex: a cryptex packet is not masked as well, a received one is not unmaskedwebrtc_srtpwebrtc_srtp_hdrext_tests:with_cryptex_test, webrtc_pc_SUITE:header_extension_encryptionE2E tested

RFC 9335: cryptex

IDSectionRequirementModuleTestStatus
CRYPTEX-15.1Profile 0xC0DE for one-byte and 0xC2DE for two-byte extensions; CSRCs without extensions get an empty 0xC0DE block and the X bitwebrtc_srtpwebrtcsrtp_cryptex_tests:vectors_test (A.1.5, A.1.6)Unit tested
CRYPTEX-25.2, 6.2AES-CM: CSRCs, extension data and payload encrypted as one keystream, authentication unchangedwebrtc_srtp_cipherwebrtcsrtp_cryptex_tests:vectors_test (A.1)Unit tested
CRYPTEX-35.2, 6.2AES-GCM: fixed header and extension header are the associated data, CSRCs, extension data and payload the plaintextwebrtc_srtp_cipherwebrtcsrtp_cryptex_tests:vectors_test (A.2), tampered_testUnit tested
CRYPTEX-46.3The receiver recognises cryptex by the extension profile and accepts both formswebrtc_srtpwebrtcsrtp_cryptex_tests:vectors_testUnit tested
CRYPTEX-56.1a=cryptex offered on RTP sections; answered for a transport whose RTP sections all have it (media or session level); sent once every section negotiated itwebrtc_jsep_build, webrtc_jsep_params, webrtc_mediawebrtc_pc_SUITE:cryptex, webrtc_pc_interop_SUITE:cryptex_echoInteroperability tested (Pion)
CRYPTEX-66.3, 5.1Once cryptex is negotiated, packets with header extensions or CSRCs in any other form are refused (cryptex_required); a packet whose extension profile cryptex cannot carry is not sent (cryptex_unsupported)webrtc_srtp, webrtc_mediawebrtc_srtp_tests:cryptex_required_test, webrtc_media_tests:cryptex_required_test, prop_webrtc_srtp:prop_rtp_roundtripUnit tested; interop with Chromium, Firefox, Pion and aiortc unchanged

RFC 5764: DTLS-SRTP keying

IDSectionRequirementModuleTestStatus
KEY-14.1.2; RFC 7714 §14.2Profile ids 0x0001, 0x0002, 0x0007, 0x0008webrtc_srtp_profileprofile_ids_testUnit tested
KEY-24.1.2SRTP_AES128_CM_HMAC_SHA1_32: 32-bit SRTP tag, 80-bit SRTCP tagwebrtc_srtp_profilesha1_32_tag_lengths_testUnit tested
KEY-34.1.2Key derivation rate is 0 and the RFC 3711 AES-CM PRF is usedwebrtc_srtp_kdfb3_* testsUnit tested
KEY-44.1.2maximum_lifetime of 2^31 packets per key set for the AES-CM profileswebrtc_srtpNon-compliant / known limitation: the AES-CM profiles use the RFC 3711 limits (2^48 indices per SRTP stream, 2^31 per SRTCP stream) like libsrtp. A WebRTC session cannot rekey, so a 2^31 total would end long video calls that browsers keep running.
KEY-54.2Export 2 * (key_len + salt_len) octets with label "EXTRACTOR-dtls_srtp" and no contextwebrtc_srtp_profilekey_material_length_testUnit tested (the export itself is done by the DTLS layer)
KEY-64.2Layout client_key, server_key, client_salt, server_saltwebrtc_srtp_profilesplit_layout_testUnit tested
KEY-74.2Each side sends with its own write keys and only uses the peer's keys to receivewebrtc_srtp (dtls_contexts/4)dtls_contexts_testUnit tested

RFC 8827: WebRTC security architecture

IDSectionRequirementModuleTestStatus
WEBRTC-SRTP-16.5SRTP_AES128_CM_HMAC_SHA1_80 MUST be supportedwebrtc_srtp_profileroundtriprtp_test, libsrtp_aes_cm_rtp_testUnit tested
WEBRTC-SRTP-26.5NULL encryption profiles MUST NOT be negotiatedwebrtc_srtp_profilenull_profiles_rejected_test, bad_options_testUnit tested
WEBRTC-SRTP-36.5MKI MUST NOT be usedwebrtc_srtpImplemented, untested (no MKI support: a packet carrying an MKI fails authentication)
WEBRTC-SRTP-46.5AEAD profiles SHOULD be favoredwebrtc_srtp_profileaead_preferred_testUnit tested
WEBRTC-SRTP-56.5All media and RTCP protected: SRTCP authentication always onwebrtc_srtptamperrtcp_testUnit tested