1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<!doctype html>
<meta charset=utf-8>
<title>RTCPeerConnection.prototype.createOffer</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../RTCPeerConnection-helper.js"></script>
<script>
'use strict';
// draft-ietf-rtcweb-security-20 section 6.5
//
// All Implementations MUST support DTLS 1.2 with the
// TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 cipher suite and the P-256
// curve [FIPS186].
// ....... The DTLS-SRTP protection profile
// SRTP_AES128_CM_HMAC_SHA1_80 MUST be supported for SRTP.
// Implementations MUST favor cipher suites which support (Perfect
// Forward Secrecy) PFS over non-PFS cipher suites and SHOULD favor AEAD
// over non-AEAD cipher suites.
const acceptableTlsVersions = new Set([
'FEFD', // DTLS 1.2 - RFC 6437 section 4.1
'0304', // TLS 1.3 - RFC 8446 section 5.1
]);
const acceptableDtlsCiphersuites = new Set([
'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256',
]);
const acceptableSrtpCiphersuites = new Set([
'SRTP_AES128_CM_HMAC_SHA1_80',
'AES_CM_128_HMAC_SHA1_80',
]);
const acceptableValues = {
'tlsVersion': acceptableTlsVersions,
'dtlsCipher': acceptableDtlsCiphersuites,
'srtpCipher': acceptableSrtpCiphersuites,
};
function verifyStat(name, transportStats) {
assert_not_equals(typeof transportStats, 'undefined');
assert_true(name in transportStats, 'Value present:');
assert_true(acceptableValues[name].has(transportStats[name]));
}
for (const name of Object.keys(acceptableValues)) {
promise_test(async t => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
pc1.createDataChannel('foo');
exchangeIceCandidates(pc1, pc2);
await exchangeOfferAnswer(pc1, pc2);
await waitForState(pc1.sctp.transport, 'connected');
const statsReport = await pc1.getStats();
const transportStats = [...statsReport.values()].find(({type}) => type === 'transport');
verifyStat(name, transportStats);
}, name + ' is acceptable on data-only');
promise_test(async t => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
const transceiver = pc1.addTransceiver('video');
exchangeIceCandidates(pc1, pc2);
await exchangeOfferAnswer(pc1, pc2);
await waitForState(transceiver.sender.transport, 'connected');
const statsReport = await pc1.getStats();
const transportStats = [...statsReport.values()].find(({type}) => type === 'transport');
verifyStat(name, transportStats);
}, name + ' is acceptable on video-only');
}
</script>
|