diff --git a/Cargo.lock b/Cargo.lock index 455b5dc925b..78d900ebe87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4348,7 +4348,6 @@ dependencies = [ "reqwest", "rind", "rind-jsonwebtoken", - "rind-rustls", "rustls", "rustls-platform-verifier", "serde", @@ -4638,6 +4637,7 @@ dependencies = [ "kio", "m3u8-rs", "moq-archive", + "moq-crypto", "moq-hls", "moq-json", "moq-mux", @@ -4648,7 +4648,6 @@ dependencies = [ "rand 0.10.3", "reqwest", "rind", - "rind-rustls", "serde", "serde_json", "tempfile", @@ -5008,6 +5007,7 @@ dependencies = [ "futures", "hang", "kio", + "moq-crypto", "moq-mux", "moq-net", "moq-tokio", diff --git a/quest/m1/rind/README.md b/quest/m1/rind/README.md index 9b5b6b0e7a3..f74c02abd88 100644 --- a/quest/m1/rind/README.md +++ b/quest/m1/rind/README.md @@ -65,5 +65,4 @@ The epic's own work, once every child has merged: ## Required -- [One typed unsupported-CPU error](/quest/m1/rind/cpu-error.md) - moq-auth, moq-hls and moq-crypto e2ee carry `moq_crypto::provider::UnsupportedCpu` and drop their own CPU-check helpers - [moq-rtc on rind](/quest/m1/rind/rtc.md) - str0m and dimpl run DTLS, SRTP, and STUN on rind diff --git a/quest/m1/rind/cpu-error.md b/quest/m1/rind/cpu-error.md deleted file mode 100644 index ad97978fe4a..00000000000 --- a/quest/m1/rind/cpu-error.md +++ /dev/null @@ -1,49 +0,0 @@ -# [S] One typed unsupported-CPU error - -## Goal - -moq-auth's and moq-hls's `Error::UnsupportedCpu` and moq-crypto e2ee's -`Error::Unsupported` carry the shared -`moq_crypto::provider::UnsupportedCpu` instead of a `String`, converted with -`?`, and each crate's own `rind::cpu::check()` wrapper is gone -(`unsupported_cpu` in `rs/moq-auth/src/error.rs` and -`rs/moq-hls/src/error.rs`, and the `map_err` in -`rs/moq-crypto/src/e2ee/credential.rs`). A caller tells a CPU refusal from -any other failure by its type, the same way in every crate. - -## Plan - -Planned 2026-11-04 with the maintainer, from the suggested follow-up of -[moq-dev/moq#7873](https://github.com/moq-dev/moq/pull/7873), which moved -the transport crates to rind. That PR added the `provider` feature to -moq-crypto, holding `provider::UnsupportedCpu` (`Clone + Copy + Eq`, wrapping -rind's `MissingFeature` privately), and moved moq-quic, moq-tokio, qmux and -moq-uring onto it as `UnsupportedCpu(#[from] ...)` with -`#[error(transparent)]`. This quest does the same for the three crates it -left. - -- ✅ #7873 lands as is, with the type in `provider`; this quest moves it - later (maintainer, 2026-11-04, on - [moq-dev/moq#7917](https://github.com/moq-dev/moq/pull/7917)). -- **The type must not need rustls.** In #7873, `provider` pulls in rustls, - since it also holds `provider()` and `install_default()`. moq-auth's core - build has no rustls (only its `client` feature does), and the e2ee feature - doesn't either. Recommended: put `UnsupportedCpu` and `check()` where they - need only rind, such as a moq-crypto feature that `provider` and `e2ee` - both enable, and keep `provider` for the rustls half. The type's path - may then move out of `provider`, which nothing released uses yet. Check with - `cargo tree` that moq-auth's and moq-crypto's default and - `--no-default-features` graphs gain no rustls. -- moq-hls doesn't depend on moq-crypto today and gains it for this type. -- moq-rtmp kept `rind::cpu::check()` behind `io::Error` in #7873 only - because `provider` needs rustls. If the split above lands, move it onto - the typed error too, or record why not. -- Keep each variant's name: `UnsupportedCpu` in moq-auth and moq-hls. Rename - e2ee's `Unsupported` to `UnsupportedCpu` too, since it only ever means a - CPU refusal, so all three read alike. -- Docs naming these variants (`rs/moq-hls/src/lib.rs`, the moq-hls export - and server rustdoc) follow the change. - -Public API: breaking for moq-auth, moq-hls and moq-crypto (the variants' -payload type, and e2ee's variant name). Each gets a `## Unreleased` note in -its `MIGRATE.md`. Wire: none. diff --git a/quest/m2/recut-held.md b/quest/m2/recut-held.md index 84ecd4ed448..d9125daf2c9 100644 --- a/quest/m2/recut-held.md +++ b/quest/m2/recut-held.md @@ -30,6 +30,5 @@ padding probes in [lite07-finalize](/quest/m2/lite07-finalize.md). ## Required -- [rind CPU error](/quest/m1/rind/cpu-error.md) - claim held rind - [Release on leave](/quest/m1/stream-credit/release-on-leave.md) - claim held stream-credit - [Probe padding](/quest/m2/probe/padding.md) - claim held probe diff --git a/rs/moq-auth/Cargo.toml b/rs/moq-auth/Cargo.toml index deda27f2d56..6af31b4fbba 100644 --- a/rs/moq-auth/Cargo.toml +++ b/rs/moq-auth/Cargo.toml @@ -18,7 +18,7 @@ async = ["kio/async"] client = [ "async", "dep:reqwest", - "dep:rind-rustls", + "moq-crypto/provider", "dep:rustls", "dep:rustls-platform-verifier", "dep:tokio", @@ -34,7 +34,7 @@ axum = { workspace = true, optional = true } base64 = { workspace = true } jsonwebtoken = { workspace = true } kio = { workspace = true, features = ["serde"] } -moq-crypto = { workspace = true, features = ["serde"] } +moq-crypto = { workspace = true, features = ["serde", "cpu"] } moq-pattern = { workspace = true, features = ["serde"] } pkcs1 = { workspace = true, features = ["std"] } pkcs8 = { workspace = true } @@ -42,7 +42,6 @@ rand = { workspace = true, optional = true } reqwest = { workspace = true, features = ["rustls-no-provider", "json"], optional = true } rind = { workspace = true } rind-jsonwebtoken = { workspace = true } -rind-rustls = { workspace = true, optional = true } rustls = { version = "0.23", default-features = false, optional = true } rustls-platform-verifier = { version = "0.7", optional = true } serde = { workspace = true } diff --git a/rs/moq-auth/MIGRATE.md b/rs/moq-auth/MIGRATE.md index 728acafcf2d..7dbb2b0b915 100644 --- a/rs/moq-auth/MIGRATE.md +++ b/rs/moq-auth/MIGRATE.md @@ -4,6 +4,10 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Shared unsupported CPU error + +`Error::UnsupportedCpu` now carries `moq_crypto::cpu::UnsupportedCpu` instead of a `String`. Use its `Display` implementation for the missing feature message. Core builds still need no rustls. + ### `Peer` carries the certificate chain `Peer` gains `chain`: the SHA-256 of the leaf and of each certificate it provably diff --git a/rs/moq-auth/src/crypto.rs b/rs/moq-auth/src/crypto.rs index 447279b1c91..5355debeb88 100644 --- a/rs/moq-auth/src/crypto.rs +++ b/rs/moq-auth/src/crypto.rs @@ -3,7 +3,7 @@ /// /// rind panics on such a CPU instead, so every key runs this before its first operation. pub(crate) fn init() -> crate::Result<()> { - rind::cpu::check().map_err(crate::Error::unsupported_cpu)?; + moq_crypto::cpu::check()?; // An error means the process already picked a provider, which it is entitled to. let _ = rind_jsonwebtoken::DEFAULT_PROVIDER.install_default(); Ok(()) @@ -16,15 +16,13 @@ pub(crate) fn init() -> crate::Result<()> { #[cfg(feature = "client")] pub(crate) fn tls() -> crate::Result { use rustls_platform_verifier::BuilderVerifierExt; - let provider = rind_rustls::default_provider().map_err(crate::Error::unsupported_cpu)?; - Ok( - rustls::ClientConfig::builder_with_provider(std::sync::Arc::new(provider)) - .with_safe_default_protocol_versions() - .map_err(crate::Error::crypto)? - .with_platform_verifier() - .map_err(crate::Error::crypto)? - .with_no_client_auth(), - ) + let provider = moq_crypto::provider::provider()?; + Ok(rustls::ClientConfig::builder_with_provider(provider) + .with_safe_default_protocol_versions() + .map_err(crate::Error::crypto)? + .with_platform_verifier() + .map_err(crate::Error::crypto)? + .with_no_client_auth()) } #[cfg(test)] diff --git a/rs/moq-auth/src/error.rs b/rs/moq-auth/src/error.rs index 0d05edd3844..ae4c8986228 100644 --- a/rs/moq-auth/src/error.rs +++ b/rs/moq-auth/src/error.rs @@ -213,8 +213,8 @@ pub enum Error { MeshState(String), /// This CPU lacks a feature the crate's cryptography requires, named in rind's message. - #[error("unsupported CPU: {0}")] - UnsupportedCpu(String), + #[error(transparent)] + UnsupportedCpu(#[from] moq_crypto::cpu::UnsupportedCpu), } // Dependency errors are flattened to their message so their crates stay out of this crate's @@ -243,11 +243,6 @@ impl Error { pub(crate) fn crypto(err: impl std::error::Error) -> Self { Self::Crypto(message(err)) } - - /// Carries rind's message rather than its type, so rind stays out of this crate's API. - pub(crate) fn unsupported_cpu(err: rind::cpu::MissingFeature) -> Self { - Self::UnsupportedCpu(err.to_string()) - } } #[cfg(feature = "client")] diff --git a/rs/moq-crypto/Cargo.toml b/rs/moq-crypto/Cargo.toml index 3a31818d768..f4f10a1b058 100644 --- a/rs/moq-crypto/Cargo.toml +++ b/rs/moq-crypto/Cargo.toml @@ -22,10 +22,11 @@ default = ["sign", "e2ee"] # Per-frame signing: `sign::SecretKey` and the signed broadcast wrappers. sign = ["dep:bytes", "dep:kio", "dep:moq-net", "dep:rind", "dep:zeroize"] # End-to-end encryption: the `e2ee` module. -e2ee = ["dep:base64", "dep:bytes", "dep:kio", "dep:moq-net", "dep:rind", "dep:uuid", "dep:zeroize"] -# rind's rustls provider and CPU check, with the `UnsupportedCpu` error the transport crates -# share. Needs neither `moq-net` nor the other features, so moq-quic and moq-tokio can use it. -provider = ["dep:rind", "dep:rind-rustls", "dep:rustls"] +e2ee = ["cpu", "dep:base64", "dep:bytes", "dep:kio", "dep:moq-net", "dep:rind", "dep:uuid", "dep:zeroize"] +# CPU support and its shared error need only rind. +cpu = ["dep:rind"] +# The rustls provider adds TLS without needing `moq-net`. +provider = ["cpu", "dep:rind-rustls", "dep:rustls"] # `sign::PublicKey` serializes as its canonical z-base-32 text. serde = ["dep:serde"] # Generated async wrappers for the `sign` and `e2ee` poll methods. Enable where you `.await` them. diff --git a/rs/moq-crypto/MIGRATE.md b/rs/moq-crypto/MIGRATE.md index 29cac30e93f..5acd000a297 100644 --- a/rs/moq-crypto/MIGRATE.md +++ b/rs/moq-crypto/MIGRATE.md @@ -4,6 +4,10 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Shared unsupported CPU error + +`e2ee::Error::Unsupported(String)` is now `UnsupportedCpu(cpu::UnsupportedCpu)`. The shared `UnsupportedCpu` type and `check()` move from `provider` to `cpu`, enabled by the new `cpu` feature and by `e2ee` and `provider`. `cpu` needs only rind; `provider` adds rustls. + ### Async wrappers are opt-in Enable the `async` Cargo feature to keep awaiting `read_frame`, `recv_group`, `recv`, diff --git a/rs/moq-crypto/README.md b/rs/moq-crypto/README.md index a62659ee8fd..a2a371df1d9 100644 --- a/rs/moq-crypto/README.md +++ b/rs/moq-crypto/README.md @@ -6,32 +6,32 @@ Cryptography for [Media over QUIC](https://moq.dev): the `sign` module signs eve relays cannot forge it, and the `e2ee` module encrypts groups, datagrams, and track names so relays cannot read them. Both wrap `moq-net` and check timestamps with its `track::Info::rescale`, so a frame either half accepts is one `moq-net` accepts. The `provider` -module is the [rind](https://github.com/moq-dev/rind) rustls provider and CPU check that the -MoQ transport crates share. +module is the [rind](https://github.com/moq-dev/rind) rustls provider; `cpu` holds the CPU +check and error that the MoQ crates share. ## Features `sign` and `e2ee`, both default, enable the two modules. With default features off, the crate is only `sign::PublicKey`, the endpoint ID, with its canonical z-base-32 text: it builds without -`moq-net` or rind, for crates such as `moq-auth` that name endpoints but sign nothing. -`serde` adds the key's string serialization. `provider`, off by default, enables the `provider` -module; it depends only on rind and rustls, never on `moq-net`, so the transport crates can -use it without a dependency cycle. +`moq-net` or rind, for crates that only name endpoints. +`serde` adds the key's string serialization. `cpu`, enabled by `e2ee` and `provider`, adds +only rind. `provider`, off by default, adds the rustls integration without `moq-net`, so +transport crates can use it without a dependency cycle. ## Provider MoQ runs all of its cryptography on rind. Its primitives panic on a CPU missing a feature rind -requires, so the `provider` module refuses such a CPU up front. Today that is NEON on aarch64; +requires, so the `cpu` module refuses such a CPU up front. Today that is NEON on aarch64; every `x86_64` CPU and armv7 are supported, and a CPU without AES or other crypto extensions runs rind's slower paths rather than being refused: -- `provider::check()` returns `UnsupportedCpu`, naming the missing feature. +- `cpu::check()` returns `cpu::UnsupportedCpu`, naming the missing feature. - `provider::provider()` returns rind's rustls `CryptoProvider`, or that error. It ignores the process default, so TLS works whether or not one was installed. - `provider::install_default()` installs rind as rustls' process default for libraries such as reqwest that read it, leaving a provider the process already installed in place. -moq-quic, moq-tokio, qmux, and moq-uring report the same `UnsupportedCpu`, and +moq-auth, moq-hls, e2ee, moq-rtmp, and the transports report the same `cpu::UnsupportedCpu`, and `moq_tokio::crypto` re-exports this module's API. ## Signing diff --git a/rs/moq-crypto/src/cpu.rs b/rs/moq-crypto/src/cpu.rs new file mode 100644 index 00000000000..98ba51451f9 --- /dev/null +++ b/rs/moq-crypto/src/cpu.rs @@ -0,0 +1,13 @@ +//! CPU support for rind cryptography, without a TLS dependency. + +/// This CPU lacks a feature that rind requires, named in the message. +#[derive(Clone, Copy, Debug, PartialEq, Eq, thiserror::Error)] +#[error("unsupported CPU: {0}")] +pub struct UnsupportedCpu(pub(crate) rind::cpu::MissingFeature); + +/// Refuse a CPU that rind cannot run on, naming the missing feature. +/// +/// Call this before using rind's primitives directly; the rustls provider checks it too. +pub fn check() -> Result<(), UnsupportedCpu> { + rind::cpu::check().map_err(UnsupportedCpu) +} diff --git a/rs/moq-crypto/src/e2ee/credential.rs b/rs/moq-crypto/src/e2ee/credential.rs index 59d2303e851..b6bd4dc6ab1 100644 --- a/rs/moq-crypto/src/e2ee/credential.rs +++ b/rs/moq-crypto/src/e2ee/credential.rs @@ -10,7 +10,7 @@ use rind::hkdf; use zeroize::{Zeroize, ZeroizeOnDrop}; use crate::e2ee::Epoch; -use crate::e2ee::error::{Error, Result}; +use crate::e2ee::error::Result; use crate::e2ee::generation; use crate::e2ee::limits::{PATH_LABEL, PATH_LEN, PROFILE, SECRET_LEN, check_bytes, check_u53}; @@ -54,10 +54,10 @@ impl Credential { /// /// # Errors /// - /// [`Error::Unsupported`] if this CPU lacks a feature the crypto needs. - /// [`Error::Identity`] if `context` exceeds 65535 bytes or `kid` exceeds `2^53-1`. + /// [`Error::UnsupportedCpu`](crate::e2ee::Error::UnsupportedCpu) if this CPU lacks a feature the crypto needs. + /// [`Error::Identity`](crate::e2ee::Error::Identity) if `context` exceeds 65535 bytes or `kid` exceeds `2^53-1`. pub fn new(config: Config) -> Result { - rind::cpu::check().map_err(|missing| Error::Unsupported(missing.to_string()))?; + crate::cpu::check()?; check_bytes(config.context.len())?; check_u53(config.kid)?; let secret = Secret(config.secret); @@ -84,7 +84,7 @@ impl Credential { /// /// # Errors /// - /// [`Error::Identity`] if `semantic` exceeds 65535 bytes. + /// [`Error::Identity`](crate::e2ee::Error::Identity) if `semantic` exceeds 65535 bytes. pub fn path(&self, semantic: &str) -> Result { let material: [u8; PATH_LEN] = self.expand(&self.path_info(semantic)?); // A fixed-length encoding, far under the path limit. diff --git a/rs/moq-crypto/src/e2ee/error.rs b/rs/moq-crypto/src/e2ee/error.rs index 81c87068898..9810d0116f0 100644 --- a/rs/moq-crypto/src/e2ee/error.rs +++ b/rs/moq-crypto/src/e2ee/error.rs @@ -1,6 +1,6 @@ /// Typed failures from [draft-lcurley-moq-e2ee](https://datatracker.ietf.org/doc/draft-lcurley-moq-e2ee/). /// -/// Display is the profile code. Secrets, keys, and plaintext never appear here. +/// Display is the profile code or the CPU refusal. Secrets, keys, and plaintext never appear here. #[derive(thiserror::Error, Debug, Clone)] #[non_exhaustive] pub enum Error { @@ -25,8 +25,8 @@ pub enum Error { Authentication, /// This CPU lacks an instruction set extension the crypto requires; the message names it. - #[error("unsupported: {0}")] - Unsupported(String), + #[error(transparent)] + UnsupportedCpu(#[from] crate::cpu::UnsupportedCpu), /// The underlying MoQ track failed. #[error(transparent)] diff --git a/rs/moq-crypto/src/lib.rs b/rs/moq-crypto/src/lib.rs index 605bd3b4285..03541f831cc 100644 --- a/rs/moq-crypto/src/lib.rs +++ b/rs/moq-crypto/src/lib.rs @@ -4,12 +4,13 @@ //! forging it. [`e2ee`] encrypts groups, datagrams, and track names so a relay forwards //! ciphertext it cannot read. Both wrap `moq-net` and check a frame's timestamp with //! `moq_net::track::Info::rescale`, so neither accepts a frame the net track would refuse. -//! [`provider`] is rind's rustls provider and CPU check, with the [`provider::UnsupportedCpu`] +//! [`provider`] is rind's rustls provider; [`cpu`] holds the CPU check and [`cpu::UnsupportedCpu`] //! error that moq-quic, moq-tokio, and the other transport crates report. //! //! The `sign` and `e2ee` features, both default, gate those halves; `provider`, off by default, -//! gates the provider and needs no `moq-net`. Without any of them the crate holds only -//! [`sign::PublicKey`], the endpoint ID, and its canonical z-base-32 text, with no `moq-net` +//! gates the rustls provider and enables `cpu`, which needs only rind. Without any of these +//! features the crate holds only [`sign::PublicKey`], the endpoint ID, and its canonical +//! z-base-32 text, with no `moq-net` //! or crypto backend; `serde` adds its string serialization. //! //! The `poll_*` methods are always available. Enable the `async` feature for their generated @@ -17,6 +18,8 @@ #![warn(missing_docs)] +#[cfg(feature = "cpu")] +pub mod cpu; #[cfg(feature = "e2ee")] pub mod e2ee; #[cfg(feature = "provider")] diff --git a/rs/moq-crypto/src/provider.rs b/rs/moq-crypto/src/provider.rs index 557432825cf..80bdbfe2849 100644 --- a/rs/moq-crypto/src/provider.rs +++ b/rs/moq-crypto/src/provider.rs @@ -1,27 +1,16 @@ -//! rind, MoQ's one cryptography provider: the CPU check and its rustls provider. +//! rind's rustls cryptography provider. //! //! rind's primitives panic on a CPU missing a feature they require, so each entry point -//! here refuses such a CPU with [`UnsupportedCpu`] instead. The transport crates report -//! this one type, and rind stays out of their public APIs. +//! here refuses such a CPU with [`crate::cpu::UnsupportedCpu`] instead. The [`crate::cpu`] +//! module owns the shared error reported by transport crates, keeping rind out of their APIs. use std::sync::{Arc, OnceLock}; +use crate::cpu::UnsupportedCpu; + /// A shared rustls crypto provider. pub type Provider = Arc; -/// This CPU lacks a feature that rind requires, named in the message. -#[derive(Clone, Copy, Debug, PartialEq, Eq, thiserror::Error)] -#[error("unsupported CPU: {0}")] -pub struct UnsupportedCpu(rind::cpu::MissingFeature); - -/// Refuse a CPU that rind cannot run on, naming the missing feature. -/// -/// Call this before using rind's primitives directly; [`provider`] and -/// [`install_default`] run it themselves. -pub fn check() -> Result<(), UnsupportedCpu> { - rind::cpu::check().map_err(UnsupportedCpu) -} - /// Return rind's rustls provider, refusing a CPU missing a required feature. /// /// The process default is not consulted, so TLS works whether or not one was installed. @@ -51,7 +40,7 @@ mod tests { // The test hosts run rind, so the provider builds and every call returns the same one. let first = provider().unwrap(); assert!(Arc::ptr_eq(&first, &provider().unwrap())); - check().unwrap(); + crate::cpu::check().unwrap(); install_default().unwrap(); // A second install keeps the first provider and still succeeds. install_default().unwrap(); diff --git a/rs/moq-hls/Cargo.toml b/rs/moq-hls/Cargo.toml index 8e85e323b2d..0b72c392f72 100644 --- a/rs/moq-hls/Cargo.toml +++ b/rs/moq-hls/Cargo.toml @@ -15,7 +15,7 @@ categories = ["multimedia", "network-programming", "web-programming"] [features] default = ["server"] # The import and export gateways, which drive HTTP fetches and background watchers as async code. -async = ["kio/async", "moq-mux/async"] +async = ["kio/async", "moq-mux/async", "moq-crypto/provider"] server = ["async", "dep:axum", "dep:http-body"] [dependencies] @@ -27,14 +27,13 @@ http-body = { workspace = true, optional = true } humantime = { workspace = true } kio = { workspace = true, features = ["runtime"] } m3u8-rs = "6" +moq-crypto = { workspace = true, features = ["cpu"] } moq-mux = { workspace = true } moq-net = { workspace = true } percent-encoding = { workspace = true } rand = { workspace = true } reqwest = { workspace = true, features = ["rustls-no-provider", "gzip"] } rind = { workspace = true } -# Installed as rustls's process default when the host installed none, since reqwest reads it. -rind-rustls = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } thiserror = { workspace = true } diff --git a/rs/moq-hls/MIGRATE.md b/rs/moq-hls/MIGRATE.md index 8e9466626ad..1022062e3d6 100644 --- a/rs/moq-hls/MIGRATE.md +++ b/rs/moq-hls/MIGRATE.md @@ -4,6 +4,10 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Shared unsupported CPU error + +`Error::UnsupportedCpu` now carries `moq_crypto::cpu::UnsupportedCpu` instead of a `String`. Use its `Display` implementation for the missing feature message. + ### Media indexing counts toward no stats session A `Broadcaster` subscribes to each rendition's media to index it, and those subscriptions diff --git a/rs/moq-hls/src/error.rs b/rs/moq-hls/src/error.rs index ed216837467..a3c84220db8 100644 --- a/rs/moq-hls/src/error.rs +++ b/rs/moq-hls/src/error.rs @@ -179,17 +179,11 @@ pub enum Error { }, /// This CPU lacks a feature the crate's cryptography requires, named in rind's message. - #[error("unsupported CPU: {0}")] - UnsupportedCpu(String), + #[error(transparent)] + UnsupportedCpu(#[from] moq_crypto::cpu::UnsupportedCpu), } impl Error { - /// Carries rind's message rather than its type, so rind stays out of this crate's API. - #[cfg(feature = "async")] - pub(crate) fn unsupported_cpu(err: rind::cpu::MissingFeature) -> Self { - Self::UnsupportedCpu(err.to_string()) - } - /// The HTTP status the origin answered with, if it answered with one at all. /// /// The import loop consults it: a `503` on a playlist fetch is worth another pass, a `404` is @@ -263,9 +257,7 @@ mod tests { drop(listener); // reqwest reads rustls's process default, as the importer installs it. - let _ = rind_rustls::default_provider() - .expect("supported CPU") - .install_default(); + moq_crypto::provider::install_default().expect("supported CPU"); let err: Error = reqwest::get(format!("http://user:pass@{address}/media.m3u8?jwt=secret")) .await .expect_err("dial a closed port") diff --git a/rs/moq-hls/src/export/mod.rs b/rs/moq-hls/src/export/mod.rs index 2641afdbe69..0d9de315d34 100644 --- a/rs/moq-hls/src/export/mod.rs +++ b/rs/moq-hls/src/export/mod.rs @@ -144,7 +144,7 @@ impl Broadcaster { /// Fails with [`Error::UnsupportedCpu`](crate::Error::UnsupportedCpu) on a CPU its /// cryptography cannot run on. pub fn new(source: moq_mux::Source, config: Config) -> crate::Result<(Self, Driver)> { - rind::cpu::check().map_err(crate::Error::unsupported_cpu)?; + moq_crypto::cpu::check()?; Ok(Self::start(source, config, None)) } diff --git a/rs/moq-hls/src/import.rs b/rs/moq-hls/src/import.rs index f0215dc4de7..8a4332d69ac 100644 --- a/rs/moq-hls/src/import.rs +++ b/rs/moq-hls/src/import.rs @@ -218,9 +218,7 @@ impl Fetcher { // reqwest reads rustls's process default and panics without one, so install rind's // unless the host already chose a provider. - let _ = rind_rustls::default_provider() - .map_err(Error::unsupported_cpu)? - .install_default(); + moq_crypto::provider::install_default()?; let client = Client::builder() .user_agent(concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"))) diff --git a/rs/moq-hls/src/lib.rs b/rs/moq-hls/src/lib.rs index 96189b3ed9b..84b384d5879 100644 --- a/rs/moq-hls/src/lib.rs +++ b/rs/moq-hls/src/lib.rs @@ -19,7 +19,7 @@ //! record-driven playlist window, and the HTTP surface. //! //! Its cryptography is [rind](https://docs.rs/rind), so every constructor that first needs it -//! refuses a CPU missing a feature rind requires with [`Error::UnsupportedCpu`]. +//! refuses a CPU missing a feature rind requires with [`Error::UnsupportedCpu`], carrying [`moq_crypto::cpu::UnsupportedCpu`]. //! //! The gateway drives its HTTP fetches and background watchers as async code, so [`import`] and //! [`export`] need the `async` feature. The default `server` feature enables it. diff --git a/rs/moq-hls/src/server/mod.rs b/rs/moq-hls/src/server/mod.rs index e4596bba323..4d69ca8f525 100644 --- a/rs/moq-hls/src/server/mod.rs +++ b/rs/moq-hls/src/server/mod.rs @@ -185,7 +185,7 @@ impl Server { /// cryptography cannot run on. pub fn new(origin: moq_net::origin::Consumer, config: Config) -> crate::Result { // Checked once here, so each broadcaster it serves starts without failing. - rind::cpu::check().map_err(crate::Error::unsupported_cpu)?; + moq_crypto::cpu::check()?; Ok(Self { inner: Arc::new(Inner { _watch: origin.clone().with_hidden(true).announced(), diff --git a/rs/moq-quic/MIGRATE.md b/rs/moq-quic/MIGRATE.md index 6d6f34df16a..6efd72b6225 100644 --- a/rs/moq-quic/MIGRATE.md +++ b/rs/moq-quic/MIGRATE.md @@ -15,13 +15,13 @@ moq-quic draws it from the connection's rng, so `endpoint::Config::rng_seed` now Remove the `ring`, `aws-lc-rs`, and `rustls-aws-lc-rs` Cargo features. rind is always enabled. Build caller-supplied rustls configurations on `moq_crypto::provider::provider()?` (enable moq-crypto's `provider` feature) or `moq_tokio::crypto::provider()?`. -A CPU missing a feature rind needs is reported as `moq_crypto::provider::UnsupportedCpu`, which names the feature: +A CPU missing a feature rind needs is reported as `moq_crypto::cpu::UnsupportedCpu`, which names the feature: - Endpoint initialization returns `ConfigError::UnsupportedCpu`. - `client::Config::with_root_certificates` now returns `rustls::Error` instead of `VerifierBuilderError`. Both the CPU refusal and a verifier builder failure arrive in `rustls::Error::Other`; downcast its inner error to `UnsupportedCpu` or `rustls::client::VerifierBuilderError`. - `server::Config::with_single_cert` keeps its `rustls::Error` and reports the CPU refusal the same way, where it used to panic. -Call `moq_crypto::provider::check()` before calling rind's primitives directly. +Call `moq_crypto::cpu::check()` before calling rind's primitives directly. QUIC packet protection, Retry integrity, reset tokens, and address-validation tokens keep their wire formats and derivation labels. diff --git a/rs/moq-quic/src/config/client.rs b/rs/moq-quic/src/config/client.rs index 3cf1001a9fd..944910ec20e 100644 --- a/rs/moq-quic/src/config/client.rs +++ b/rs/moq-quic/src/config/client.rs @@ -60,7 +60,7 @@ impl Config { /// /// A CPU that rind cannot run on, and a root store the verifier refuses, both arrive in /// [`rustls::Error::Other`]: downcast it to - /// [`UnsupportedCpu`](moq_crypto::provider::UnsupportedCpu) or + /// [`UnsupportedCpu`](moq_crypto::cpu::UnsupportedCpu) or /// [`VerifierBuilderError`](rustls::client::VerifierBuilderError). pub fn with_root_certificates(roots: Arc) -> Result { let provider = provider()?; diff --git a/rs/moq-quic/src/config/endpoint.rs b/rs/moq-quic/src/config/endpoint.rs index 51233fe7d30..22e12682e45 100644 --- a/rs/moq-quic/src/config/endpoint.rs +++ b/rs/moq-quic/src/config/endpoint.rs @@ -119,7 +119,7 @@ impl Config { use crate::cid_generator::HashedConnectionIdGenerator; self.validate()?; - moq_crypto::provider::check()?; + moq_crypto::cpu::check()?; let (reset_key, cid_key, min_reset_interval): (Arc, _, _) = match &self.reset_secret { Some(secret) => { diff --git a/rs/moq-quic/src/config/mod.rs b/rs/moq-quic/src/config/mod.rs index 174dbb92677..5ac99901603 100644 --- a/rs/moq-quic/src/config/mod.rs +++ b/rs/moq-quic/src/config/mod.rs @@ -25,5 +25,5 @@ pub enum ConfigError { MaxUdpPayloadSize, /// This CPU lacks a feature that rind, the transport's cryptography, requires #[error(transparent)] - UnsupportedCpu(#[from] moq_crypto::provider::UnsupportedCpu), + UnsupportedCpu(#[from] moq_crypto::cpu::UnsupportedCpu), } diff --git a/rs/moq-quic/src/config/server/mod.rs b/rs/moq-quic/src/config/server/mod.rs index 61afb2643f9..ddb660a40e3 100644 --- a/rs/moq-quic/src/config/server/mod.rs +++ b/rs/moq-quic/src/config/server/mod.rs @@ -125,7 +125,7 @@ impl Config { /// Present `cert_chain`, signed for by `key`, with the default settings /// /// A CPU that rind cannot run on arrives in [`rustls::Error::Other`]: downcast it to - /// [`UnsupportedCpu`](moq_crypto::provider::UnsupportedCpu). + /// [`UnsupportedCpu`](moq_crypto::cpu::UnsupportedCpu). pub fn with_single_cert( cert_chain: Vec>, key: PrivateKeyDer<'static>, diff --git a/rs/moq-quic/src/crypto/rustls.rs b/rs/moq-quic/src/crypto/rustls.rs index 0ec294af475..39659d58c2f 100644 --- a/rs/moq-quic/src/crypto/rustls.rs +++ b/rs/moq-quic/src/crypto/rustls.rs @@ -375,7 +375,7 @@ fn no_initial_suite() -> rustls::Error { /// /// The convenience constructors return rustls errors already; the refusal stays typed inside /// [`rustls::Error::Other`], so a caller can downcast it to -/// [`UnsupportedCpu`](moq_crypto::provider::UnsupportedCpu). +/// [`UnsupportedCpu`](moq_crypto::cpu::UnsupportedCpu). pub(crate) fn provider() -> Result, rustls::Error> { moq_crypto::provider::provider().map_err(|err| rustls::Error::Other(rustls::OtherError(Arc::new(err)))) } diff --git a/rs/moq-rtmp/Cargo.toml b/rs/moq-rtmp/Cargo.toml index cb9df64851c..e8241e44006 100644 --- a/rs/moq-rtmp/Cargo.toml +++ b/rs/moq-rtmp/Cargo.toml @@ -38,6 +38,7 @@ bytes = { workspace = true } futures = { workspace = true } hang = { workspace = true } kio = { workspace = true, features = ["runtime"] } +moq-crypto = { workspace = true, features = ["cpu"] } moq-mux = { workspace = true, features = ["async"] } moq-net = { workspace = true } rand = { workspace = true } diff --git a/rs/moq-rtmp/MIGRATE.md b/rs/moq-rtmp/MIGRATE.md index 9d92d21446b..3e3aca40108 100644 --- a/rs/moq-rtmp/MIGRATE.md +++ b/rs/moq-rtmp/MIGRATE.md @@ -4,9 +4,13 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Shared unsupported CPU error + +CPU refusals now return `Error::UnsupportedCpu(moq_crypto::cpu::UnsupportedCpu)` from listener, stream acceptance, and dial setup instead of an I/O or session error. + ### Handshake cryptography uses rind -RTMP handshake HMAC-SHA256 uses rind. `Server::bind` checks CPU support before binding; every stream handshake also checks before using crypto, including `accept_stream` and the dial client. +RTMP handshake HMAC-SHA256 uses rind. `Server::bind` checks CPU support before binding; `accept_stream` and the dial client also check at setup, before using crypto. The `tls` feature no longer selects rustls' aws-lc provider; build the supplied TLS configuration with `rind_rustls::default_provider()?` or `moq_tokio::tls::Listen::server_config`. RTMP and RTMPS wire formats are unchanged. diff --git a/rs/moq-rtmp/src/dial.rs b/rs/moq-rtmp/src/dial.rs index 02bdfeee304..d7d2b63e277 100644 --- a/rs/moq-rtmp/src/dial.rs +++ b/rs/moq-rtmp/src/dial.rs @@ -88,6 +88,7 @@ impl Client { /// For `rtmps://` or any other transport, establish the stream yourself and use /// [`with_stream`](Self::with_stream) instead. pub async fn connect(addr: SocketAddr, app: &str) -> Result { + moq_crypto::cpu::check()?; kio::clock::timeout(crate::server::REQUEST_TIMEOUT, async { let stream = TcpStream::connect(addr).await?; crate::server::configure_socket(&stream, addr); @@ -107,6 +108,7 @@ impl Client { /// The bring-your-own-transport entry point: establish the connection (and, for /// `rtmps://`, the TLS handshake) yourself, then hand the stream here. pub async fn with_stream(stream: S, app: &str) -> Result { + moq_crypto::cpu::check()?; kio::clock::timeout( crate::server::REQUEST_TIMEOUT, Self::with_stream_config(stream, app, None), @@ -548,7 +550,7 @@ fn is_status_failure(code: &str) -> bool { /// handshake read can also carry the first RTMP chunks, so those `remaining_bytes` /// must be fed to the session or chunk parsing desyncs. async fn client_handshake(stream: &mut S) -> anyhow::Result> { - let mut handshake = Handshake::new(PeerType::Client)?; + let mut handshake = Handshake::new(PeerType::Client); let p0_p1 = handshake .generate_outbound_p0_and_p1() .map_err(|e| anyhow::anyhow!("rtmp handshake p0/p1: {e:?}"))?; diff --git a/rs/moq-rtmp/src/error.rs b/rs/moq-rtmp/src/error.rs index 9f0f691b074..d36954d63d9 100644 --- a/rs/moq-rtmp/src/error.rs +++ b/rs/moq-rtmp/src/error.rs @@ -14,6 +14,10 @@ pub enum Error { #[error("io: {0}")] Io(Arc), + /// This CPU lacks a feature that rind requires. + #[error(transparent)] + UnsupportedCpu(#[from] moq_crypto::cpu::UnsupportedCpu), + /// The RTMP handshake or session state machine failed. #[error("rtmp session: {0}")] Session(String), diff --git a/rs/moq-rtmp/src/rml/handshake/mod.rs b/rs/moq-rtmp/src/rml/handshake/mod.rs index d0730d55d51..5c6cbd427bf 100644 --- a/rs/moq-rtmp/src/rml/handshake/mod.rs +++ b/rs/moq-rtmp/src/rml/handshake/mod.rs @@ -107,8 +107,8 @@ enum Stage { /// ```ignore /// use rml_rtmp::handshake::{Handshake, PeerType, HandshakeProcessResult}; /// -/// let mut client = Handshake::new(PeerType::Client).unwrap(); -/// let mut server = Handshake::new(PeerType::Server).unwrap(); +/// let mut client = Handshake::new(PeerType::Client); +/// let mut server = Handshake::new(PeerType::Server); /// /// let c0_and_c1 = client.generate_outbound_p0_and_p1().unwrap(); /// let s0_s1_and_s2 = match server.process_bytes(&c0_and_c1[..]) { @@ -148,16 +148,15 @@ impl Handshake { /// The Flash Player 9 handshake requires generating a different packet 1 depending if you /// are the client or the server, and thus this must be specified when creating a new /// `Handshake` instance. - pub fn new(peer_type: PeerType) -> Result { - rind::cpu::check().map_err(std::io::Error::other)?; - Ok(Handshake { + pub fn new(peer_type: PeerType) -> Self { + Self { current_stage: Stage::NeedToSendP0AndP1, command_byte: 0_u8, input_buffer: Vec::with_capacity(RTMP_PACKET_SIZE), sent_p1: [0_u8; RTMP_PACKET_SIZE], peer_type, sent_digest: [0_u8; SHA256_DIGEST_LENGTH], - }) + } } /// Creates the packets 0 and 1 that should get sent to the peer. This is only strictly @@ -624,7 +623,7 @@ mod tests { #[test] fn bad_version_if_first_byte_is_not_a_3() { - let mut handshake = Handshake::new(PeerType::Server).unwrap(); + let mut handshake = Handshake::new(PeerType::Server); let input = [4_u8]; match handshake.process_bytes(&input) { @@ -636,7 +635,7 @@ mod tests { #[test] fn can_accept_jw_player_example_p0_and_p1() { - let mut handshake = Handshake::new(PeerType::Server).unwrap(); + let mut handshake = Handshake::new(PeerType::Server); let s0_and_s1 = match handshake.generate_outbound_p0_and_p1() { Err(x) => panic!("Unexpected error: {:?}", x), Ok(x) => x, @@ -684,7 +683,7 @@ mod tests { c0_and_c1[0] = 3; fill_with_random_data(&mut c0_and_c1[9..RTMP_PACKET_SIZE + 1]); - let mut handshake = Handshake::new(PeerType::Server).unwrap(); + let mut handshake = Handshake::new(PeerType::Server); let s0_and_s1 = match handshake.generate_outbound_p0_and_p1() { Err(x) => panic!("Unexpected error: {:?}", x), Ok(x) => x, @@ -717,8 +716,8 @@ mod tests { // This is the best way to verify we can handle the fp9 handshake method // without reimplementing the exact algorithims for the test. - let mut client = Handshake::new(PeerType::Client).unwrap(); - let mut server = Handshake::new(PeerType::Server).unwrap(); + let mut client = Handshake::new(PeerType::Client); + let mut server = Handshake::new(PeerType::Server); let c0_and_c1 = match client.generate_outbound_p0_and_p1() { Ok(bytes) => bytes, @@ -757,7 +756,7 @@ mod tests { #[test] fn sends_outbound_p0_p1_if_p0_received_and_outbound_p0_and_p1_not_yet_sent() { - let mut handshake = Handshake::new(PeerType::Server).unwrap(); + let mut handshake = Handshake::new(PeerType::Server); let input = [3_u8]; let response = match handshake.process_bytes(&input) { diff --git a/rs/moq-rtmp/src/server.rs b/rs/moq-rtmp/src/server.rs index d61ddb4b68f..d009e1320fa 100644 --- a/rs/moq-rtmp/src/server.rs +++ b/rs/moq-rtmp/src/server.rs @@ -266,7 +266,7 @@ pub struct Server { impl Server { /// Bind an RTMP listener on `addr` (RTMP's well-known port is 1935). pub async fn bind(addr: SocketAddr) -> Result { - rind::cpu::check().map_err(std::io::Error::other)?; + moq_crypto::cpu::check()?; let listener = TcpListener::bind(addr).await?; Ok(Self { @@ -496,6 +496,7 @@ pub fn configure_socket(stream: &TcpStream, peer: SocketAddr) { /// `play`. The handshake must finish in five seconds; wrap the call in /// [`kio::clock::timeout`] to also bound the wait for a publish or play request. pub async fn accept_stream(stream: S, peer: SocketAddr) -> Result>> { + moq_crypto::cpu::check()?; Ok(accept_until_request(stream, peer).await?) } @@ -1470,7 +1471,7 @@ async fn feed_input( /// Perform the RTMP server handshake, returning any leftover bytes that followed /// the client's final handshake packet (the start of the chunk stream). async fn run_handshake(stream: &mut S, peer: SocketAddr) -> anyhow::Result> { - let mut handshake = Handshake::new(PeerType::Server)?; + let mut handshake = Handshake::new(PeerType::Server); let mut buffer = [0u8; 4096]; loop { let n = stream.read(&mut buffer).await?; @@ -1952,7 +1953,7 @@ mod tests { /// The client half of the RTMP handshake, returning the bytes read past it. async fn client_handshake(stream: &mut S) -> Vec { - let mut handshake = Handshake::new(PeerType::Client).unwrap(); + let mut handshake = Handshake::new(PeerType::Client); stream .write_all(&handshake.generate_outbound_p0_and_p1().unwrap()) .await @@ -2033,7 +2034,7 @@ mod tests { media: tokio::sync::mpsc::UnboundedSender, ) { // Handshake. - let mut handshake = Handshake::new(PeerType::Client).unwrap(); + let mut handshake = Handshake::new(PeerType::Client); stream .write_all(&handshake.generate_outbound_p0_and_p1().unwrap()) .await @@ -2121,7 +2122,7 @@ mod tests { None } - let mut handshake = Handshake::new(PeerType::Client).unwrap(); + let mut handshake = Handshake::new(PeerType::Client); stream .write_all(&handshake.generate_outbound_p0_and_p1().unwrap()) .await @@ -2882,7 +2883,7 @@ mod tests { let mut stream = TcpStream::connect(addr).await.unwrap(); // Client handshake. - let mut handshake = Handshake::new(PeerType::Client).unwrap(); + let mut handshake = Handshake::new(PeerType::Client); stream .write_all(&handshake.generate_outbound_p0_and_p1().unwrap()) .await diff --git a/rs/moq-tokio/MIGRATE.md b/rs/moq-tokio/MIGRATE.md index b3e894652a8..21d31f97f36 100644 --- a/rs/moq-tokio/MIGRATE.md +++ b/rs/moq-tokio/MIGRATE.md @@ -25,7 +25,7 @@ Remove the `aws-lc-rs` and `ring` Cargo features. rind is always enabled. The `net` and `driver` features include certificate support, so an RTMPS-only embedder can use `net` without selecting a provider. Self-signed certificates and mDNS/QUIC-LB authentication use rind. Wire formats are unchanged. -`crypto` now re-exports moq-crypto's `provider` module, and a CPU missing a feature rind needs is reported as `crypto::UnsupportedCpu` (`moq_crypto::provider::UnsupportedCpu`), which names the feature: +`crypto` now re-exports moq-crypto's `provider` module, and a CPU missing a feature rind needs is reported as `crypto::UnsupportedCpu` (`moq_crypto::cpu::UnsupportedCpu`), which names the feature: - `crypto::provider()` returns `Result`; add `?`. It always returns rind, independently of rustls' process default. - `crypto::install_default()` returns `Result<(), UnsupportedCpu>` instead of `Result<(), Provider>`. A provider the process already installed is kept and is no longer an error, so replace `let _ = crypto::install_default();` with `crypto::install_default()?;`. diff --git a/rs/moq-tokio/src/crypto.rs b/rs/moq-tokio/src/crypto.rs index e8a46028469..ccddd076807 100644 --- a/rs/moq-tokio/src/crypto.rs +++ b/rs/moq-tokio/src/crypto.rs @@ -2,9 +2,10 @@ //! //! [`provider`] and [`install_default`] refuse a CPU that rind cannot run on with //! [`UnsupportedCpu`], naming the missing feature. This module re-exports -//! `moq_crypto::provider`, so moq-quic, qmux, and moq-uring report the same type. +//! `moq_crypto::cpu` and `moq_crypto::provider`, so moq-quic, qmux, and moq-uring report the same type. -pub use moq_crypto::provider::{Provider, UnsupportedCpu, check, install_default, provider}; +pub use moq_crypto::cpu::{UnsupportedCpu, check}; +pub use moq_crypto::provider::{Provider, install_default, provider}; /// Hash certificate bytes independently of the configured TLS cipher suites. pub(crate) fn sha256(data: &[u8]) -> rind::digest::Digest { diff --git a/rs/moq-uring/MIGRATE.md b/rs/moq-uring/MIGRATE.md index 0f65afd146d..753240bc525 100644 --- a/rs/moq-uring/MIGRATE.md +++ b/rs/moq-uring/MIGRATE.md @@ -11,7 +11,7 @@ How to update your code for each breaking change, newest first. ### Transport cryptography uses rind TLS configuration uses rind's rustls provider, and QUIC reset and token keys use rind through moq-quic. -A CPU missing a feature rind needs fails configuration with `quic::Error::UnsupportedCpu`, wrapping `moq_crypto::provider::UnsupportedCpu`, which names the feature; it used to arrive as `quic::Error::Tls`. +A CPU missing a feature rind needs fails configuration with `quic::Error::UnsupportedCpu`, wrapping `moq_crypto::cpu::UnsupportedCpu`, which names the feature; it used to arrive as `quic::Error::Tls`. Build caller-supplied rustls configurations on `moq_crypto::provider::provider()?` or `moq_tokio::crypto::provider()?`. No wire format changes. diff --git a/rs/moq-uring/src/quic/driver/mod.rs b/rs/moq-uring/src/quic/driver/mod.rs index 6dff4ed3a8a..a4586830e9e 100644 --- a/rs/moq-uring/src/quic/driver/mod.rs +++ b/rs/moq-uring/src/quic/driver/mod.rs @@ -169,7 +169,7 @@ pub(crate) fn client_config(config: &client::Config) -> Result Result { - moq_crypto::provider::check()?; + moq_crypto::cpu::check()?; let mut server = moq_quic::server::Config::new(config.tls.clone()); server.transport = transport_config(&config.transport)?; #[cfg(feature = "qlog")] diff --git a/rs/moq-uring/src/quic/mod.rs b/rs/moq-uring/src/quic/mod.rs index 31e5630828b..b6abab18808 100644 --- a/rs/moq-uring/src/quic/mod.rs +++ b/rs/moq-uring/src/quic/mod.rs @@ -174,7 +174,7 @@ pub enum Error { Tls(String), /// This CPU lacks a feature that rind, MoQ's cryptography, requires. #[error(transparent)] - UnsupportedCpu(#[from] moq_crypto::provider::UnsupportedCpu), + UnsupportedCpu(#[from] moq_crypto::cpu::UnsupportedCpu), /// The socket died underneath the connection. #[error("socket error: {0}")] Io(String), diff --git a/rs/qmux/MIGRATE.md b/rs/qmux/MIGRATE.md index f0470550424..d0bdca1a238 100644 --- a/rs/qmux/MIGRATE.md +++ b/rs/qmux/MIGRATE.md @@ -8,7 +8,7 @@ How to update your code for each breaking change, newest first. Default WSS connections build an explicit rind rustls configuration and use native roots, without relying on a process-wide provider. Build caller-supplied TLS configurations and WSS connectors on `moq_crypto::provider::provider()?` or `moq_tokio::crypto::provider()?`. -A CPU missing a feature rind needs fails TLS connects and default WSS connects with `Error::UnsupportedCpu`, wrapping `moq_crypto::provider::UnsupportedCpu`, which names the feature; it used to arrive as `Error::Io`. +A CPU missing a feature rind needs fails TLS connects and default WSS connects with `Error::UnsupportedCpu`, wrapping `moq_crypto::cpu::UnsupportedCpu`, which names the feature; it used to arrive as `Error::Io`. No QMux or WebSocket wire format changes. ### `RecvStream` leases its credit ([#7624](https://github.com/moq-dev/moq/pull/7624)) diff --git a/rs/qmux/src/error.rs b/rs/qmux/src/error.rs index b1e476387fb..b602ced964b 100644 --- a/rs/qmux/src/error.rs +++ b/rs/qmux/src/error.rs @@ -100,7 +100,7 @@ pub enum Error { /// This CPU lacks a feature that rind, MoQ's cryptography, requires. #[error(transparent)] - UnsupportedCpu(#[from] moq_crypto::provider::UnsupportedCpu), + UnsupportedCpu(#[from] moq_crypto::cpu::UnsupportedCpu), /// The WebSocket failed. #[cfg(feature = "ws")] diff --git a/rs/qmux/src/tls.rs b/rs/qmux/src/tls.rs index 1496b4fca6d..4c7153763c4 100644 --- a/rs/qmux/src/tls.rs +++ b/rs/qmux/src/tls.rs @@ -73,7 +73,7 @@ impl Client { addr: impl ToSocketAddrs, server_name: &str, ) -> Result<(Session, Driver>>), Error> { - moq_crypto::provider::check()?; + moq_crypto::cpu::check()?; let stream = TcpStream::connect(&addr).await?; // Adopt the socket before TLS takes ownership; the kernel's view of the TCP // connection is the same either side of the encryption.