summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2025-05-15 16:36:16 +0200
committerDavid Lönnhager <david.l@mullvad.net>2025-05-15 16:36:16 +0200
commit0350f361b989ac27e0ebdf80e800e06d3d5e2d3c (patch)
tree201b28bbef5fded387783f9247ece3593cc7cd3e
parent1957ca9181c3badffc103166c3d4f668694e0345 (diff)
downloadmullvadvpn-test-masque-ech.tar.xz
mullvadvpn-test-masque-ech.zip
Test ECH with aws in masque clienttest-masque-ech
-rw-r--r--Cargo.lock116
-rw-r--r--mullvad-masque-proxy/Cargo.toml2
-rw-r--r--mullvad-masque-proxy/src/client/mod.rs42
3 files changed, 153 insertions, 7 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 6d761edd51..5f377f1a9d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -231,6 +231,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80"
[[package]]
+name = "aws-lc-rs"
+version = "1.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19b756939cb2f8dc900aa6dcd505e6e2428e9cae7ff7b028c49e3946efa70878"
+dependencies = [
+ "aws-lc-sys",
+ "zeroize",
+]
+
+[[package]]
+name = "aws-lc-sys"
+version = "0.28.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9f7720b74ed28ca77f90769a71fd8c637a0137f6fae4ae947e1050229cff57f"
+dependencies = [
+ "bindgen",
+ "cc",
+ "cmake",
+ "dunce",
+ "fs_extra",
+]
+
+[[package]]
name = "axum"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -326,6 +349,29 @@ dependencies = [
]
[[package]]
+name = "bindgen"
+version = "0.69.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"
+dependencies = [
+ "bitflags 2.9.0",
+ "cexpr",
+ "clang-sys",
+ "itertools 0.10.5",
+ "lazy_static",
+ "lazycell",
+ "log",
+ "prettyplease",
+ "proc-macro2",
+ "quote",
+ "regex",
+ "rustc-hash 1.1.0",
+ "shlex",
+ "syn 2.0.100",
+ "which",
+]
+
+[[package]]
name = "bit-set"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -495,6 +541,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
[[package]]
+name = "cexpr"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
+dependencies = [
+ "nom",
+]
+
+[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -561,6 +616,17 @@ dependencies = [
]
[[package]]
+name = "clang-sys"
+version = "1.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
+dependencies = [
+ "glob",
+ "libc",
+ "libloading",
+]
+
+[[package]]
name = "clap"
version = "4.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -610,6 +676,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
[[package]]
+name = "cmake"
+version = "0.1.54"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0"
+dependencies = [
+ "cc",
+]
+
+[[package]]
name = "colorchoice"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1270,6 +1345,12 @@ dependencies = [
]
[[package]]
+name = "fs_extra"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
+
+[[package]]
name = "fsevent-sys"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2369,6 +2450,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
+name = "lazycell"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
+
+[[package]]
name = "libc"
version = "0.2.172"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2572,6 +2659,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
+name = "minimal-lexical"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
+
+[[package]]
name = "miniz_oxide"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3271,6 +3364,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43794a0ace135be66a25d3ae77d41b91615fb68ae937f904090203e81f755b65"
[[package]]
+name = "nom"
+version = "7.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
+dependencies = [
+ "memchr",
+ "minimal-lexical",
+]
+
+[[package]]
name = "notify"
version = "6.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4111,7 +4214,7 @@ dependencies = [
"pin-project-lite",
"quinn-proto",
"quinn-udp",
- "rustc-hash",
+ "rustc-hash 2.1.0",
"rustls 0.23.18",
"socket2",
"thiserror 2.0.9",
@@ -4126,12 +4229,13 @@ version = "0.11.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49df843a9161c85bb8aae55f101bc0bac8bcafd637a620d9122fd7e0b2f7422e"
dependencies = [
+ "aws-lc-rs",
"bytes",
"getrandom 0.3.2",
"lru-slab",
"rand 0.9.0",
"ring",
- "rustc-hash",
+ "rustc-hash 2.1.0",
"rustls 0.23.18",
"rustls-pki-types",
"slab",
@@ -4474,6 +4578,12 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustc-hash"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
+
+[[package]]
+name = "rustc-hash"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497"
@@ -4518,6 +4628,7 @@ version = "0.23.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c9cc1d47e243d655ace55ed38201c19ae02c148ae56412ab8750e8f0166ab7f"
dependencies = [
+ "aws-lc-rs",
"log",
"once_cell",
"ring",
@@ -4571,6 +4682,7 @@ version = "0.102.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9"
dependencies = [
+ "aws-lc-rs",
"ring",
"rustls-pki-types",
"untrusted",
diff --git a/mullvad-masque-proxy/Cargo.toml b/mullvad-masque-proxy/Cargo.toml
index 6f54734d1d..5ec2a716b2 100644
--- a/mullvad-masque-proxy/Cargo.toml
+++ b/mullvad-masque-proxy/Cargo.toml
@@ -9,7 +9,7 @@ rust-version.workspace = true
description = "A limited functionality UDP over HTTP3 proxy"
[dependencies]
-quinn = { version = "0.11", default-features = false, features = ["log", "runtime-tokio", "rustls-ring"] }
+quinn = { version = "0.11", default-features = false, features = ["log", "runtime-tokio", "rustls-ring", "rustls-aws-lc-rs"] }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["fs", "macros", "io-util"] }
h3 = "0.0.7"
diff --git a/mullvad-masque-proxy/src/client/mod.rs b/mullvad-masque-proxy/src/client/mod.rs
index d2b56d12cc..fe6e6299ab 100644
--- a/mullvad-masque-proxy/src/client/mod.rs
+++ b/mullvad-masque-proxy/src/client/mod.rs
@@ -1,6 +1,6 @@
use anyhow::{anyhow, Context};
use bytes::{Buf, Bytes, BytesMut};
-use rustls::client::danger::ServerCertVerified;
+use rustls::{client::{danger::ServerCertVerified, EchConfig, EchMode}, crypto::aws_lc_rs::hpke::ALL_SUPPORTED_SUITES, pki_types::{pem::PemObject, EchConfigListBytes}};
use std::{
fs::{self},
future, io,
@@ -605,12 +605,46 @@ pub fn default_tls_config() -> Arc<rustls::ClientConfig> {
TLS_CONFIG.clone()
}
+static ECH_CONFIG: &[u8] = b"-----BEGIN ECHCONFIG-----
+AEH+DQA9mwAgACDc6mzgHSQV5XxuSXVqUTkT5krmHTZehgqYAJ2ZhN8vLQAEAAEA
+AQAOZWNoLmRldm1vbGUuZXUAAA==
+-----END ECHCONFIG-----
+";
+
fn client_tls_config_with_certs(certs: rustls::RootCertStore) -> Arc<rustls::ClientConfig> {
+ // from go
+ /*
+ var echConfig []byte
+ if *echConfigFile != "" {
+ configBytes, err := os.ReadFile(*echConfigFile)
+ if err != nil {
+ slog2.Fatal("Read ECH config file", "error", err)
+ }
+
+ echConfigs := certutil.DecodePEMBlocks(configBytes, "ECHCONFIG")
+ if lc := len(echConfigs); lc != 1 {
+ slog2.Fatal("Expected one ECHCONFIG block", "n", lc)
+ }
+ echConfig = echConfigs[0]
+ }
+ */
+
+ // TODO: which suites should we support?
+ // TODO: grease?
+ let config = EchConfigListBytes::from_pem_slice(
+ ECH_CONFIG,
+ )
+ .unwrap();
+ let ech_config = EchConfig::new(config, ALL_SUPPORTED_SUITES).unwrap();
+
let mut config = rustls::ClientConfig::builder_with_provider(Arc::new(
- rustls::crypto::ring::default_provider(),
+ //rustls::crypto::ring::default_provider(),
+ rustls::crypto::aws_lc_rs::default_provider(),
))
- .with_protocol_versions(&[&rustls::version::TLS13])
- .expect("ring crypt-prover should support TLS 1.3")
+ .with_ech(ech_config.into())
+ .unwrap()
+ //.with_protocol_versions(&[&rustls::version::TLS13])
+ //.expect("ring crypt-prover should support TLS 1.3")
.with_root_certificates(certs)
.with_no_client_auth();
config.alpn_protocols = vec![b"h3".to_vec()];