Skip to content

Commit ba93f44

Browse files
authored
Correct features to avoid ring if desired. (#98)
* Correct features to avoid ring if desired. quinn-proto isn't required either. * Forgot to remove the dependency. * Proper logic for removing ring. * And we can remove ring/aws-lc-rs
1 parent 5d1bce2 commit ba93f44

File tree

6 files changed

+25
-38
lines changed

6 files changed

+25
-38
lines changed

web-transport-quinn/Cargo.toml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ categories = ["network-programming", "web-programming"]
1313

1414
[features]
1515
default = ["aws-lc-rs"]
16-
aws-lc-rs = ["dep:aws-lc-rs", "quinn/aws-lc-rs", "rustls/aws-lc-rs"]
17-
ring = ["dep:ring", "quinn/ring", "rustls/ring"]
16+
aws-lc-rs = ["quinn/rustls-aws-lc-rs", "rustls/aws-lc-rs"]
17+
ring = ["quinn/rustls-ring", "rustls/ring"]
1818
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1919

2020
[dependencies]
21-
aws-lc-rs = { version = "1", optional = true }
22-
2321
bytes = "1"
2422
futures = "0.3"
2523
http = "1"
2624
log = "0.4"
2725

28-
quinn = "0.11"
29-
quinn-proto = "0.11"
30-
ring = { version = "0.17.13", optional = true }
26+
quinn = { version = "0.11", default-features = false, features = [
27+
"platform-verifier",
28+
"runtime-tokio",
29+
"bloom",
30+
] }
3131

3232
rustls = { version = "0.23", default-features = false, features = [
3333
"logging",
@@ -48,8 +48,5 @@ web-transport-trait = { path = "../web-transport-trait", version = "0.1" }
4848
anyhow = "1"
4949
clap = { version = "4", features = ["derive"] }
5050
env_logger = "0.11"
51-
quinn = "0.11"
52-
quinn-proto = "0.11"
53-
rustls = "0.23"
5451
rustls-pemfile = "2"
5552
tokio = { version = "1", features = ["full"] }

web-transport-quinn/examples/echo-client-advanced.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ async fn main() -> anyhow::Result<()> {
3939

4040
// Standard quinn setup, accepting only the given certificate.
4141
// You should use system roots in production.
42-
let mut config = rustls::ClientConfig::builder_with_provider(Arc::new(
43-
rustls::crypto::aws_lc_rs::default_provider(),
44-
))
42+
let mut config = rustls::ClientConfig::builder_with_provider(
43+
web_transport_quinn::crypto::default_provider(),
44+
)
4545
.with_protocol_versions(&[&rustls::version::TLS13])?
4646
.with_root_certificates(roots)
4747
.with_no_client_auth();

web-transport-quinn/examples/echo-server-advanced.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ async fn main() -> anyhow::Result<()> {
5858
.context("missing private key")?;
5959

6060
// Standard Quinn setup
61-
let mut config = rustls::ServerConfig::builder_with_provider(Arc::new(
62-
rustls::crypto::ring::default_provider(),
63-
))
61+
let mut config = rustls::ServerConfig::builder_with_provider(
62+
web_transport_quinn::crypto::default_provider(),
63+
)
6464
.with_protocol_versions(&[&rustls::version::TLS13])?
6565
.with_no_client_auth()
6666
.with_single_cert(chain, key)?;

web-transport-quinn/src/crypto.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@ pub fn default_provider() -> Provider {
1212
return provider;
1313
}
1414

15-
#[cfg(feature = "aws-lc-rs")]
15+
#[cfg(all(feature = "aws-lc-rs", not(feature = "ring")))]
1616
{
17-
Arc::new(rustls::crypto::aws_lc_rs::default_provider())
17+
return Arc::new(rustls::crypto::aws_lc_rs::default_provider());
1818
}
1919
#[cfg(all(feature = "ring", not(feature = "aws-lc-rs")))]
2020
{
21-
Arc::new(rustls::crypto::ring::default_provider())
21+
return Arc::new(rustls::crypto::ring::default_provider());
2222
}
23-
#[cfg(not(any(feature = "ring", feature = "aws-lc-rs")))]
23+
#[allow(unreachable_code)]
2424
{
25-
panic!("rustls CryptoProvider::set_default() not called and no 'ring'/'aws-lc-rs' feature enabled.");
25+
panic!(
26+
"CryptoProvider::set_default() must be called; or only enable one ring/aws-lc-rs feature."
27+
);
2628
}
2729
}
2830

@@ -39,16 +41,5 @@ pub fn sha256(provider: &Provider, cert: &CertificateDer<'_>) -> hash::Output {
3941
return hash_provider.hash(cert);
4042
}
4143

42-
#[cfg(feature = "aws-lc-rs")]
43-
{
44-
hash::Output::new(aws_lc_rs::digest::digest(&aws_lc_rs::digest::SHA256, cert).as_ref())
45-
}
46-
#[cfg(all(feature = "ring", not(feature = "aws-lc-rs")))]
47-
{
48-
return hash::Output::new(ring::digest::digest(&ring::digest::SHA256, cert).as_ref());
49-
}
50-
#[cfg(not(any(feature = "ring", feature = "aws-lc-rs")))]
51-
{
52-
panic!("No SHA-256 backend available. Ensure your provider exposes SHA-256 or enable 'ring'/'aws-lc-rs' feature.");
53-
}
44+
panic!("No SHA-256 backend available. Ensure your provider exposes SHA-256 or enable the 'ring'/'aws-lc-rs' feature.");
5445
}

web-transport-quinn/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
2626
// External
2727
mod client;
28-
pub(crate) mod crypto;
2928
mod error;
3029
mod recv;
3130
mod send;
@@ -49,6 +48,9 @@ use settings::*;
4948
/// The HTTP/3 ALPN is required when negotiating a QUIC connection.
5049
pub const ALPN: &str = "h3";
5150

51+
/// Export our simple crypto provider.
52+
pub mod crypto;
53+
5254
/// Re-export the underlying QUIC implementation.
5355
pub use quinn;
5456

web-transport-quinn/src/send.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ impl SendStream {
5656
}
5757

5858
/// Write chunks of data to the stream. See [`quinn::SendStream::write_chunks`].
59-
pub async fn write_chunks(
60-
&mut self,
61-
bufs: &mut [Bytes],
62-
) -> Result<quinn_proto::Written, WriteError> {
59+
pub async fn write_chunks(&mut self, bufs: &mut [Bytes]) -> Result<quinn::Written, WriteError> {
6360
self.stream.write_chunks(bufs).await.map_err(Into::into)
6461
}
6562

0 commit comments

Comments
 (0)