tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit bf7a85843044f2326261c7fad6899d197604a4db
parent a7fa8e2b82913810ce9993928fa7e49d29aa54f8
Author: Michael Froman <mfroman@mozilla.com>
Date:   Wed, 15 Oct 2025 11:31:51 -0500

Bug 1993083 - Vendor libwebrtc from 6b82554f6d

Upstream commit: https://webrtc.googlesource.com/src/+/6b82554f6d3a3fa6944714329ba001e212db11bf
    Ignore a no-op delta in RTCConfig.crypto_options.

    GetCryptoOptions() initializes configuration_.crypto_options to
    default options if found uninitialized. This causes future
    SetConfiguration to fail even with an unmodified RTCConfig due
    to a trivial and no-op difference in crypto_options.

    So ignore a no-op difference and proceed with SetConfiguration in
    such cases. Also added tests that exercise this case.

    Bug: webrtc:42235111
    Change-Id: If8c7bc0bdd06710e453c1157fee09819b0248aad
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/402800
    Reviewed-by: Harald Alvestrand <hta@webrtc.org>
    Auto-Submit: Sameer Vijaykar <samvi@google.com>
    Commit-Queue: Harald Alvestrand <hta@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45252}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0103.patch | 2+-
Mthird_party/libwebrtc/pc/BUILD.gn | 5+++--
Mthird_party/libwebrtc/pc/peer_connection.cc | 3++-
Mthird_party/libwebrtc/pc/peer_connection_interface_unittest.cc | 120+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mthird_party/libwebrtc/pc/test/fake_rtc_certificate_generator.h | 16+++++++++++-----
6 files changed, 139 insertions(+), 11 deletions(-)

diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-15T16:30:40.164868+00:00. +libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-15T16:31:41.924777+00:00. # base of lastest vendoring -f7ecdbe669 +6b82554f6d diff --git a/third_party/libwebrtc/moz-patch-stack/s0103.patch b/third_party/libwebrtc/moz-patch-stack/s0103.patch @@ -601,7 +601,7 @@ index f79625d651..fe09ff6f5b 100644 import("../../webrtc.gni") diff --git a/pc/BUILD.gn b/pc/BUILD.gn -index 49c99d02aa..f0bce25487 100644 +index 8ccabca2e2..640a30b5a4 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -30,8 +30,8 @@ diff --git a/third_party/libwebrtc/pc/BUILD.gn b/third_party/libwebrtc/pc/BUILD.gn @@ -2340,7 +2340,7 @@ if (rtc_include_tests && !build_with_chromium) { "../test:test_main", "../test:test_support", "../test:wait_until", - "../test/time_controller:time_controller", + "../test/time_controller", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/strings", ] @@ -2675,7 +2675,7 @@ if (rtc_include_tests && !build_with_chromium) { "test/android_test_initializer.h", ] deps = [ - "../modules/utility:utility", + "../modules/utility", "../rtc_base:checks", "../rtc_base:ssl_adapter", "../sdk/android:internal_jni", @@ -2865,6 +2865,7 @@ if (rtc_include_tests && !build_with_chromium) { "../api/environment:environment_factory", "../api/task_queue", "../api/task_queue:default_task_queue_factory", + "../api/task_queue:pending_task_safety_flag", "../api/transport:bandwidth_estimation_settings", "../api/transport:bitrate_settings", "../api/transport:datagram_transport_interface", diff --git a/third_party/libwebrtc/pc/peer_connection.cc b/third_party/libwebrtc/pc/peer_connection.cc @@ -1494,7 +1494,8 @@ RTCError PeerConnection::SetConfiguration( } if (has_local_description && - configuration.crypto_options != configuration_.crypto_options) { + configuration.crypto_options.value_or(CryptoOptions()) != + configuration_.crypto_options) { LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_MODIFICATION, "Can't change crypto_options after calling " "SetLocalDescription."); diff --git a/third_party/libwebrtc/pc/peer_connection_interface_unittest.cc b/third_party/libwebrtc/pc/peer_connection_interface_unittest.cc @@ -25,6 +25,7 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/create_peerconnection_factory.h" +#include "api/crypto/crypto_options.h" #include "api/data_channel_interface.h" #include "api/enable_media_with_defaults.h" #include "api/environment/environment_factory.h" @@ -2398,6 +2399,125 @@ TEST_P(PeerConnectionInterfaceTest, RTCErrorType::INVALID_PARAMETER); } +TEST_P(PeerConnectionInterfaceTest, UnmodifiedSetConfigurationSucceeds) { + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + + CreatePeerConnection(config); + + EXPECT_TRUE(pc_->SetConfiguration(config).ok()); + } + + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + + CreatePeerConnection(config); + + std::unique_ptr<SessionDescriptionInterface> offer; + ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); + EXPECT_TRUE(DoSetLocalDescription(std::move(offer))); + + EXPECT_TRUE(pc_->SetConfiguration(config).ok()); + } +} + +TEST_P(PeerConnectionInterfaceTest, + SetConfigurationSucceedsWithMatchingCryptoOptions) { + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + + CreatePeerConnection(config); + + config.crypto_options = CryptoOptions(); + EXPECT_TRUE(pc_->SetConfiguration(config).ok()); + } + + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + + CreatePeerConnection(config); + + std::unique_ptr<SessionDescriptionInterface> offer; + ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); + EXPECT_TRUE(DoSetLocalDescription(std::move(offer))); + + config.crypto_options = CryptoOptions(); + EXPECT_TRUE(pc_->SetConfiguration(config).ok()); + } + + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + CryptoOptions options; + options.ephemeral_key_exchange_cipher_groups.SetEnabled({ + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups:: + kX25519_MLKEM768, + }); + config.crypto_options = options; + + CreatePeerConnection(config); + + std::unique_ptr<SessionDescriptionInterface> offer; + ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); + EXPECT_TRUE(DoSetLocalDescription(std::move(offer))); + + EXPECT_TRUE(pc_->SetConfiguration(config).ok()); + } +} + +TEST_P(PeerConnectionInterfaceTest, + SetConfigurationFailsWithMismatchingCryptoOptions) { + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + + CreatePeerConnection(config); + + std::unique_ptr<SessionDescriptionInterface> offer; + ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); + EXPECT_TRUE(DoSetLocalDescription(std::move(offer))); + + CryptoOptions options; + options.ephemeral_key_exchange_cipher_groups.SetEnabled({ + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups:: + kX25519_MLKEM768, + }); + config.crypto_options = options; + + RTCError error = pc_->SetConfiguration(config); + EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, error.type()); + } + + { + RTCConfiguration config; + config.sdp_semantics = sdp_semantics_; + CryptoOptions options; + options.ephemeral_key_exchange_cipher_groups.SetEnabled({ + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups:: + kX25519_MLKEM768, + }); + config.crypto_options = options; + + CreatePeerConnection(config); + + std::unique_ptr<SessionDescriptionInterface> offer; + ASSERT_TRUE(DoCreateOffer(&offer, nullptr)); + EXPECT_TRUE(DoSetLocalDescription(std::move(offer))); + + options.ephemeral_key_exchange_cipher_groups.SetEnabled({ + webrtc::CryptoOptions::EphemeralKeyExchangeCipherGroups::kSECP521R1, + }); + config.crypto_options = options; + + RTCError error = pc_->SetConfiguration(config); + EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, error.type()); + } +} + // Test that PeerConnection::Close changes the states to closed and all remote // tracks change state to ended. TEST_P(PeerConnectionInterfaceTest, CloseAndTestStreamsAndStates) { diff --git a/third_party/libwebrtc/pc/test/fake_rtc_certificate_generator.h b/third_party/libwebrtc/pc/test/fake_rtc_certificate_generator.h @@ -17,6 +17,7 @@ #include <utility> #include "api/scoped_refptr.h" +#include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/task_queue_base.h" #include "api/units/time_delta.h" #include "rtc_base/checks.h" @@ -158,10 +159,11 @@ class FakeRTCCertificateGenerator RTC_DCHECK_EQ(key_params.ec_curve(), webrtc::EC_NIST_P256); } webrtc::KeyType key_type = key_params.type(); - webrtc::TaskQueueBase::Current()->PostTask( + webrtc::TaskQueueBase::Current()->PostTask(webrtc::SafeTask( + pending_delete_.flag(), [this, key_type, callback = std::move(callback)]() mutable { GenerateCertificate(key_type, std::move(callback)); - }); + })); } static webrtc::scoped_refptr<webrtc::RTCCertificate> GenerateCertificate() { @@ -202,9 +204,11 @@ class FakeRTCCertificateGenerator // set_should_wait(false) is called. if (should_wait_) { webrtc::TaskQueueBase::Current()->PostDelayedTask( - [this, key_type, callback = std::move(callback)]() mutable { - GenerateCertificate(key_type, std::move(callback)); - }, + webrtc::SafeTask( + pending_delete_.flag(), + [this, key_type, callback = std::move(callback)]() mutable { + GenerateCertificate(key_type, std::move(callback)); + }), webrtc::TimeDelta::Millis(1)); return; } @@ -220,6 +224,8 @@ class FakeRTCCertificateGenerator } } + webrtc::ScopedTaskSafetyDetached pending_delete_; + bool should_fail_; bool should_wait_; int key_index_ = 0;