rtci-srtp
Sans-I/O SRTP and SRTCP (RFC 3711, RFC 7714 AES-GCM, RFC 9335 Cryptex) for WebRTC. 10 public modules, 37 items at 0.5.0.
cargo add [email protected] · crates.io · docs.rs · README on GitHub· MSRV 1.89
README
SRTP and SRTCP for WebRTC: encryption and authentication of RTP and RTCP with the protection profiles DTLS-SRTP negotiates, replay protection, rollover counter tracking, key lifetimes and rekeying, Cryptex and encrypted header extensions.
Specifications
- RFC 3711, SRTP and SRTCP
- RFC 7714, AES-GCM for SRTP; RFC 6188, AES-192 and AES-256 counter mode
- RFC 5764, keys from DTLS-SRTP
- RFC 9335, completely encrypting RTP header extensions and contributing sources (Cryptex)
- RFC 6904, encryption of header extensions
Clause-by-clause status, with the test that proves each clause: rfc3711, rfc7714, rfc6188, rfc9335, rfc6904.
Use
context::Context encrypts or decrypts one direction (encrypt_rtp / decrypt_rtp and the RTCP equivalents) for a protection_profile::ProtectionProfile. The root crate (rtci) creates the contexts from the keys rtci-dtls exports.
Sans-I/O
Packets in, packets out; the crate holds the per-stream replay and rollover state and nothing else. No I/O, no clock. All cryptography goes through rtci-crypto's provider (crypto-ring by default, or crypto-aws-lc-rs; openssl adds an OpenSSL AES-CTR cipher).
Licence
Licensed under either of the MIT licence or the Apache License, Version 2.0, at your option.
This crate is part of the rtci workspace, which descends from webrtc-rs/rtc and is developed independently; FORK.md lists what it carries over upstream. Upstream's licence and copyright notices are retained.
rtci_srtp
SRTP and SRTCP for the Sans-I/O WebRTC stack.
- mod
configSession configuration: keys, protection profile, and replay-protection options. - mod
contextThe encrypt/decrypt state for one SRTP/SRTCP session. - mod
cryptexCryptex ([RFC 9335]): encryption of the CSRCs and RTP header extensions. - mod
header_extensionEncryption of selected RTP header extension elements ([RFC 6904]). - mod
keyingMaster keys over a context's lifetime: the key derivation rate, the Master Key Identifier (MKI), the number of packets a master key may protect, and the events that tell the application to re-key ([RFC 3711] sections 3.2.1, 4.3.1, 8.1 and 9.2). - mod
optionPer-context options, currently the replay-detector factory. - mod
protection_profileThe DTLS-SRTP protection profiles and their key, salt and tag lengths. - use
crypto
rtci_srtp::config
Session configuration: keys, protection profile, and replay-protection options.
- struct
ConfigConfig is used to configure a session. The top-level integration exports keying material from DTLS and installs it here, or callers can directly pass the keys themselves. After a Config is passed to a session it must not be modified. - struct
SessionKeysSessionKeys bundles the keys required to setup an SRTP session - const
LABEL_EXTRACTOR_DTLS_SRTPRFC 5764 exporter label used to derive SRTP master keys and salts from DTLS.
rtci_srtp::context
The encrypt/decrypt state for one SRTP/SRTCP session.
- mod
srtcpSRTCP protection and unprotection. - mod
srtpSRTP protection and unprotection. - struct
ContextContext represents a SRTP cryptographic context Context can only be used for one-way operations it must either used ONLY for encryption or ONLY for decryption - const
MAX_MASTER_KEYSHow many master keys one context holds at a time (seeContext::add_master_key).
rtci_srtp::context::srtcp
SRTCP protection and unprotection.
No public items at its top level.
rtci_srtp::context::srtp
SRTP protection and unprotection.
No public items at its top level.
rtci_srtp::cryptex
Cryptex ([RFC 9335]): encryption of the CSRCs and RTP header extensions.
- struct
CryptexHow aContextuses Cryptex (RFC 9335).
rtci_srtp::header_extension
Encryption of selected RTP header extension elements ([RFC 6904]).
- struct
EncryptedHeaderExtensionsThe header extension element ids whose payload is encrypted (RFC 6904 section 4).
rtci_srtp::keying
Master keys over a context's lifetime: the key derivation rate, the Master Key Identifier (MKI), the number of packets a master key may protect, and the events that tell the application to re-key ([RFC 3711] sections 3.2.1, 4.3.1, 8.1 and 9.2).
- struct
KeyDerivationRateThe key derivation rate (RFC 3711 section 4.3.1): session keys are derived again each time the packet index crosses a multiple of it. Zero, the default and what DTLS-SRTP fixes (RFC 5764 section 4.1.2), derives them once. - struct
KeyingHow a context is keyed beyond its first master key and salt; seeContext::with_keying. Both are fixed for the context's lifetime (RFC 3711 sections 3.2.1 and 4.3.1). - struct
KeyLifetimeHow many packets one master key may protect before the context refuses to use it. - struct
KeyUsageHow much of a master key's lifetime is used; seeContext::key_usage. - enum
ContextEventWhat a context reports to the application; read withContext::poll_event. - enum
DiscardReasonWhyContextEvent::PacketDiscardeddiscarded a packet (RFC 3711 section 3.3). - enum
PacketKindWhich of a master key's two packet counts something is about. - fn
validate_key_lifetimeChecks a key lifetime asContext::set_key_lifetimedoes: at least one packet, at most 2^48 SRTP and 2^31 SRTCP (RFC 3711 section 9.2). - const
MAX_MKI_LENThe longest MKI a context accepts, in octets. RFC 3711 leaves the length to key management; DTLS-SRTP (RFC 5764 section 4.1.3) and SDES (RFC 4568) carry at most 255 and 128. - const
MAX_PENDING_DISCARD_EVENTSThe mostContextEvent::PacketDiscardedevents a context keeps queued. - const
MAX_SRTCP_PACKETS_PER_KEYThe most SRTCP packets one master key may protect (RFC 3711 section 9.2, RFC 7714 section 10): 2^31. - const
MAX_SRTP_PACKETS_PER_KEYThe most SRTP packets one master key may protect (RFC 3711 section 9.2, RFC 7714 section 10): 2^48.
rtci_srtp::option
Per-context options, currently the replay-detector factory.
- fn
srtcp_no_replay_protectionsrtcp_no_replay_protection disables SRTCP replay protection. - fn
srtcp_replay_protectionSets SRTCP replay protection window size. - fn
srtp_no_replay_protectionsrtp_no_replay_protection disables SRTP replay protection. - fn
srtp_replay_protectionsrtp_replay_protection sets SRTP replay protection window size. - type
ContextOptionA factory for theReplayDetectora context should use. - const
DEFAULT_REPLAY_PROTECTION_WINDOWThe replay window of a context created without replay options. - const
MIN_REPLAY_PROTECTION_WINDOWThe smallest replay window RFC 3711 section 3.3.2 allows: "SRTP-WINDOW-SIZE ... MUST be at least 64".
rtci_srtp::protection_profile
The DTLS-SRTP protection profiles and their key, salt and tag lengths.
- enum
ProtectionProfileProtectionProfile specifies Cipher and AuthTag details, similar to TLS cipher suite
Generated from the sources of rtci-srtp 0.5.0 at its release tag. Items made by macros and methods are on docs.rs.