Skip to content

Commit f3fa57a

Browse files
committed
Revert "Bug 1932591 - WebRTC DTLS1.3 to enable sending a PQ key share and put the PQ share as the top priority in Nightly/Early Beta r=webrtc-reviewers,djackson,bwc" for causing bc failures on ServoUtils.h
This reverts commit b82a54f.
1 parent c1e6f79 commit f3fa57a

File tree

6 files changed

+50
-202
lines changed

6 files changed

+50
-202
lines changed

browser/components/enterprisepolicies/Policies.sys.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,7 @@ export var Policies = {
20972097
onBeforeAddons(manager, param) {
20982098
setAndLockPref("network.http.http3.enable_kyber", param);
20992099
setAndLockPref("security.tls.enable_kyber", param);
2100-
setAndLockPref("media.peerconnection.dtls.enable_pq_hybrid_kex", param);
2100+
setAndLockPref("media.webrtc.enable_pq_dtls", param);
21012101
},
21022102
},
21032103

dom/media/webrtc/tests/mochitests/test_peerConnection_glean.html

Lines changed: 2 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -223,70 +223,7 @@
223223
},
224224

225225
async function checkDtlsKEA() {
226-
// "media.peerconnection.dtls.enable_pq_hybrid_kex" is enabled by default
227-
// "send_mlkem_keyshare" enabled in Nightly and Early Beta
228-
// By default we send 2 key shares, PQ and X25519
229-
// PQ Key share (ECDH Hybrid) has a higher preference, so it will be chosen as KEA
230-
const pc1 = new RTCPeerConnection();
231-
const pc2 = new RTCPeerConnection();
232-
await gleanResetTestValues();
233-
// SSL Handshake Key Exchange Algorithm (null=0, rsa=1, dh=2, ecdh=4, ecdh_hybrid=8)
234-
let keyExchangeValue = await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue() || 0;
235-
is(keyExchangeValue, 0, "Expected no keyExchange distribution defined");
236-
237-
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
238-
pc1.addTrack(stream.getTracks()[0]);
239-
240-
await connect(pc1, pc2, 32000, "DTLS connected", true, true);
241-
// This telemetry happens on STS/socket process
242-
await gleanFlushChildren();
243-
244-
let count1_0 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["0"] || 0;
245-
let count1_1 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["1"] || 0;
246-
let count1_2 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["2"] || 0;
247-
let count1_4 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["4"] || 0;
248-
let count1_8 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["8"] || 0;
249-
is(count1_0, 0, "Expected 0 connections using NULL");
250-
is(count1_1, 0, "Expected 0 connections using RSA");
251-
is(count1_2, 0, "Expected 0 connections using DH");
252-
is(count1_4, 0, "Expected 0 connections using ECDH");
253-
is(count1_8, 2, "Expected 2 connections using ECDH Hybrid");
254-
},
255-
256-
async function checkDtlsKEA_DTLSBelow13() {
257-
// DTLS1.2 does not use Kyber
258-
// In this case, X25519 (ECDH) key share will be used
259-
await withPrefs([["media.peerconnection.dtls.version.max", 771]],
260-
async () => {
261-
const pc1 = new RTCPeerConnection();
262-
const pc2 = new RTCPeerConnection();
263-
await gleanResetTestValues();
264-
// SSL Handshake Key Exchange Algorithm (null=0, rsa=1, dh=2, ecdh=4, ecdh_hybrid=8)
265-
let keyExchangeValue = await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue() || 0;
266-
is(keyExchangeValue, 0, "Expected no keyExchange distribution defined");
267-
268-
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
269-
pc1.addTrack(stream.getTracks()[0]);
270-
271-
await connect(pc1, pc2, 32000, "DTLS connected", true, true);
272-
// This telemetry happens on STS/socket process
273-
await gleanFlushChildren();
274-
275-
let count1_0 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["0"] || 0;
276-
let count1_1 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["1"] || 0;
277-
let count1_2 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["2"] || 0;
278-
let count1_4 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["4"] || 0;
279-
let count1_8 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["8"] || 0;
280-
is(count1_0, 0, "Expected 0 connections using NULL");
281-
is(count1_1, 0, "Expected 0 connections using RSA");
282-
is(count1_2, 0, "Expected 0 connections using DH");
283-
is(count1_4, 2, "Expected 2 connections using ECDH");
284-
is(count1_8, 0, "Expected 0 connections using ECDH Hybrid");
285-
})},
286-
287-
async function checkDtlsKEA_DTLS13DisablePQ() {
288-
await withPrefs([["media.peerconnection.dtls.enable_pq_hybrid_kex", false]],
289-
async () => {
226+
// Currently, ssl_grp_ec_curve25519 is the default option (ECDH)
290227
const pc1 = new RTCPeerConnection();
291228
const pc2 = new RTCPeerConnection();
292229
await gleanResetTestValues();
@@ -311,73 +248,7 @@
311248
is(count1_2, 0, "Expected 0 connections using DH");
312249
is(count1_4, 2, "Expected 2 connections using ECDH");
313250
is(count1_8, 0, "Expected 0 connections using ECDH Hybrid");
314-
})},
315-
316-
async function checkDtlsKEA_DTLS13DisablePQEnablePQShare() {
317-
// Safety measures, when PQ is disabled, even if the sending ml-kem share is enabled
318-
// it should not be sent.
319-
await withPrefs([["media.peerconnection.dtls.enable_pq_hybrid_kex", false],
320-
["media.peerconnection.dtls.send_mlkem_keyshare", true]
321-
],
322-
async () => {
323-
const pc1 = new RTCPeerConnection();
324-
const pc2 = new RTCPeerConnection();
325-
await gleanResetTestValues();
326-
// SSL Handshake Key Exchange Algorithm (null=0, rsa=1, dh=2, ecdh=4, ecdh_hybrid=8)
327-
let keyExchangeValue = await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue() || 0;
328-
is(keyExchangeValue, 0, "Expected no keyExchange distribution defined");
329-
330-
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
331-
pc1.addTrack(stream.getTracks()[0]);
332-
333-
await connect(pc1, pc2, 32000, "DTLS connected", true, true);
334-
// This telemetry happens on STS/socket process
335-
await gleanFlushChildren();
336-
337-
let count1_0 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["0"] || 0;
338-
let count1_1 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["1"] || 0;
339-
let count1_2 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["2"] || 0;
340-
let count1_4 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["4"] || 0;
341-
let count1_8 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["8"] || 0;
342-
is(count1_0, 0, "Expected 0 connections using NULL");
343-
is(count1_1, 0, "Expected 0 connections using RSA");
344-
is(count1_2, 0, "Expected 0 connections using DH");
345-
is(count1_4, 2, "Expected 2 connections using ECDH");
346-
is(count1_8, 0, "Expected 0 connections using ECDH Hybrid");
347-
})},
348-
349-
async function checkDtlsKEA_DTLS13EnablePQDisablePQShare() {
350-
// We will still advertise PQ, but we won't send a key share.
351-
// See bug 1992457.
352-
await withPrefs([["media.peerconnection.dtls.enable_pq_hybrid_kex", true],
353-
["media.peerconnection.dtls.send_mlkem_keyshare", false]
354-
],
355-
async () => {
356-
const pc1 = new RTCPeerConnection();
357-
const pc2 = new RTCPeerConnection();
358-
await gleanResetTestValues();
359-
// SSL Handshake Key Exchange Algorithm (null=0, rsa=1, dh=2, ecdh=4, ecdh_hybrid=8)
360-
let keyExchangeValue = await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue() || 0;
361-
is(keyExchangeValue, 0, "Expected no keyExchange distribution defined");
362-
363-
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
364-
pc1.addTrack(stream.getTracks()[0]);
365-
366-
await connect(pc1, pc2, 32000, "DTLS connected", true, true);
367-
// This telemetry happens on STS/socket process
368-
await gleanFlushChildren();
369-
370-
let count1_0 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["0"] || 0;
371-
let count1_1 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["1"] || 0;
372-
let count1_2 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["2"] || 0;
373-
let count1_4 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["4"] || 0;
374-
let count1_8 = (await GleanTest.webrtcdtls.keyExchangeAlgorithm.testGetValue()).values["8"] || 0;
375-
is(count1_0, 0, "Expected 0 connections using NULL");
376-
is(count1_1, 0, "Expected 0 connections using RSA");
377-
is(count1_2, 0, "Expected 0 connections using DH");
378-
is(count1_4, 2, "Expected 2 connections using ECDH");
379-
is(count1_8, 0, "Expected 0 connections using ECDH Hybrid");
380-
})},
251+
},
381252

382253
async function checkRTCRtpSenderCount() {
383254
const pc = new RTCPeerConnection();

dom/media/webrtc/transport/transportlayerdtls.cpp

Lines changed: 40 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -593,62 +593,39 @@ bool TransportLayerDtls::Setup() {
593593
return false;
594594
}
595595

596-
// If the version is DTLS1.3 and pq in enabled, we will indicate support for
597-
// ML-KEM
598-
bool enable_mlkem =
599-
maxVersion_ >= Version::DTLS_1_3 &&
600-
Preferences::GetBool("media.peerconnection.dtls.enable_pq_hybrid_kex");
596+
unsigned int additional_shares =
597+
StaticPrefs::security_tls_client_hello_send_p256_keyshare();
601598

602-
bool send_mlkem =
603-
Preferences::GetBool("media.peerconnection.dtls.send_mlkem_keyshare");
599+
const SSLNamedGroup namedGroups[] = {
600+
ssl_grp_ec_curve25519, ssl_grp_ec_secp256r1, ssl_grp_ec_secp384r1,
601+
ssl_grp_ffdhe_2048, ssl_grp_ffdhe_3072,
602+
// Advertise MLKEM support but do not pro-actively send a keyshare
604603

605-
if (!enable_mlkem && send_mlkem) {
606-
MOZ_MTLOG(ML_NOTICE,
607-
"The PQ preferences are inconsistent. ML-KEM support will not be "
608-
"advertised, nor will the ML-KEM key share be sent.");
609-
}
610-
611-
std::vector<SSLNamedGroup> namedGroups;
604+
// Mlkem must stay the last in the list because if we don't support it
605+
// the amount of supported_groups will be sent without it.
606+
ssl_grp_kem_mlkem768x25519};
612607

613-
if (enable_mlkem && send_mlkem) {
614-
// RFC 8446: client_shares: A list of offered KeyShareEntry values in
615-
// descending order of client preference.
616-
// {ssl_grp_kem_mlkem768x25519}, {ssl_grp_ec_curve2551} key shared to be
617-
// sent ML-KEM has the highest preference, so it's sent first.
618-
namedGroups = {ssl_grp_kem_mlkem768x25519, ssl_grp_ec_curve25519,
619-
ssl_grp_ec_secp256r1, ssl_grp_ec_secp384r1,
620-
ssl_grp_ffdhe_2048, ssl_grp_ffdhe_3072};
621-
622-
if (SECSuccess != SSL_SendAdditionalKeyShares(ssl_fd.get(), 1)) {
623-
MOZ_MTLOG(ML_ERROR, "Couldn't set up additional key shares");
624-
return false;
625-
}
626-
}
627-
// Else we don't send any additional key share
628-
else if (enable_mlkem && !send_mlkem) {
629-
// Here the order of the namedGroups is different than in the first if
630-
// {ssl_grp_ec_curve25519} is first because it's the key share
631-
// that will be sent by default
632-
namedGroups = {ssl_grp_ec_curve25519, ssl_grp_kem_mlkem768x25519,
633-
ssl_grp_ec_secp256r1, ssl_grp_ec_secp384r1,
634-
ssl_grp_ffdhe_2048, ssl_grp_ffdhe_3072};
635-
}
636-
// ml_kem is disabled
637-
// {ssl_grp_ec_curve25519} will be send as a default key_share
638-
else {
639-
namedGroups = {ssl_grp_ec_curve25519, ssl_grp_ec_secp256r1,
640-
ssl_grp_ec_secp384r1, ssl_grp_ffdhe_2048,
641-
ssl_grp_ffdhe_3072};
608+
size_t numGroups = std::size(namedGroups);
609+
if (!(StaticPrefs::security_tls_enable_kyber() &&
610+
StaticPrefs::media_webrtc_enable_pq_dtls() &&
611+
maxVersion_ >= Version::DTLS_1_3)) {
612+
// Excluding the last group of the namedGroups.
613+
numGroups -= 1;
642614
}
643615

644-
rv = SSL_NamedGroupConfig(ssl_fd.get(), namedGroups.data(),
645-
std::size(namedGroups));
616+
rv = SSL_NamedGroupConfig(ssl_fd.get(), namedGroups, numGroups);
646617

647618
if (rv != SECSuccess) {
648619
MOZ_MTLOG(ML_ERROR, "Couldn't set named groups");
649620
return false;
650621
}
651622

623+
if (SECSuccess !=
624+
SSL_SendAdditionalKeyShares(ssl_fd.get(), additional_shares)) {
625+
MOZ_MTLOG(ML_ERROR, "Couldn't set up additional key shares");
626+
return false;
627+
}
628+
652629
// Certificate validation
653630
rv = SSL_AuthCertificateHook(ssl_fd.get(), AuthCertificateHook,
654631
reinterpret_cast<void*>(this));
@@ -722,16 +699,16 @@ bool TransportLayerDtls::SetupAlpn(UniquePRFileDesc& ssl_fd) const {
722699
// builds, but can be disabled with prefs and they aren't on in our unit tests
723700
// since that uses NSS default configuration.
724701
//
725-
// Only override prefs to comply with MUST statements in the security-arch
726-
// doc. Anything outside this list is governed by the usual combination of
727-
// policy and user preferences.
702+
// Only override prefs to comply with MUST statements in the security-arch doc.
703+
// Anything outside this list is governed by the usual combination of policy
704+
// and user preferences.
728705
static const uint32_t EnabledCiphers[] = {
729706
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
730707
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA};
731708

732-
// Disable all NSS suites modes without PFS or with old and rusty
733-
// ciphersuites. Anything outside this list is governed by the usual
734-
// combination of policy and user preferences.
709+
// Disable all NSS suites modes without PFS or with old and rusty ciphersuites.
710+
// Anything outside this list is governed by the usual combination of policy
711+
// and user preferences.
735712
static const uint32_t DisabledCiphers[] = {
736713
// Bug 1310061: disable all SHA384 ciphers until fixed
737714
TLS_AES_256_GCM_SHA384,
@@ -863,8 +840,8 @@ std::vector<uint16_t> TransportLayerDtls::GetDefaultSrtpCiphers() {
863840
ciphers.push_back(kDtlsSrtpAeadAes256Gcm);
864841
ciphers.push_back(kDtlsSrtpAes128CmHmacSha1_80);
865842
#ifndef NIGHTLY_BUILD
866-
// To support bug 1491583 lets try to find out if we get bug reports if we
867-
// no longer offer this in Nightly builds.
843+
// To support bug 1491583 lets try to find out if we get bug reports if we no
844+
// longer offer this in Nightly builds.
868845
ciphers.push_back(kDtlsSrtpAes128CmHmacSha1_32);
869846
#endif
870847

@@ -893,8 +870,8 @@ void TransportLayerDtls::StateChange(TransportLayer* layer, State state) {
893870
LAYER_INFO << "Lower layer is now open; starting TLS");
894871
timer_->Cancel();
895872
timer_->SetTarget(target_);
896-
// Async, since the ICE layer might need to send a STUN response, and
897-
// we don't want the handshake to start until that is sent.
873+
// Async, since the ICE layer might need to send a STUN response, and we
874+
// don't want the handshake to start until that is sent.
898875
timer_->InitWithNamedFuncCallback(
899876
TimerCallback, this, 0, nsITimer::TYPE_ONE_SHOT,
900877
"TransportLayerDtls::TimerCallback"_ns);
@@ -1025,8 +1002,8 @@ bool TransportLayerDtls::CheckAlpn() {
10251002
return !alpn_.empty();
10261003

10271004
case SSL_NEXT_PROTO_NO_OVERLAP:
1028-
// This only happens if there is a custom NPN/ALPN callback installed
1029-
// and that callback doesn't properly handle ALPN.
1005+
// This only happens if there is a custom NPN/ALPN callback installed and
1006+
// that callback doesn't properly handle ALPN.
10301007
MOZ_MTLOG(ML_ERROR, LAYER_INFO << "error in ALPN selection callback");
10311008
return false;
10321009

@@ -1039,8 +1016,8 @@ bool TransportLayerDtls::CheckAlpn() {
10391016
std::string chosen(chosenAlpn, chosenAlpnLen);
10401017
MOZ_MTLOG(ML_NOTICE, LAYER_INFO << "Selected ALPN string: " << chosen);
10411018
if (alpn_allowed_.find(chosen) == alpn_allowed_.end()) {
1042-
// Maybe our peer chose a protocol we didn't offer (when we are client),
1043-
// or something is seriously wrong.
1019+
// Maybe our peer chose a protocol we didn't offer (when we are client), or
1020+
// something is seriously wrong.
10441021
std::ostringstream ss;
10451022
for (auto i = alpn_allowed_.begin(); i != alpn_allowed_.end(); ++i) {
10461023
ss << (i == alpn_allowed_.begin() ? " '" : ", '") << *i << "'";
@@ -1249,8 +1226,8 @@ PRBool TransportLayerDtls::WriteSrtpXtn(PRFileDesc* fd,
12491226
if (message == ssl_hs_client_hello) {
12501227
MOZ_ASSERT(self->role_ == CLIENT);
12511228
MOZ_ASSERT(self->enabled_srtp_ciphers_.size(), "Haven't enabled SRTP");
1252-
// We will take 2 octets for each cipher, plus a 2 octet length and 1
1253-
// octet for the length of the empty MKI.
1229+
// We will take 2 octets for each cipher, plus a 2 octet length and 1 octet
1230+
// for the length of the empty MKI.
12541231
if (max_len < self->enabled_srtp_ciphers_.size() * 2 + 3) {
12551232
MOZ_ASSERT(false, "Not enough space to send SRTP extension");
12561233
return false;
@@ -1380,8 +1357,8 @@ SECStatus TransportLayerDtls::HandleSrtpXtn(
13801357
MOZ_ASSERT(self->role_ == SERVER);
13811358
if (self->enabled_srtp_ciphers_.empty()) {
13821359
// We don't have SRTP enabled, which is probably bad, but no sense in
1383-
// having the handshake fail at this point, let the client decide if
1384-
// this is a problem.
1360+
// having the handshake fail at this point, let the client decide if this
1361+
// is a problem.
13851362
return SECSuccess;
13861363
}
13871364

modules/libpref/init/StaticPrefList.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12161,6 +12161,12 @@
1216112161
value: false
1216212162
mirror: always
1216312163

12164+
# This pref disables using PQ crypto for WebRTC DTLS code.
12165+
- name: media.webrtc.enable_pq_dtls
12166+
type: RelaxedAtomicBool
12167+
value: @IS_EARLY_BETA_OR_EARLIER@
12168+
mirror: always
12169+
1216412170
# This pref controls whether dispatch testing-only events.
1216512171
- name: media.webvtt.testing.events
1216612172
type: bool

modules/libpref/init/all.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,6 @@ pref("media.videocontrols.keyboard-tab-to-all-controls", true);
319319
// 770 = DTLS 1.0, 771 = DTLS 1.2, 772 = DTLS 1.3
320320
pref("media.peerconnection.dtls.version.min", 771);
321321
pref("media.peerconnection.dtls.version.max", 772);
322-
pref("media.peerconnection.dtls.enable_pq_hybrid_kex", true);
323-
#ifdef EARLY_BETA_OR_EARLIER
324-
pref("media.peerconnection.dtls.send_mlkem_keyshare", true);
325-
#else
326-
pref("media.peerconnection.dtls.send_mlkem_keyshare", false);
327-
#endif
328322

329323
pref("media.peerconnection.sctp.default_max_streams", 2048);
330324

toolkit/components/nimbus/FeatureManifest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4843,7 +4843,7 @@ pqcrypto:
48434843
type: boolean
48444844
setPref:
48454845
branch: default
4846-
pref: media.peerconnection.dtls.enable_pq_hybrid_kex
4846+
pref: media.webrtc.enable_pq_dtls
48474847
description: >-
48484848
Whether to enable mlkem768x25519 for DTLS in WebRTC.
48494849

0 commit comments

Comments
 (0)