rwebtransport 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +666 -666
- package/Cargo.toml +31 -31
- package/LICENSE +202 -202
- package/NOTICE +41 -41
- package/README.md +550 -550
- package/crates/echo-server/Cargo.toml +20 -20
- package/crates/echo-server/src/main.rs +666 -666
- package/crates/native/Cargo.toml +23 -23
- package/crates/native/src/config.rs +129 -129
- package/crates/native/src/driver.rs +463 -463
- package/crates/native/src/lib.rs +821 -821
- package/crates/native/src/server.rs +718 -718
- package/crates/native/src/session.rs +1191 -1191
- package/crates/native/src/tls.rs +96 -96
- package/crates/wtcore/Cargo.toml +15 -15
- package/crates/wtcore/src/h3.rs +226 -226
- package/crates/wtcore/src/lib.rs +9 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +80 -79
- package/prebuilds/darwin-arm64/rwebtransport.node +0 -0
- package/prebuilds/linux-arm64/rwebtransport.node +0 -0
- package/prebuilds/linux-x64/rwebtransport.node +0 -0
- package/prebuilds/win32-x64/rwebtransport.node +0 -0
- package/scripts/bench.mjs +180 -180
- package/scripts/build.js +67 -67
- package/scripts/postinstall.js +67 -67
- package/scripts/setup-unix.sh +129 -129
- package/scripts/setup-windows.ps1 +229 -229
- package/vendor/quiche/AGENTS.md +75 -75
- package/vendor/quiche/COPYING +23 -23
- package/vendor/quiche/Cargo.lock +1212 -1212
- package/vendor/quiche/Cargo.toml +215 -215
- package/vendor/quiche/README.md +466 -466
- package/vendor/quiche/examples/Makefile +46 -46
- package/vendor/quiche/examples/README.md +20 -20
- package/vendor/quiche/examples/cert-big.crt +90 -90
- package/vendor/quiche/examples/cert.crt +18 -18
- package/vendor/quiche/examples/cert.key +28 -28
- package/vendor/quiche/examples/client.c +343 -343
- package/vendor/quiche/examples/client.rs +281 -281
- package/vendor/quiche/examples/gen-certs.sh +15 -15
- package/vendor/quiche/examples/http3-client.c +473 -473
- package/vendor/quiche/examples/http3-client.rs +349 -349
- package/vendor/quiche/examples/http3-server.c +614 -614
- package/vendor/quiche/examples/http3-server.rs +680 -680
- package/vendor/quiche/examples/qpack-decode.rs +87 -87
- package/vendor/quiche/examples/qpack-encode.rs +88 -88
- package/vendor/quiche/examples/rootca.crt +21 -21
- package/vendor/quiche/examples/server.c +529 -529
- package/vendor/quiche/examples/server.rs +529 -529
- package/vendor/quiche/include/quiche.h +1282 -1282
- package/vendor/quiche/src/buffers.rs +105 -105
- package/vendor/quiche/src/build.rs +66 -66
- package/vendor/quiche/src/cid.rs +1079 -1079
- package/vendor/quiche/src/crypto/boringssl.rs +373 -373
- package/vendor/quiche/src/crypto/mod.rs +671 -671
- package/vendor/quiche/src/dgram.rs +118 -118
- package/vendor/quiche/src/error.rs +263 -263
- package/vendor/quiche/src/ffi.rs +2290 -2290
- package/vendor/quiche/src/flowcontrol.rs +246 -246
- package/vendor/quiche/src/frame.rs +2172 -2172
- package/vendor/quiche/src/h3/AGENTS.md +54 -54
- package/vendor/quiche/src/h3/ffi.rs +442 -442
- package/vendor/quiche/src/h3/frame.rs +1404 -1404
- package/vendor/quiche/src/h3/mod.rs +8223 -8223
- package/vendor/quiche/src/h3/qpack/decoder.rs +288 -288
- package/vendor/quiche/src/h3/qpack/encoder.rs +235 -235
- package/vendor/quiche/src/h3/qpack/mod.rs +202 -202
- package/vendor/quiche/src/h3/qpack/static_table.rs +323 -323
- package/vendor/quiche/src/h3/stream.rs +1595 -1595
- package/vendor/quiche/src/lib.rs +9556 -9556
- package/vendor/quiche/src/minmax.rs +446 -446
- package/vendor/quiche/src/packet.rs +2334 -2334
- package/vendor/quiche/src/path.rs +1374 -1374
- package/vendor/quiche/src/pmtud.rs +652 -652
- package/vendor/quiche/src/rand.rs +64 -64
- package/vendor/quiche/src/range_buf.rs +186 -186
- package/vendor/quiche/src/ranges.rs +755 -755
- package/vendor/quiche/src/recovery/AGENTS.md +80 -80
- package/vendor/quiche/src/recovery/bandwidth.rs +565 -565
- package/vendor/quiche/src/recovery/bytes_in_flight.rs +179 -179
- package/vendor/quiche/src/recovery/congestion/cubic.rs +1038 -1038
- package/vendor/quiche/src/recovery/congestion/delivery_rate.rs +514 -514
- package/vendor/quiche/src/recovery/congestion/hystart.rs +241 -241
- package/vendor/quiche/src/recovery/congestion/mod.rs +361 -361
- package/vendor/quiche/src/recovery/congestion/prr.rs +238 -238
- package/vendor/quiche/src/recovery/congestion/recovery.rs +1170 -1170
- package/vendor/quiche/src/recovery/congestion/reno.rs +291 -291
- package/vendor/quiche/src/recovery/congestion/test_sender.rs +201 -201
- package/vendor/quiche/src/recovery/gcongestion/bbr/bandwidth_sampler.rs +1947 -1947
- package/vendor/quiche/src/recovery/gcongestion/bbr/windowed_filter.rs +158 -158
- package/vendor/quiche/src/recovery/gcongestion/bbr.rs +37 -37
- package/vendor/quiche/src/recovery/gcongestion/bbr2/drain.rs +120 -120
- package/vendor/quiche/src/recovery/gcongestion/bbr2/mode.rs +318 -318
- package/vendor/quiche/src/recovery/gcongestion/bbr2/network_model.rs +784 -784
- package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_bw.rs +729 -729
- package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_rtt.rs +175 -175
- package/vendor/quiche/src/recovery/gcongestion/bbr2/startup.rs +190 -190
- package/vendor/quiche/src/recovery/gcongestion/bbr2.rs +855 -855
- package/vendor/quiche/src/recovery/gcongestion/mod.rs +275 -275
- package/vendor/quiche/src/recovery/gcongestion/pacer.rs +294 -294
- package/vendor/quiche/src/recovery/gcongestion/recovery.rs +1384 -1384
- package/vendor/quiche/src/recovery/mod.rs +3086 -3086
- package/vendor/quiche/src/recovery/rtt.rs +152 -152
- package/vendor/quiche/src/stream/mod.rs +2210 -2210
- package/vendor/quiche/src/stream/recv_buf.rs +1236 -1236
- package/vendor/quiche/src/stream/send_buf.rs +849 -849
- package/vendor/quiche/src/test_utils.rs +681 -681
- package/vendor/quiche/src/tests.rs +12922 -12922
- package/vendor/quiche/src/tls/boringssl.rs +375 -375
- package/vendor/quiche/src/tls/mod.rs +1245 -1245
- package/vendor/quiche/src/transport_params.rs +628 -628
package/crates/native/src/tls.rs
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
//! The default "Google Chrome" TLS profile for the QUIC (TLS 1.3) handshake.
|
|
3
|
-
//!
|
|
4
|
-
//! QUIC mandates TLS 1.3, so — unlike a TCP/TLS stack — there is no TLS 1.2
|
|
5
|
-
//! cipher list to negotiate. What still shapes the ClientHello, and what servers
|
|
6
|
-
//! (Cloudflare in particular) fingerprint, is the group preference, the
|
|
7
|
-
//! signature-algorithm list, GREASE, and extension ordering. We mirror Chrome's
|
|
8
|
-
//! choices so the handshake is browser-indistinguishable. The TLS 1.3
|
|
9
|
-
//! cipher-suite preference order is fixed inside BoringSSL and already matches
|
|
10
|
-
//! Chrome (AES-128-GCM, AES-256-GCM, ChaCha20-Poly1305).
|
|
11
|
-
|
|
12
|
-
use boring::hash::MessageDigest;
|
|
13
|
-
use boring::ssl::{
|
|
14
|
-
SslAlert, SslContextBuilder, SslMethod, SslVerifyError, SslVerifyMode, SslVersion,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/// How the server certificate is verified.
|
|
18
|
-
#[derive(Clone, Debug)]
|
|
19
|
-
pub enum CertVerification {
|
|
20
|
-
/// Full PKI validation against the system trust store, with hostname
|
|
21
|
-
/// checking (the default). The `verify_peer(true)` + root loading half is
|
|
22
|
-
/// applied on the quiche `Config` in [`crate::config`]; nothing is set on
|
|
23
|
-
/// the SSL context here.
|
|
24
|
-
PkiDefault,
|
|
25
|
-
/// Accept the server certificate iff its SHA-256 fingerprint matches one of
|
|
26
|
-
/// these. This mirrors the WebTransport `serverCertificateHashes` option:
|
|
27
|
-
/// no CA chain and no hostname check, just a pinned leaf fingerprint.
|
|
28
|
-
Hashes(Vec<[u8; 32]>),
|
|
29
|
-
/// Accept any certificate. Development only.
|
|
30
|
-
Insecure,
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/// Chrome's TLS 1.3 signature-algorithm preference.
|
|
34
|
-
const CHROME_SIGALGS: &str = "ecdsa_secp256r1_sha256:\
|
|
35
|
-
rsa_pss_rsae_sha256:\
|
|
36
|
-
rsa_pkcs1_sha256:\
|
|
37
|
-
ecdsa_secp384r1_sha384:\
|
|
38
|
-
rsa_pss_rsae_sha384:\
|
|
39
|
-
rsa_pkcs1_sha384:\
|
|
40
|
-
rsa_pss_rsae_sha512:\
|
|
41
|
-
rsa_pkcs1_sha512:\
|
|
42
|
-
rsa_pkcs1_sha1";
|
|
43
|
-
|
|
44
|
-
/// Build a BoringSSL client context configured with the Chrome TLS profile and
|
|
45
|
-
/// the requested certificate-verification policy.
|
|
46
|
-
pub fn build_client_tls(verify: &CertVerification) -> Result<SslContextBuilder, String> {
|
|
47
|
-
let mut b =
|
|
48
|
-
SslContextBuilder::new(SslMethod::tls()).map_err(|e| format!("SslContextBuilder: {e}"))?;
|
|
49
|
-
|
|
50
|
-
// QUIC mandates TLS 1.3.
|
|
51
|
-
b.set_min_proto_version(Some(SslVersion::TLS1_3))
|
|
52
|
-
.map_err(|e| format!("set_min_proto_version: {e}"))?;
|
|
53
|
-
b.set_max_proto_version(Some(SslVersion::TLS1_3))
|
|
54
|
-
.map_err(|e| format!("set_max_proto_version: {e}"))?;
|
|
55
|
-
|
|
56
|
-
// Chrome's group (named curve) preference.
|
|
57
|
-
b.set_curves_list("X25519:P-256:P-384")
|
|
58
|
-
.map_err(|e| format!("set_curves_list: {e}"))?;
|
|
59
|
-
|
|
60
|
-
// Chrome's signature-algorithm list.
|
|
61
|
-
b.set_sigalgs_list(CHROME_SIGALGS)
|
|
62
|
-
.map_err(|e| format!("set_sigalgs_list: {e}"))?;
|
|
63
|
-
|
|
64
|
-
// Browser-like ClientHello shape: GREASE values and permuted extensions.
|
|
65
|
-
b.set_grease_enabled(true);
|
|
66
|
-
b.set_permute_extensions(true);
|
|
67
|
-
|
|
68
|
-
match verify {
|
|
69
|
-
CertVerification::PkiDefault => {
|
|
70
|
-
// Applied on the quiche Config (verify_peer + system roots). Leaving
|
|
71
|
-
// the SSL context untouched keeps quiche's built-in verification
|
|
72
|
-
// (including the hostname check wired by `set_host_name`).
|
|
73
|
-
}
|
|
74
|
-
CertVerification::Insecure => {
|
|
75
|
-
b.set_verify(SslVerifyMode::NONE);
|
|
76
|
-
}
|
|
77
|
-
CertVerification::Hashes(hashes) => {
|
|
78
|
-
let hashes = hashes.clone();
|
|
79
|
-
b.set_custom_verify_callback(SslVerifyMode::PEER, move |ssl| {
|
|
80
|
-
let cert = ssl
|
|
81
|
-
.peer_certificate()
|
|
82
|
-
.ok_or(SslVerifyError::Invalid(SslAlert::CERTIFICATE_UNKNOWN))?;
|
|
83
|
-
let digest = cert
|
|
84
|
-
.digest(MessageDigest::sha256())
|
|
85
|
-
.map_err(|_| SslVerifyError::Invalid(SslAlert::CERTIFICATE_UNKNOWN))?;
|
|
86
|
-
if hashes.iter().any(|h| digest.as_ref() == h.as_slice()) {
|
|
87
|
-
Ok(())
|
|
88
|
-
} else {
|
|
89
|
-
Err(SslVerifyError::Invalid(SslAlert::BAD_CERTIFICATE))
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
Ok(b)
|
|
96
|
-
}
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
//! The default "Google Chrome" TLS profile for the QUIC (TLS 1.3) handshake.
|
|
3
|
+
//!
|
|
4
|
+
//! QUIC mandates TLS 1.3, so — unlike a TCP/TLS stack — there is no TLS 1.2
|
|
5
|
+
//! cipher list to negotiate. What still shapes the ClientHello, and what servers
|
|
6
|
+
//! (Cloudflare in particular) fingerprint, is the group preference, the
|
|
7
|
+
//! signature-algorithm list, GREASE, and extension ordering. We mirror Chrome's
|
|
8
|
+
//! choices so the handshake is browser-indistinguishable. The TLS 1.3
|
|
9
|
+
//! cipher-suite preference order is fixed inside BoringSSL and already matches
|
|
10
|
+
//! Chrome (AES-128-GCM, AES-256-GCM, ChaCha20-Poly1305).
|
|
11
|
+
|
|
12
|
+
use boring::hash::MessageDigest;
|
|
13
|
+
use boring::ssl::{
|
|
14
|
+
SslAlert, SslContextBuilder, SslMethod, SslVerifyError, SslVerifyMode, SslVersion,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/// How the server certificate is verified.
|
|
18
|
+
#[derive(Clone, Debug)]
|
|
19
|
+
pub enum CertVerification {
|
|
20
|
+
/// Full PKI validation against the system trust store, with hostname
|
|
21
|
+
/// checking (the default). The `verify_peer(true)` + root loading half is
|
|
22
|
+
/// applied on the quiche `Config` in [`crate::config`]; nothing is set on
|
|
23
|
+
/// the SSL context here.
|
|
24
|
+
PkiDefault,
|
|
25
|
+
/// Accept the server certificate iff its SHA-256 fingerprint matches one of
|
|
26
|
+
/// these. This mirrors the WebTransport `serverCertificateHashes` option:
|
|
27
|
+
/// no CA chain and no hostname check, just a pinned leaf fingerprint.
|
|
28
|
+
Hashes(Vec<[u8; 32]>),
|
|
29
|
+
/// Accept any certificate. Development only.
|
|
30
|
+
Insecure,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// Chrome's TLS 1.3 signature-algorithm preference.
|
|
34
|
+
const CHROME_SIGALGS: &str = "ecdsa_secp256r1_sha256:\
|
|
35
|
+
rsa_pss_rsae_sha256:\
|
|
36
|
+
rsa_pkcs1_sha256:\
|
|
37
|
+
ecdsa_secp384r1_sha384:\
|
|
38
|
+
rsa_pss_rsae_sha384:\
|
|
39
|
+
rsa_pkcs1_sha384:\
|
|
40
|
+
rsa_pss_rsae_sha512:\
|
|
41
|
+
rsa_pkcs1_sha512:\
|
|
42
|
+
rsa_pkcs1_sha1";
|
|
43
|
+
|
|
44
|
+
/// Build a BoringSSL client context configured with the Chrome TLS profile and
|
|
45
|
+
/// the requested certificate-verification policy.
|
|
46
|
+
pub fn build_client_tls(verify: &CertVerification) -> Result<SslContextBuilder, String> {
|
|
47
|
+
let mut b =
|
|
48
|
+
SslContextBuilder::new(SslMethod::tls()).map_err(|e| format!("SslContextBuilder: {e}"))?;
|
|
49
|
+
|
|
50
|
+
// QUIC mandates TLS 1.3.
|
|
51
|
+
b.set_min_proto_version(Some(SslVersion::TLS1_3))
|
|
52
|
+
.map_err(|e| format!("set_min_proto_version: {e}"))?;
|
|
53
|
+
b.set_max_proto_version(Some(SslVersion::TLS1_3))
|
|
54
|
+
.map_err(|e| format!("set_max_proto_version: {e}"))?;
|
|
55
|
+
|
|
56
|
+
// Chrome's group (named curve) preference.
|
|
57
|
+
b.set_curves_list("X25519:P-256:P-384")
|
|
58
|
+
.map_err(|e| format!("set_curves_list: {e}"))?;
|
|
59
|
+
|
|
60
|
+
// Chrome's signature-algorithm list.
|
|
61
|
+
b.set_sigalgs_list(CHROME_SIGALGS)
|
|
62
|
+
.map_err(|e| format!("set_sigalgs_list: {e}"))?;
|
|
63
|
+
|
|
64
|
+
// Browser-like ClientHello shape: GREASE values and permuted extensions.
|
|
65
|
+
b.set_grease_enabled(true);
|
|
66
|
+
b.set_permute_extensions(true);
|
|
67
|
+
|
|
68
|
+
match verify {
|
|
69
|
+
CertVerification::PkiDefault => {
|
|
70
|
+
// Applied on the quiche Config (verify_peer + system roots). Leaving
|
|
71
|
+
// the SSL context untouched keeps quiche's built-in verification
|
|
72
|
+
// (including the hostname check wired by `set_host_name`).
|
|
73
|
+
}
|
|
74
|
+
CertVerification::Insecure => {
|
|
75
|
+
b.set_verify(SslVerifyMode::NONE);
|
|
76
|
+
}
|
|
77
|
+
CertVerification::Hashes(hashes) => {
|
|
78
|
+
let hashes = hashes.clone();
|
|
79
|
+
b.set_custom_verify_callback(SslVerifyMode::PEER, move |ssl| {
|
|
80
|
+
let cert = ssl
|
|
81
|
+
.peer_certificate()
|
|
82
|
+
.ok_or(SslVerifyError::Invalid(SslAlert::CERTIFICATE_UNKNOWN))?;
|
|
83
|
+
let digest = cert
|
|
84
|
+
.digest(MessageDigest::sha256())
|
|
85
|
+
.map_err(|_| SslVerifyError::Invalid(SslAlert::CERTIFICATE_UNKNOWN))?;
|
|
86
|
+
if hashes.iter().any(|h| digest.as_ref() == h.as_slice()) {
|
|
87
|
+
Ok(())
|
|
88
|
+
} else {
|
|
89
|
+
Err(SslVerifyError::Invalid(SslAlert::BAD_CERTIFICATE))
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Ok(b)
|
|
96
|
+
}
|
package/crates/wtcore/Cargo.toml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
[package]
|
|
3
|
-
name = "rwebtransport-wtcore"
|
|
4
|
-
version.workspace = true
|
|
5
|
-
edition.workspace = true
|
|
6
|
-
license.workspace = true
|
|
7
|
-
publish = false
|
|
8
|
-
|
|
9
|
-
[lib]
|
|
10
|
-
name = "wtcore"
|
|
11
|
-
path = "src/lib.rs"
|
|
12
|
-
|
|
13
|
-
[dependencies]
|
|
14
|
-
quiche.workspace = true
|
|
15
|
-
octets.workspace = true
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
[package]
|
|
3
|
+
name = "rwebtransport-wtcore"
|
|
4
|
+
version.workspace = true
|
|
5
|
+
edition.workspace = true
|
|
6
|
+
license.workspace = true
|
|
7
|
+
publish = false
|
|
8
|
+
|
|
9
|
+
[lib]
|
|
10
|
+
name = "wtcore"
|
|
11
|
+
path = "src/lib.rs"
|
|
12
|
+
|
|
13
|
+
[dependencies]
|
|
14
|
+
quiche.workspace = true
|
|
15
|
+
octets.workspace = true
|