Skip to content

Commit 121d813

Browse files
committed
Avoid feature unification for bogo
It is no longer possible for rustls-post-quantum and rustls/fips to co-exist. Bleed that fact into bogo's crate features. admin/all-workspace-members is a helper to assist running a command many times for each workspace member, while avoiding unification. Hoist clippy calls into a script for use from CI
1 parent eb2a1c4 commit 121d813

File tree

11 files changed

+728
-30
lines changed

11 files changed

+728
-30
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ jobs:
215215
env:
216216
BOGO_SHIM_PROVIDER: aws-lc-rs-fips
217217

218+
- name: Run test suite (post-quantum)
219+
working-directory: bogo
220+
run: ./runme
221+
env:
222+
BOGO_SHIM_PROVIDER: post-quantum
223+
218224
fuzz:
219225
name: Smoke-test fuzzing targets
220226
runs-on: ubuntu-latest
@@ -430,11 +436,6 @@ jobs:
430436
clippy:
431437
name: Clippy
432438
runs-on: ubuntu-latest
433-
env:
434-
# - we want to be free of any warnings, so deny them
435-
# - disable incompatible_msrv as it does not understand that we apply our
436-
# MSRV to the just the core crate.
437-
CLIPPY_PARAMS: --deny warnings --allow clippy::incompatible_msrv
438439
steps:
439440
- name: Checkout sources
440441
uses: actions/checkout@v4
@@ -449,12 +450,10 @@ jobs:
449450
uses: dtolnay/rust-toolchain@stable
450451
with:
451452
components: clippy
452-
# because examples enable rustls' features, `--workspace --no-default-features` is not
453-
# the same as `--package rustls --no-default-features` so run it separately
454-
- run: cargo clippy --locked --package rustls --no-default-features --all-targets -- $CLIPPY_PARAMS
455-
- run: cargo clippy --locked --workspace --all-features --all-targets -- $CLIPPY_PARAMS
456-
# not part of the workspace
457-
- run: cargo clippy --locked --manifest-path=fuzz/Cargo.toml --all-features --all-targets -- $CLIPPY_PARAMS
453+
# - we want to be free of any warnings, so deny them
454+
# - disable incompatible_msrv as it does not understand that we apply our
455+
# MSRV to the just the core crate.
456+
- run: ./admin/clippy -- --deny warnings --allow clippy::incompatible_msrv
458457

459458
clippy-nightly:
460459
name: Clippy (Nightly)
@@ -473,9 +472,8 @@ jobs:
473472
uses: dtolnay/rust-toolchain@nightly
474473
with:
475474
components: clippy
476-
- run: cargo clippy --locked --package rustls --no-default-features --all-targets
477-
- run: cargo clippy --locked --workspace --all-features --all-targets
478-
- run: cargo clippy --locked --manifest-path=fuzz/Cargo.toml --all-features --all-targets
475+
# do not deny warnings, as nightly clippy sometimes has false negatives
476+
- run: ./admin/clippy
479477

480478
check-external-types:
481479
name: Validate external types appearing in public API
@@ -524,4 +522,3 @@ jobs:
524522
run: cargo test --locked -- --include-ignored
525523
env:
526524
RUST_BACKTRACE: 1
527-

.github/workflows/daily-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
run: cargo run --locked -p rustls-provider-example --example client
130130

131131
- name: Check rustls-post-quantum client
132-
run: cargo run --locked -p rustls-post-quantum --example client | grep 'kex=X25519MLKEM768'
132+
run: cargo run --locked --manifest-path=rustls-post-quantum/Cargo.toml --example client | grep 'kex=X25519MLKEM768'
133133

134134

135135
feature-powerset:

Cargo.lock

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,23 @@ members = [
1414
"provider-example",
1515
# the main library and tests
1616
"rustls",
17-
# experimental post-quantum algorithm support
18-
"rustls-post-quantum",
1917
# rustls cryptography provider integration tests
2018
"rustls-provider-test",
2119
]
20+
21+
## Deliberately not included in `members`:
22+
exclude = [
23+
# `cargo fuzz` integration (requires nightly)
24+
"fuzz",
25+
# experimental post-quantum algorithm support
26+
# (conflicting feature requirements with `rustls`)
27+
"rustls-post-quantum",
28+
]
29+
2230
default-members = [
23-
"bogo",
2431
"examples",
2532
"rustls",
26-
"rustls-post-quantum",
2733
]
28-
exclude = ["admin/rustfmt"]
2934
resolver = "2"
3035

3136
[profile.bench]

admin/all-workspace-members

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python3
2+
3+
"""
4+
Usage: admin/all-workspace-members
5+
6+
Prints the set of all workspace members by package name, suitable
7+
for passing to cargo with the `-p`/`--package` option.
8+
9+
"Workspace members" are computed by cargo, and included as
10+
the `workspace_members` item returned from `cargo metadata`.
11+
See
12+
<https://doc.rust-lang.org/cargo/reference/workspaces.html#the-members-and-exclude-fields>
13+
for documentation on what makes a package a workspace member
14+
or not.
15+
"""
16+
17+
import subprocess
18+
import argparse
19+
import json
20+
21+
22+
def workspace_packages():
23+
js = json.loads(
24+
subprocess.check_output(
25+
["cargo", "metadata", "--no-deps", "--format-version=1"]
26+
)
27+
)
28+
members = js["workspace_members"]
29+
packages = [p for p in js["packages"] if p["id"] in members]
30+
return packages
31+
32+
33+
if __name__ == "__main__":
34+
ap = argparse.ArgumentParser(description=__doc__)
35+
opts = ap.parse_args()
36+
37+
for p in workspace_packages():
38+
print(p["name"])

admin/clippy

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Runs clippy on every package in this repo.
4+
#
5+
# Passes through any extra arguments to each invocation.
6+
#
7+
# Exits non-zero if any clippy invocation exits non-zero,
8+
# but always runs them all.
9+
10+
rc=0
11+
script_args="$@"
12+
13+
function run_clippy() {
14+
if ! ( set -x ; cargo clippy --locked "$@" $script_args ) ; then
15+
rc=$PIPESTATUS
16+
fi
17+
}
18+
19+
# because examples enable rustls' features, `--workspace --no-default-features` is not
20+
# the same as `--package rustls --no-default-features` so run it separately
21+
run_clippy --package rustls --no-default-features --all-targets
22+
23+
# run all workspace members (individually, because we don't want feature unification)
24+
for p in $(admin/all-workspace-members) ; do
25+
# `bogo` is allergic to `--all-features`
26+
if [ "$p" == "bogo" ] ; then
27+
ALL_FEATURES="--features fips"
28+
else
29+
ALL_FEATURES="--all-features"
30+
fi
31+
32+
run_clippy --package $p $ALL_FEATURES --all-targets
33+
done
34+
35+
# not part of the workspace
36+
run_clippy --manifest-path=fuzz/Cargo.toml --all-features --all-targets
37+
run_clippy --manifest-path=rustls-post-quantum/Cargo.toml --all-features --all-targets
38+
39+
exit $rc

bogo/Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,10 @@ edition = "2021"
66
[dependencies]
77
base64 = "0.22"
88
env_logger = "0.10" # 0.11 requires 1.71 MSRV even as a dev-dep (due to manifest features)
9-
rustls = { path = "../rustls", features = ["aws_lc_rs", "fips", "ring", "tls12"] }
10-
rustls-post-quantum = { path = "../rustls-post-quantum" }
9+
rustls = { path = "../rustls", features = ["aws_lc_rs", "ring", "tls12"] }
10+
rustls-post-quantum = { path = "../rustls-post-quantum", optional = true }
11+
12+
[features]
13+
default = []
14+
post-quantum = ["dep:rustls-post-quantum"]
15+
fips = ["rustls/fips"]

bogo/runme

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@
55

66
set -xe
77

8-
cargo run -- -print-rustls-provider
9-
108
case ${BOGO_SHIM_PROVIDER:-aws-lc-rs} in
119
ring)
1210
cpp -P -DRING config.json.in > config.json
11+
cargo run -- -print-rustls-provider
1312
;;
1413
aws-lc-rs)
1514
cpp -P -DAWS_LC_RS config.json.in > config.json
15+
cargo run -- -print-rustls-provider
1616
;;
1717
aws-lc-rs-fips)
1818
cpp -P -DAWS_LC_RS -DFIPS config.json.in > config.json
19+
cargo run --features fips -- -print-rustls-provider
1920
;;
2021
post-quantum)
2122
cpp -P -DAWS_LC_RS -DPOST_QUANTUM config.json.in > config.json
23+
cargo run --features post-quantum -- -print-rustls-provider
2224
;;
2325
existing)
2426
;;

bogo/src/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ use rustls::client::{
1717
};
1818
use rustls::crypto::aws_lc_rs::hpke;
1919
use rustls::crypto::hpke::{Hpke, HpkePublicKey};
20-
use rustls::crypto::{aws_lc_rs, ring, CryptoProvider, SupportedKxGroup};
20+
#[cfg(feature = "post-quantum")]
21+
use rustls::crypto::SupportedKxGroup;
22+
use rustls::crypto::{aws_lc_rs, ring, CryptoProvider};
2123
use rustls::internal::msgs::codec::{Codec, Reader};
2224
use rustls::internal::msgs::handshake::EchConfigPayload;
2325
use rustls::internal::msgs::persist::ServerSessionValue;
@@ -210,7 +212,9 @@ impl Options {
210212
#[derive(Clone, Copy, Debug, PartialEq)]
211213
enum SelectedProvider {
212214
AwsLcRs,
215+
#[cfg_attr(not(feature = "fips"), allow(dead_code))]
213216
AwsLcRsFips,
217+
#[cfg_attr(not(feature = "post-quantum"), allow(dead_code))]
214218
PostQuantum,
215219
Ring,
216220
}
@@ -222,7 +226,9 @@ impl SelectedProvider {
222226
.as_deref()
223227
{
224228
None | Some("aws-lc-rs") => Self::AwsLcRs,
229+
#[cfg(feature = "fips")]
225230
Some("aws-lc-rs-fips") => Self::AwsLcRsFips,
231+
#[cfg(feature = "post-quantum")]
226232
Some("post-quantum") => Self::PostQuantum,
227233
Some("ring") => Self::Ring,
228234
Some(other) => panic!("unrecognised value for BOGO_SHIM_PROVIDER: {other:?}"),
@@ -1535,6 +1541,7 @@ pub fn main() {
15351541
opts.groups.get_or_insert(Vec::new()).push(group);
15361542

15371543
// if X25519MLKEM768 is requested, insert it from rustls_post_quantum
1544+
#[cfg(feature = "post-quantum")]
15381545
if group == rustls_post_quantum::X25519MLKEM768.name() && opts.selected_provider == SelectedProvider::PostQuantum {
15391546
opts.provider.kx_groups.insert(0, &rustls_post_quantum::X25519MLKEM768);
15401547
}
@@ -1552,6 +1559,7 @@ pub fn main() {
15521559
"-install-one-cert-compression-alg" => {
15531560
opts.install_cert_compression_algs = CompressionAlgs::One(args.remove(0).parse::<u16>().unwrap());
15541561
}
1562+
#[cfg(feature = "fips")]
15551563
"-fips-202205" if opts.selected_provider == SelectedProvider::AwsLcRsFips => {
15561564
opts.provider = rustls::crypto::default_fips_provider();
15571565
}

0 commit comments

Comments
 (0)