Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Run clippy
run: cargo clippy --all --all-targets
- name: Check docs
run: cargo doc --no-deps -p boring -p boring-sys --features rpk,pq-experimental,underscore-wildcards
run: cargo doc --no-deps -p boring -p boring-sys --features rpk
env:
DOCS_RS: 1
test:
Expand Down Expand Up @@ -357,15 +357,3 @@ jobs:
shell: bash
- run: cargo test --features rpk
name: Run `rpk` tests
- run: cargo test --features pq-experimental
name: Run `pq-experimental` tests
- run: cargo test --features underscore-wildcards
name: Run `underscore-wildcards` tests
- run: cargo test --features pq-experimental,rpk
name: Run `pq-experimental,rpk` tests
- run: cargo test --features pq-experimental,underscore-wildcards
name: Run `pq-experimental,underscore-wildcards` tests
- run: cargo test --features rpk,underscore-wildcards
name: Run `rpk,underscore-wildcards` tests
- run: cargo test --features pq-experimental,rpk,underscore-wildcards
name: Run `pq-experimental,rpk,underscore-wildcards` tests
14 changes: 1 addition & 13 deletions boring-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ include = [
]

[package.metadata.docs.rs]
features = ["rpk", "pq-experimental", "underscore-wildcards"]
features = ["rpk"]
rustdoc-args = ["--cfg", "docsrs"]

[features]
Expand All @@ -56,18 +56,6 @@ fips = []
# Enables Raw public key API (https://datatracker.ietf.org/doc/html/rfc7250)
rpk = []

# Applies a patch (`patches/boring-pq.patch`) to the boringSSL source code that
# enables support for PQ key exchange. This feature is necessary in order to
# compile the bindings for the default branch of boringSSL (`deps/boringssl`).
# Alternatively, a version of boringSSL that implements the same feature set
# can be provided by setting `BORING_BSSL{,_FIPS}_SOURCE_PATH`.
pq-experimental = []

# Applies a patch (`patches/underscore-wildcards.patch`) to enable
# `ffi::X509_CHECK_FLAG_UNDERSCORE_WILDCARDS`. Same caveats as
# those for `pq-experimental` feature apply.
underscore-wildcards = []

[build-dependencies]
bindgen = { workspace = true }
cmake = { workspace = true }
Expand Down
17 changes: 2 additions & 15 deletions boring-sys/build/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ pub(crate) struct Config {

pub(crate) struct Features {
pub(crate) fips: bool,
pub(crate) pq_experimental: bool,
pub(crate) rpk: bool,
pub(crate) underscore_wildcards: bool,
}

pub(crate) struct Env {
Expand Down Expand Up @@ -89,11 +87,7 @@ impl Config {
);
}

let features_with_patches_enabled = self.features.rpk
|| self.features.pq_experimental
|| self.features.underscore_wildcards;

let patches_required = features_with_patches_enabled && !self.env.assume_patched;
let patches_required = self.features.rpk && !self.env.assume_patched;

if is_precompiled_native_lib && patches_required {
println!(
Expand All @@ -106,16 +100,9 @@ impl Config {
impl Features {
fn from_env() -> Self {
let fips = env::var_os("CARGO_FEATURE_FIPS").is_some();
let pq_experimental = env::var_os("CARGO_FEATURE_PQ_EXPERIMENTAL").is_some();
let rpk = env::var_os("CARGO_FEATURE_RPK").is_some();
let underscore_wildcards = env::var_os("CARGO_FEATURE_UNDERSCORE_WILDCARDS").is_some();

Self {
fips,
pq_experimental,
rpk,
underscore_wildcards,
}
Self { fips, rpk }
}

pub(crate) fn is_fips_like(&self) -> bool {
Expand Down
21 changes: 6 additions & 15 deletions boring-sys/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,10 @@ fn ensure_patches_applied(config: &Config) -> io::Result<()> {
native BoringSSL is expected to have the patches included"
);
return Ok(());
} else if config.env.source_path.is_some()
&& (config.features.rpk
|| config.features.pq_experimental
|| config.features.underscore_wildcards)
{
} else if config.env.source_path.is_some() && config.features.rpk {
panic!(
"BORING_BSSL_ASSUME_PATCHED must be set when setting
BORING_BSSL_SOURCE_PATH and using any of the following
features: rpk, pq-experimental, underscore-wildcards"
BORING_BSSL_SOURCE_PATH and using the rpk feature"
);
}

Expand All @@ -456,20 +451,16 @@ fn ensure_patches_applied(config: &Config) -> io::Result<()> {
run_command(Command::new("git").arg("init").current_dir(src_path))?;
}

if config.features.pq_experimental {
println!("cargo:warning=applying experimental post quantum crypto patch to boringssl");
apply_patch(config, "boring-pq.patch")?;
}
println!("cargo:warning=applying experimental post quantum crypto patch to boringssl");
apply_patch(config, "boring-pq.patch")?;

if config.features.rpk {
println!("cargo:warning=applying RPK patch to boringssl");
apply_patch(config, "rpk.patch")?;
}

if config.features.underscore_wildcards {
println!("cargo:warning=applying underscore wildcards patch to boringssl");
apply_patch(config, "underscore-wildcards.patch")?;
}
println!("cargo:warning=applying underscore wildcards patch to boringssl");
apply_patch(config, "underscore-wildcards.patch")?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion boring-sys/patches/boring-pq.patch
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ index d3ea02090..ccb5b3d9b 100644
+ for(i=0;i<len;i++)
+ r |= a[i] ^ b[i];
+
+ return (-(uint64_t)r) >> 63;
+ return (0-(uint64_t)r) >> 63;
+}
+
+/*************************************************
Expand Down
14 changes: 1 addition & 13 deletions boring/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edition = { workspace = true }
rust-version = "1.80"

[package.metadata.docs.rs]
features = ["rpk", "pq-experimental", "underscore-wildcards"]
features = ["rpk"]
rustdoc-args = ["--cfg", "docsrs"]

[features]
Expand All @@ -32,18 +32,6 @@ legacy-compat-deprecated = []
# `BORING_BSSL{,_FIPS}_SOURCE_PATH` and `BORING_BSSL{,_FIPS}_ASSUME_PATCHED`.
rpk = ["boring-sys/rpk"]

# Applies a patch to the boringSSL source code that enables support for PQ key
# exchange. This feature is necessary in order to compile the bindings for the
# default branch of boringSSL. Alternatively, a version of boringSSL that
# implements the same feature set can be provided by setting
# `BORING_BSSL{,_FIPS}_SOURCE_PATH` and `BORING_BSSL{,_FIPS}_ASSUME_PATCHED`.
pq-experimental = ["boring-sys/pq-experimental"]

# Applies a patch to enable
# `ffi::X509_CHECK_FLAG_UNDERSCORE_WILDCARDS`. Same caveats as
# those for `pq-experimental` feature apply.
underscore-wildcards = ["boring-sys/underscore-wildcards"]

[dependencies]
bitflags = { workspace = true }
foreign-types = { workspace = true }
Expand Down
8 changes: 0 additions & 8 deletions boring/src/ssl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,18 +719,14 @@ impl SslCurve {
pub const X25519_KYBER768_DRAFT00: SslCurve =
SslCurve(ffi::SSL_GROUP_X25519_KYBER768_DRAFT00 as _);

#[cfg(feature = "pq-experimental")]
pub const X25519_KYBER768_DRAFT00_OLD: SslCurve =
SslCurve(ffi::SSL_GROUP_X25519_KYBER768_DRAFT00_OLD as _);

#[cfg(feature = "pq-experimental")]
pub const X25519_KYBER512_DRAFT00: SslCurve =
SslCurve(ffi::SSL_GROUP_X25519_KYBER512_DRAFT00 as _);

#[cfg(feature = "pq-experimental")]
pub const P256_KYBER768_DRAFT00: SslCurve = SslCurve(ffi::SSL_GROUP_P256_KYBER768_DRAFT00 as _);

#[cfg(feature = "pq-experimental")]
pub const X25519_MLKEM768: SslCurve = SslCurve(ffi::SSL_GROUP_X25519_MLKEM768 as _);

/// Returns the curve name
Expand Down Expand Up @@ -761,13 +757,9 @@ impl SslCurve {
ffi::SSL_GROUP_SECP521R1 => Some(ffi::NID_secp521r1),
ffi::SSL_GROUP_X25519 => Some(ffi::NID_X25519),
ffi::SSL_GROUP_X25519_KYBER768_DRAFT00 => Some(ffi::NID_X25519Kyber768Draft00),
#[cfg(feature = "pq-experimental")]
ffi::SSL_GROUP_X25519_KYBER768_DRAFT00_OLD => Some(ffi::NID_X25519Kyber768Draft00Old),
#[cfg(feature = "pq-experimental")]
ffi::SSL_GROUP_X25519_KYBER512_DRAFT00 => Some(ffi::NID_X25519Kyber512Draft00),
#[cfg(feature = "pq-experimental")]
ffi::SSL_GROUP_P256_KYBER768_DRAFT00 => Some(ffi::NID_P256Kyber768Draft00),
#[cfg(feature = "pq-experimental")]
ffi::SSL_GROUP_X25519_MLKEM768 => Some(ffi::NID_X25519MLKEM768),
_ => None,
}
Expand Down
1 change: 0 additions & 1 deletion boring/src/ssl/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,6 @@ fn verify_reject_underscore_hostname_with_wildcard() {
client.connect_err();
}

#[cfg(feature = "underscore-wildcards")]
#[test]
fn verify_allow_underscore_hostname_with_wildcard() {
let mut server = Server::builder();
Expand Down
1 change: 0 additions & 1 deletion boring/src/x509/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ bitflags! {
const MULTI_LABEL_WILDCARDS = ffi::X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS as _;
const SINGLE_LABEL_SUBDOMAINS = ffi::X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS as _;
const NEVER_CHECK_SUBJECT = ffi::X509_CHECK_FLAG_NEVER_CHECK_SUBJECT as _;
#[cfg(feature = "underscore-wildcards")]
const UNDERSCORE_WILDCARDS = ffi::X509_CHECK_FLAG_UNDERSCORE_WILDCARDS as _;

#[deprecated(since = "0.10.6", note = "renamed to NO_WILDCARDS")]
Expand Down
5 changes: 1 addition & 4 deletions hyper-boring/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ exclude = ["test/*"]
rust-version = "1.80"

[package.metadata.docs.rs]
features = ["pq-experimental"]
features = []
rustdoc-args = ["--cfg", "docsrs"]

[features]
# Use a FIPS-validated version of boringssl.
fips = ["boring/fips", "tokio-boring/fips"]

# Enables experimental post-quantum crypto (https://blog.cloudflare.com/post-quantum-for-all/)
pq-experimental = ["tokio-boring/pq-experimental"]

[dependencies]
antidote = { workspace = true }
http = { workspace = true }
Expand Down
5 changes: 1 addition & 4 deletions tokio-boring/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ An implementation of SSL streams for Tokio backed by BoringSSL
"""

[package.metadata.docs.rs]
features = ["rpk", "pq-experimental"]
features = ["rpk"]
rustdoc-args = ["--cfg", "docsrs"]

[features]
# Use a FIPS-validated version of boringssl.
fips = ["boring/fips", "boring-sys/fips"]

# Enables experimental post-quantum crypto (https://blog.cloudflare.com/post-quantum-for-all/)
pq-experimental = ["boring/pq-experimental"]

# Enables Raw public key API (https://datatracker.ietf.org/doc/html/rfc7250)
rpk = ["boring/rpk"]

Expand Down
Loading