Upstream changes merged (webrtc-rs/rtc 0.21.x through 0fbcaa74)
From CHANGELOG.md of rtci at its release tag.
Added
RTCCrypto::new_hmacreturns a keyedMacwhose key schedule is derived once, mirroring the existing keyed cipher factories. It replaces the removed one-shothmac/verify_hmac.- New
rtc-cryptocrate: a provider-neutral cryptographic API (webrtc#839, rtc#128).RTCCryptoProviderbundles anRTCCryptooperations trait and anRTCRandomCSPRNG. Two built-in providers ship,RingProviderandAwsLcRsProvider, and applications can supply their own — for OpenSSL, a FIPS-validated module, an HSM, or a platform backend — by implementing the public traits. A reusable conformance suite (rtc_crypto::conformance::assert_provider, behind thetest-supportfeature) validates any implementation against the same RFC vectors the built-ins pass. SettingEngine::set_crypto_providerselects the provider per peer connection. Two peer connections in one process may use different providers. There is no process-global provider to install.- Explicit provider constructors on the standalone protocol crates:
rtc_dtls::ConfigBuilder::with_crypto_provider,rtc_srtp::Context::new_with_provider, andMessageIntegrity::{new_raw,new_short_term,new_long_term}_integrity_with_provider. - Provider-neutral certificate construction:
RTCCertificate::generate,RTCCertificate::generate_from_signing_key, andRTCCertificate::from_pkcs8.rcgen::CertificateParamsis re-exported fromrtc::peer_connection::certificate, so callers no longer need a directrcgendependency to name it. - DTLS record-protection benchmarks (
cargo bench --package rtc-dtls --bench record_protection) and SRTP AEAD plus context-construction benchmarks, all reporting each enabled provider under identical inputs and separating one-time key-schedule cost from per-packet cost.
Changed
- No library code resolves a default crypto provider.
crypto::default_provider()is now called in exactly one place — peer-connection construction — where the application either supplied one viaSettingEngine::set_crypto_provideror gets the feature-selected built-in. Every constructor below that takes anArc<dyn RTCCryptoProvider>from its caller, so a--no-default-featuresbuild fails at configuration time instead of deep inside a handshake. The*_with_providerconstructor pairs are collapsed into single provider-taking constructors (Context::new,Client::new,Agent::new,Certificate::generate_self_signed,Certificate::from_pem,RTCCertificate::from_pem,RTCCertificate::get_fingerprints, theMessageIntegrityconstructors).Defaultimpls that resolved a provider —HandshakeConfig,rtc_dtls::State,Agent,RTCDtlsTransport— are removed in favour of those constructors, andConfigBuilder::builderrors when no provider was configured rather than inventing one. - Each protocol crate re-exports the crypto API (
rtc_srtp::crypto,rtc_stun::crypto,rtc_ice::crypto,rtc_turn::crypto,rtc_dtls::crypto_provider) so standalone users can nameArc<dyn RTCCryptoProvider>without a directrtc-cryptodependency. crypto-ringandcrypto-aws-lc-rsCargo features are now additive. Enabling both builds successfully and is covered in CI. Previously each ofrtc,rtc-dtls,rtc-srtp, andrtc-stuncarried acompile_error!rejecting the combination, which made an otherwise valid build fail whenever Cargo feature unification pulled in both.rtc_crypto::default_provider()still prefersringwhen both are enabled, so default behaviour is unchanged.- DTLS, SRTP, STUN, ICE, TURN, and the top-level
rtccrate perform all cryptography through the configured provider. Protocol composition is unchanged and stays in its own crate: the TLS 1.2 PRF in DTLS, SRTP key derivation and packet layout in SRTP, STUN integrity framing in STUN. Default algorithm selection and wire behaviour are unchanged. rtc_dtls::State::export_keying_materialis now an inherent method returningSecretVec, andrtc_srtp::Config::set_session_keys_from_keying_materialconsumes the exported bytes. The top-level crate performs the handoff, sortc-srtpandrtc-dtlsremain independent of each other.rtc_srtp::config::LABEL_EXTRACTOR_DTLS_SRTPis now public for standalone callers.rtc_stun::MessageIntegritychanged from a public tuple struct to named fields and now holds its provider, becauseSetter::add_toandcheckhave no parameter through which to receive one. Its key is stored as aSecretVec.MediaEngine::register_default_codecsno longer registersvideo/ulpfec(#837). The receive path does not recover media from ULPFEC packets, so offering the codec invited peers to send repair packets that could not be used. Applications that want it can still register it explicitly withMIME_TYPE_ULP_FEC, which remains public. This changes the default offer's SDP: payload type 116 is no longer present. ULPFEC will return to the defaults once receive-side recovery is implemented.- Upgrade
nixto the newer version that allow compileohostargets.
Deprecated
-
Removed
These are deliberate pre-1.0 API removals, not behaviour changes. Every entry has a replacement; see docs/crypto-provider-migration.md for before/after examples.
- Removed the partial
opensslandvendored-opensslCargo features fromrtc-srtpandrtc; SRTP cryptography now uses the selectedrtc-cryptoprovider for every protection profile. They selected only an alternate AES-CTR path and never implemented the full provider contract. An OpenSSL backend can return as a complete downstreamRTCCryptoProvider. - Removed
rtc_shared::crypto::KeyingMaterialExporter.rtc-sharedperforms no cryptography and no longer carries a crypto bridge. - Removed
rtc_srtp::Config::extract_session_keys_from_dtls; useset_session_keys_from_keying_materialwith material exported from the DTLS session. - Removed the default-resolving
MessageIntegrity::{new_raw_integrity, new_short_term_integrity, new_long_term_integrity}constructors and the derivedDefaultimpl.Defaultproduced a credential with an empty key, which is never valid; use the_with_providerconstructors. - Removed
rtc_dtls::crypto::CustomSignerandCryptoPrivateKey::from_custom_signer. Implementrtc_crypto::SigningKeyand useCryptoPrivateKey::from_signing_key. This is a superset of the old capability: non-exportable HSM and KMS keys are supported, andto_pkcs8_der()returnsOk(None)for them instead of fabricating key bytes. - Removed
CryptoPrivateKey::from_key_pair, itsTryFrom<&rcgen::KeyPair>impl, and theserialized_derfield. - Removed
RTCCertificate::from_key_pairandfrom_key_pair_with_provider; useRTCCertificate::generateorgenerate_from_signing_key. - Removed the
Sec1,P256,RcGen,AesGcm, andAesvariants fromrtc_shared::Error, along with thesec1,p256,rcgen,aes, andaes-gcmdependencies ofrtc-shared. These put crypto-crate types in the public API of every crate in the workspace and pinned their major versions there. Crypto failures now cross crate boundaries asError::Crypto(String). - Removed
RTCCrypto::hmacandRTCCrypto::verify_hmac. They are exactlynew_hmac(..)?.sign(..)andnew_hmac(..)?.verify(..), and retaining them preserved a path that re-derives the HMAC key schedule on every call. - Removed the four duplicated
compile_error!backend guards and the fourextern crate aws_lc_rs as ring;aliases.
Fixed
- A message that reaches a peer in the same read sweep as the COOKIE-ACK (or COOKIE-ECHO) that completes its SCTP handshake is no longer dropped. The data now waits for
SCTPHandshakeComplete, on which negotiated data channels open; it used to reach the data channel handler first and be discarded withErrDataChannelNotExisted, after SCTP had already acknowledged it, so the first message the peer sent on a negotiated channel could be lost. - ICE: a controlling agent now answers a Binding request that carries USE-CANDIDATE without ICE-CONTROLLING, and ignores the USE-CANDIDATE, instead of dropping it with
ErrUnexpectedStunrequestMessage. Peers that always act as controlling can now complete ICE (#299). - ICE: the controlling agent now sends a triggered check (RFC 8445 §7.3.1.4) when a Binding request arrives on a pair it had marked Failed, so a late-opening direct path is no longer lost to the relay (#282).
- Incoming RTCP reaches
get_stats()again. Receiver reports, NACK, PLI and FIR now update the outbound stream's remote-inbound and feedback counts, and sender reports update the inbound stream. The read-side stats hook was lost when the interceptor started consuming RTCP (#310). - Ignore unrelated post-handshake DTLS records without consuming the final-flight retry budget or modifying the completed handshake cache.
- Preserve the DTLS retransmission deadline when a repeated or incomplete peer flight arrives while waiting for the next flight.
rtc-crypto's AES-CTR keystream now uses a batched implementation instead of oneencrypt_blockcall per 16-byte block, which defeated AES-NI / ARMv8 instruction pipelining. Roughly 9-10% faster on a 1200-byte SRTP payload.- SRTP no longer derives the HMAC key schedule on every packet.
RTCCrypto::new_hmacreturns a keyedMac, andrtc-srtpkeys its SRTP and SRTCP MACs once per context instead of passing raw key bytes per packet. Roughly 40% faster per RTCP packet and 7% per 1200-byte RTP packet. A counting provider inrtc-srtp/tests/provider_profiles.rsguards the invariant. - DTLS CBC no longer derives its record MAC key on every record.
CryptoCbcholds two keyedMacobjects instead of passing raw key bytes toprf_macper record: ~4% faster on encrypt and ~7% on decrypt, with the key schedule moving to epoch setup. - STUN
MESSAGE-INTEGRITYwas measured against its pre-migration baseline and shows no regression (seertc-stun/benches/README.md); it already usedring's HMAC-SHA1 before G3. - The built-in
RTCRandomimplementations no longer read the operating system on every call. DTLS generates a GCM explicit nonce and a CBC record IV per record; routing those through the backend'sSystemRandomcost ~829 ns onringand ~2196 ns onaws-lc-rs, against ~8 ns for the thread-local CSPRNG the pre-provider code used. They now use an OS-seeded, periodically reseeded thread-local CSPRNG, as BoringSSL and OpenSSL do internally.SystemRandomis still used where the backend owns the operation — keypair generation and signing. DTLS GCM encryption went from 1.015 µs to 262 ns per record. A deployment needing validated entropy everywhere supplies its ownRTCRandom. - The
ringprovider composes RustCrypto's HMAC-SHA1.ringexposes SHA-1 only asHMAC_SHA1_FOR_LEGACY_USE_ONLYand does not use the ARMv8 SHA-1 instructions: 4469 ns against RustCrypto's 1373 ns over a 1212-byte message. The built-in providers are already composite — AES-CTR, CCM, CBC and MD5 come from RustCrypto — so HMAC-SHA1 is composed the same way. This closes the gap without makingaws-lc-rsthe default, which would impose theaws-lc-sysC toolchain on every downstream build. SHA-256 stays onring;aws-lc-rskeeps its own SHA-1.
Net effect: every per-packet and per-record benchmark is at parity with or faster than the pre-migration baseline on the default provider. SRTP AES-CM/HMAC RTP encryption 1.725 µs before and 1.723 µs after; DTLS GCM record encryption 270.5 ns before and 270.1 ns after; DTLS CBC 6-8% faster than before. Context and epoch setup costs rose, which is the intended trade — key schedules moved off the per-packet path. See the three benches/README.md files for the full tables and methodology.
- Add RSA as an allowed private key kind in rtc_dtls::ConfigBuilder:: validate- PR #141
Security
-