Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3/3] no-std support phase I #1502

Merged
merged 27 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d24c976
add std feature
japaric Oct 5, 2023
ddc4251
no_std: rm use of `std` in `builder`
pvdrz Dec 6, 2023
39c8f74
no-std: add TimeProvider to ClientConfig
japaric Oct 5, 2023
256e3c7
no-std: remove field from `OtherError`
japaric Oct 5, 2023
388396c
no-std: rm TicketSwitcher
japaric Oct 5, 2023
6b6042a
no-std: add TimeProvider to ServerConfig
japaric Oct 5, 2023
eb7fb3b
no-std: remove ClientSessionMemoryCache
japaric Oct 5, 2023
8504fa6
no-std: rm KeyLogFile
japaric Oct 5, 2023
dd7f37d
no-std: rm Stream*
japaric Oct 5, 2023
b1bb5f2
no-std: rm Connection
pvdrz Dec 19, 2023
91fccea
no-std: rm ServerConnection
japaric Oct 5, 2023
d7853a7
no-std: rm ClientConnection
japaric Oct 5, 2023
bb8b92c
no-std: rm Acceptor
japaric Oct 5, 2023
79826ba
no-std: rm Reader
japaric Oct 5, 2023
e5543dc
no-std: rm Writer
japaric Oct 5, 2023
3b2aec7
no-std: rm PlaintextSink
japaric Oct 5, 2023
73d7780
no-std: rm ConnectionCommon IO methods
japaric Oct 5, 2023
fe8ca37
no-std: rm StdError implementations
japaric Oct 5, 2023
b29cc29
no-std: rm ResolvesServerCertUsingSni
japaric Oct 5, 2023
63c788a
no-std: rm SystemTimeError -> Error conversion
japaric Oct 5, 2023
fb4e967
no-std: rm ServerSessionMemoryCache
japaric Oct 5, 2023
f5ac277
no-std: rm quic::*Connection API
japaric Nov 24, 2023
49dd8f8
no-std: rm MessageDeframer IO methods
japaric Oct 5, 2023
90748ec
no-std: rm temporary extern crate std
japaric Oct 5, 2023
0b5a434
make ring's ticketer module std-only
pvdrz Dec 19, 2023
8805236
crypto: use race::OnceBox for no-std support
cpu Feb 19, 2024
2444558
CI: check that deps are not using libstd API
japaric Nov 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,19 @@ jobs:

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: x86_64-unknown-none

- name: cargo build (debug; default features)
run: cargo build --locked
working-directory: rustls

# this target does _not_ include the libstd crate in its sysroot
# it will catch unwanted usage of libstd in _dependencies_
- name: cargo build (debug; default features; no-std)
run: cargo build --locked --no-default-features --target x86_64-unknown-none
working-directory: rustls

- name: cargo test (debug; default features)
run: cargo test --locked
working-directory: rustls
Expand Down
2 changes: 1 addition & 1 deletion provider-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ p256 = { version = "0.13.2", default-features = false, features = ["alloc", "ecd
pkcs8 = "0.10.2"
pki-types = { package = "rustls-pki-types", version = "1" }
rand_core = { version = "0.6", features = ["getrandom"] }
rustls = { path = "../rustls", default-features = false, features = ["logging", "tls12"] }
rustls = { path = "../rustls", default-features = false, features = ["logging", "std", "tls12"] }
rsa = { version = "0.9", features = ["sha2"], default-features = false }
sha2 = { version = "0.10", default-features = false }
signature = "2"
Expand Down
13 changes: 7 additions & 6 deletions rustls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ rustversion = { version = "1.0.6", optional = true }
aws-lc-rs = { version = "1.6", optional = true, default-features = false, features = ["aws-lc-sys"] }
log = { version = "0.4.4", optional = true }
# remove once our MSRV is >= 1.70
once_cell = "1"
once_cell = { version = "1.16", default-features = false, features = ["alloc", "race"] }
ring = { version = "0.17", optional = true }
subtle = { version = "2.5.0", default-features = false }
webpki = { package = "rustls-webpki", version = "0.102.2", features = ["std"], default-features = false }
pki-types = { package = "rustls-pki-types", version = "1.2", features = ["std"] }
webpki = { package = "rustls-webpki", version = "0.102.2", features = ["alloc"], default-features = false }
pki-types = { package = "rustls-pki-types", version = "1.2", features = ["alloc"] }
zeroize = "1.7"

[features]
default = ["aws_lc_rs", "logging", "tls12"]
default = ["logging", "std", "tls12"]
std = ["aws_lc_rs", "webpki/std", "pki-types/std", "once_cell/std"]
logging = ["log"]
aws_lc_rs = ["dep:aws-lc-rs", "webpki/aws_lc_rs"]
aws_lc_rs = ["dep:aws-lc-rs", "webpki/aws_lc_rs", "std"]
ring = ["dep:ring", "webpki/ring"]
djc marked this conversation as resolved.
Show resolved Hide resolved
tls12 = []
read_buf = ["rustversion"]
read_buf = ["rustversion", "std"]
fips = ["aws_lc_rs", "aws-lc-rs?/fips"]

[dev-dependencies]
Expand Down
6 changes: 5 additions & 1 deletion rustls/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use crate::error::Error;
use crate::time_provider::TimeProvider;
use crate::versions;
use crate::{crypto::CryptoProvider, msgs::handshake::ALL_KEY_EXCHANGE_ALGORITHMS};

use alloc::format;
use alloc::sync::Arc;
use alloc::vec::Vec;
use core::fmt;
use core::marker::PhantomData;
use std::sync::Arc;

#[cfg(doc)]
use crate::{ClientConfig, ServerConfig};
Expand Down Expand Up @@ -184,6 +185,7 @@ impl<Side: ConfigSide, State: fmt::Debug> fmt::Debug for ConfigBuilder<Side, Sta
#[derive(Clone, Debug)]
pub struct WantsVersions {
pub(crate) provider: Arc<CryptoProvider>,
pub(crate) time_provider: Arc<dyn TimeProvider>,
}

impl<S: ConfigSide> ConfigBuilder<S, WantsVersions> {
Expand Down Expand Up @@ -248,6 +250,7 @@ impl<S: ConfigSide> ConfigBuilder<S, WantsVersions> {
state: WantsVerifier {
provider: self.state.provider,
versions: versions::EnabledVersions::new(versions),
time_provider: self.state.time_provider,
},
side: self.side,
})
Expand All @@ -261,6 +264,7 @@ impl<S: ConfigSide> ConfigBuilder<S, WantsVersions> {
pub struct WantsVerifier {
pub(crate) provider: Arc<CryptoProvider>,
pub(crate) versions: versions::EnabledVersions,
pub(crate) time_provider: Arc<dyn TimeProvider>,
}

/// Helper trait to abstract [`ConfigBuilder`] over building a [`ClientConfig`] or [`ServerConfig`].
Expand Down
5 changes: 5 additions & 0 deletions rustls/src/client/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::crypto::CryptoProvider;
use crate::error::Error;
use crate::key_log::NoKeyLog;
use crate::msgs::handshake::CertificateChain;
use crate::time_provider::TimeProvider;
use crate::webpki::{self, WebPkiServerVerifier};
use crate::{verify, versions};

Expand Down Expand Up @@ -56,6 +57,7 @@ impl ConfigBuilder<ClientConfig, WantsVerifier> {
provider: self.state.provider,
versions: self.state.versions,
verifier,
time_provider: self.state.time_provider,
},
side: PhantomData,
}
Expand Down Expand Up @@ -94,6 +96,7 @@ pub(super) mod danger {
provider: self.cfg.state.provider,
versions: self.cfg.state.versions,
verifier,
time_provider: self.cfg.state.time_provider,
},
side: PhantomData,
}
Expand All @@ -110,6 +113,7 @@ pub struct WantsClientCert {
provider: Arc<CryptoProvider>,
versions: versions::EnabledVersions,
verifier: Arc<dyn verify::ServerCertVerifier>,
time_provider: Arc<dyn TimeProvider>,
}

impl ConfigBuilder<ClientConfig, WantsClientCert> {
Expand Down Expand Up @@ -161,6 +165,7 @@ impl ConfigBuilder<ClientConfig, WantsClientCert> {
enable_early_data: false,
#[cfg(feature = "tls12")]
require_ems: cfg!(feature = "fips"),
time_provider: self.state.time_provider,
}
}
}