diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..13ac3fc --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,35 @@ +version: 2 +updates: + - package-ecosystem: "cargo" + # Scan the workspace root; cargo sub-crates are reachable via + # [workspace] members and will be included in the Cargo.lock. + directory: "/" + schedule: + interval: "weekly" + day: "monday" + time: "06:00" + open-pull-requests-limit: 10 + labels: + - "dependencies" + - "cargo" + # Track all dependencies the project depends on, including + # indirect ones. The crate is pre-1.0 so we do not want to + # auto-merge; we want a PR per bump so reviewers can spot + # regressions. + allow: + - dependency-type: "direct" + - dependency-type: "indirect" + groups: + patch: + patterns: + - "*" + update-types: + - "patch" + minor: + patterns: + - "*" + update-types: + - "minor" + commit-message: + prefix: "deps" + include: "scope" diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c9e76a7..0eb901d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,39 +10,89 @@ env: CARGO_TERM_COLOR: always jobs: + msrv: + name: Verify MSRV (1.99.1) + runs-on: [self-hosted, linux, x64] + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust Toolchain (1.99.1) + uses: dtolnay/rust-toolchain@1.99.1 + + - name: Check + run: cargo check --all-features + build_linux: + needs: msrv + name: Build Linux strategy: + fail-fast: false # force all builds to run even if one fails matrix: include: - target: x86_64-unknown-linux-gnu + rust: stable + run-tests: true + - target: aarch64-unknown-linux-gnu + rust: nightly + run-tests: true + - target: riscv64gc-unknown-linux-gnu + rust: nightly + run-tests: true runs-on: [self-hosted, linux, x64] + # The runner image ships the cross std for the aarch64 and riscv64gc + # gnu targets on the nightly toolchain and points CARGO_TARGET_*_LINKER + # at the cross compilers in PATH, so the cross clippy, build, and test + # runs execute nightly with --target while staying on the x64 host. + # Clippy and the build stop at checked and emitted code, so they need + # no target execution; the test run executes foreign-arch binaries, + # and the image points CARGO_TARGET_*_RUNNER at the matching static + # qemu-user emulators, so cargo runs the cross test binaries, the + # doctests included, through them. The fmt check stays on the default + # stable toolchain. steps: - uses: actions/checkout@v4 - name: Install Rust Toolchain + if: matrix.run-tests uses: dtolnay/rust-toolchain@stable with: components: rustfmt, clippy - name: Check Code Format + if: matrix.run-tests run: cargo fmt --all -- --check - name: Code Lint - run: cargo clippy --all-targets --all-features -- -D warnings + if: matrix.run-tests + run: cargo +${{ matrix.rust }} clippy --all-targets --all-features --target ${{ matrix.target }} -- -D warnings - name: Build - run: cargo build --release --all-features + run: cargo +${{ matrix.rust }} build --verbose --all-features --target ${{ matrix.target }} - - name: Run Tests - run: cargo test --verbose # don't run --all-features because it takes waaaay too long + - name: Run tests + if: matrix.run-tests + # The test list enables every feature except the three slow gates, + # so the test jobs stay inside their budgets (docs/ci-test-budget.md). + # Keep the list in sync with the [features] table. Code Lint above + # keeps --all-features, so the gated code stays lint-checked. + run: | + cargo +${{ matrix.rust }} test --verbose --features deprecated,legacy_chacha20_fallback,wasm --target ${{ matrix.target }} build_macos: + needs: msrv + name: Build macOS strategy: + fail-fast: false # force all builds to run even if one fails matrix: include: - target: aarch64-apple-darwin + rust: stable + run-tests: true - target: x86_64-apple-darwin + rust: stable + run-tests: true runs-on: [self-hosted, macos, arm64] steps: @@ -52,48 +102,30 @@ jobs: uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} + components: rustfmt, clippy - - name: Build - run: cargo build --target ${{ matrix.target }} --release --all-features - - msrv: - name: Verify MSRV (1.99) - runs-on: [self-hosted, linux, x64] - - steps: - - uses: actions/checkout@v4 - - - name: Install Rust Toolchain (1.99) - uses: dtolnay/rust-toolchain@1.99.0 - - - name: Check - run: cargo check --all-features - - coverage: - name: Coverage - runs-on: [self-hosted, linux, x64] - - steps: - - uses: actions/checkout@v4 - - - name: Install Rust Toolchain (stable) - uses: dtolnay/rust-toolchain@stable - with: - components: llvm-tools-preview + - name: Check Code Format + if: matrix.run-tests + run: cargo fmt --all -- --check - - name: Install cargo-llvm-cov - run: command -v cargo-llvm-cov >/dev/null 2>&1 || cargo install cargo-llvm-cov + - name: Code Lint + if: matrix.run-tests + run: cargo +${{ matrix.rust }} clippy --all-targets --all-features --target ${{ matrix.target }} -- -D warnings - - name: Run coverage - run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info + - name: Build + run: cargo +${{ matrix.rust }} build --verbose --all-features --target ${{ matrix.target }} - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - with: - files: lcov.info - fail_cl_if_error: false + - name: Run tests + if: matrix.run-tests + # The test list enables every feature except the three slow gates, + # so the test jobs stay inside their budgets (docs/ci-test-budget.md). + # Keep the list in sync with the [features] table. Code Lint above + # keeps --all-features, so the gated code stays lint-checked. + run: | + cargo +${{ matrix.rust }} test --verbose --features deprecated,legacy_chacha20_fallback,wasm --target ${{ matrix.target }} audit: + needs: [build_linux, build_macos] name: Security Audit runs-on: [self-hosted, linux, x64] diff --git a/CHANGELOG.md b/CHANGELOG.md index dde3115..8ab2ab9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,15 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +### Added + +- The `slow-tests-aarch64` and `slow-tests-riscv` features. Each one holds out the tests that push the matching emulated test run past its budget. `slow-tests-aarch64` currently holds out no test. `slow-tests-riscv` holds out 11 tests: the FrodoKEM, RSA, and bcrypt key encryption round trips and the Lamport-Merkle, MAYO5, sntrup Prime, and X25519-FrodoKEM640 round trips. + +### Changed + +- The CI test jobs run `cargo test` with `--features deprecated,legacy_chacha20_fallback,wasm` on top of the default features. The old feature list derivation kept the per-arch gates enabled in every job. The MSRV check, clippy, and the build steps keep `--all-features`, so the gated code stays compile-checked. +- `slow-tests` now holds out only the tests the native test run needs off the run (SLH-DSA, Classic McEliece, XMSS). The emulated-budget tests moved to `slow-tests-riscv`. + ## [3.1.0] - 2026-11-06 ### Added diff --git a/Cargo.toml b/Cargo.toml index 6e5cd7a..fe89208 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,16 +124,26 @@ p521 = [ "ssh-key/rand_core", ] # RSA signing keys. -rsa = ["aead", "dep:getrandom", "dep:pkcs1", "dep:sad-rsa", "dep:sha2"] +rsa = ["aead", "dep:getrandom", "dep:sad-rsa", "dep:sha2"] # secp256k1 ECDSA signing and ECDH sealing keys. secp256k1 = ["aead", "dep:elliptic-curve", "dep:k256"] serde = ["dep:serde", "multi-hash/serde", "multi-sig/serde"] # SLH-DSA (FIPS 205) signing keys. slh-dsa = ["dep:getrandom", "dep:slh-dsa"] -# Tests that take over 60 seconds in debug builds (SLH-DSA, Classic McEliece, -# XMSS). Excluded from the default `cargo test` run; enable with -# `cargo test --features slow-tests` to run the full suite. +# Tests that take over 60 seconds in a native debug build (SLH-DSA, Classic +# McEliece, XMSS). Held out of the standard native test run; the CI test jobs +# never enable this gate. Budget measurements: docs/ci-test-budget.md. Run the +# full suite with `cargo test --features slow-tests`. slow-tests = [] +# Tests slower than 60 s under the emulated qemu-riscv64 debug build but fast +# natively. Held out of the standard emulated riscv64gc run to keep it under +# five minutes. Run the full emulated suite with `--features slow-tests-riscv` +# and the riscv64gc target. +slow-tests-riscv = [] +# The equivalent emulated aarch64 hold-out, keeping the standard emulated +# aarch64 run under five minutes. Enable with `--features slow-tests-aarch64` +# and the aarch64 target. +slow-tests-aarch64 = [] # Streamlined NTRU Prime sealing keys. sntrup = ["aead", "dep:blake3", "dep:sntrup"] # Key splitting into verifiable shares and the threshold marker attributes. @@ -171,13 +181,11 @@ multi-util = "2" p256 = { version = "0.14", features = ["ecdsa", "ecdh"], optional = true } p384 = { version = "0.14", features = ["ecdsa", "ecdh"], optional = true } p521 = { version = "0.14", features = ["ecdsa", "ecdh"], optional = true } -# Compatibility pin. sad-rsa 0.2.3 (the newest release of its line) cannot -# compile against pkcs1 0.8.0-rc.5, which changed `RsaPrivateKey` and -# `RsaPublicKey` from lifetime parameters to generic parameters. sad-rsa -# permits `pkcs1 ^0.8.0-rc.4`, so a fresh resolve picks rc.5 and fails. Pin -# the exact rc.4 dependency to force it; remove this entry once sad-rsa -# publishes a rc.5-compatible release. -pkcs1 = { version = "=0.8.0-rc.4", optional = true } +# sad-rsa 0.10.4 is the rc.5-compatible release the retired compatibility +# pin below waited for; it also fixes RUSTSEC-2026-0583 (panic on crafted +# RSA private keys). Direct dependency on pkcs1 dropped: sad-rsa re-exports +# the pkcs1 traits it needs, so this workspace uses the version resolved +# through sad-rsa. poly1305 = { version = "0.9", optional = true } pq-mayo = { version = "0.6.0", optional = true } pq-mceliece = { version = "0.3", default-features = false, features = ["decapsulate", "encapsulate", "keygen", "mceliece348864"], optional = true } @@ -185,7 +193,7 @@ pq-xmss = { version = "0.2.0", optional = true } rand = "0.10" rand_core = "0.10" rand_core_06 = { package = "rand_core", version = "0.6", features = ["getrandom"], optional = true } -sad-rsa = { version = "0.2.3", features = ["sha2"], optional = true } +sad-rsa = { version = "0.10.4", features = ["sha2"], optional = true } sec1 = { version = "0.8", optional = true } serde = { version = "1.0", default-features = false, features = ["alloc", "derive"], optional = true } serde_cbor_2 = { version = "0.13.0", optional = true } diff --git a/README.md b/README.md index 703109e..226a7cb 100644 --- a/README.md +++ b/README.md @@ -482,7 +482,9 @@ Each algorithm and curve is its own feature, so you compile in only the key type | `secp256k1` | yes | secp256k1 | | `serde` | yes | Serde serialization for `Multikey`, `KeyShare`, `SharePayload`, `ThresholdParticipant` | | `slh-dsa` | yes | SLH-DSA (FIPS 205) | -| `slow-tests` | no | Runs the tests that take over 60 seconds in debug builds (SLH-DSA, Classic McEliece, XMSS) | +| `slow-tests` | no | Runs the tests the native test run holds out to stay on budget (SLH-DSA, Classic McEliece, XMSS). Enable to run the full suite | +| `slow-tests-aarch64` | no | Holds out aarch64 test-run tests if the emulated run reaches its budget. Currently empty because the aarch64 run fits its budget with no test held out | +| `slow-tests-riscv` | no | Holds out the tests that exceed the riscv64 emulated-run budget (FrodoKEM, RSA, bcrypt key encryption, Lamport-Merkle, MAYO5, sntrup Prime, X25519-FrodoKEM640). Enable to run the full emulated suite | | `sntrup` | yes | Streamlined NTRU Prime | | `threshold` | yes | Key splitting (`keysplit`) and the threshold marker attributes (`elliptic-curve`, `vsss-rs`, CBOR via `serde_cbor_2`) | | `wasm` | no | WebAssembly randomness via `getrandom/wasm_js`; on `wasm32` targets `blsful` always uses its `rust` backend | @@ -490,7 +492,7 @@ Each algorithm and curve is its own feature, so you compile in only the key type ## Upgrading from 2.x -3.0 replaces the always-on crypto dependencies with one feature per algorithm or curve. The default build has every feature except `deprecated`, `legacy_chacha20_fallback`, `slow-tests`, and `wasm`, so `multi-key = "3"` has the same key types as 2.x. +3.0 replaces the always-on crypto dependencies with one feature per algorithm or curve. The default build has every feature except `deprecated`, `legacy_chacha20_fallback`, `slow-tests`, `slow-tests-aarch64`, `slow-tests-riscv`, and `wasm`, so `multi-key = "3"` has the same key types as 2.x. - If you used `default-features = false` only to drop serde, add back the algorithms you use, e.g. `features = ["curve25519", "ml-dsa"]`, plus `threshold`, `lamport`, or `xmss` if you used those. A hybrid needs every feature it combines. - Creating, converting, or viewing a key whose feature is off returns an `UnsupportedCodec` error (`UnsupportedAlgorithm` for SSH conversion, `SealError::NotEncryptionKey` for the seal and open views). diff --git a/docs/ci-test-budget.md b/docs/ci-test-budget.md new file mode 100644 index 0000000..07d5f01 --- /dev/null +++ b/docs/ci-test-budget.md @@ -0,0 +1,73 @@ +# CI test budget + +The self-hosted Linux runners run the cross-target test jobs under +`qemu-aarch64-static` and `qemu-riscv64-static` user-mode emulation. Two +features hold out the tests that push an emulated test run past its test +budget: `slow-tests-aarch64` on the aarch64 target and `slow-tests-riscv` +on the riscv64gc target. A third feature, `slow-tests`, holds out the +tests the native test run needs held out. The test jobs enable every +other feature. The `Code Lint` step and the `Check` and `Build` steps +keep `--all-features`, so the gated code stays compile-checked. + +## Measurement + +Each test ran alone under the matching `qemu-*-static` emulator +(`RUST_TEST_THREADS=1`, nightly debug build, `--all-features`) on a +16-core x86_64 workstation. Serial time is the sum of the single-test +times. + +- Total serial time of all 255 tests of the riscv64gc measurement: + 17,274 s (4 h 48 m) +- riscv64gc tests at or over 60 s: 26 tests, 16,368 s (94.8% of the serial + time) +- The `slow-tests` gate holds 18 tests. The native test run needs them + held out to stay on budget. +- The `slow-tests-riscv` gate holds 11 tests. Their emulated serial time + adds to 2,486 s (the table below). +- Remaining riscv64gc serial time when the 26 tests are gated: 906 s + (15.1 min) +- Doctests (measured the same way): 9 tests, 0.13 s +- One full riscv64gc run with the CI feature list and `slow-tests-riscv` + enabled took 291.7 s and passed every test. +- The aarch64 run needs no held-out test today. A full run with the CI + feature list measured 21.6 s and 20.3 s back to back. The slowest + single test measured 20.7 s. `slow-tests-aarch64` is the hold-out + point for a future slow aarch64 test. +- The native test run with the same feature list measured 22.9 s. + +## Slow tests (60 s or more under emulation) + +Behind `slow-tests`: the SLH-DSA tests in `mk` and `keysplit`, the two +XMSS sign and index tests, and the Classic McEliece tests and the +x25519+mceliece348864 tests (the gate sits on their tests modules). + +Behind `slow-tests-riscv` (11 tests, 2,486 s serial under emulation): + +| Test | Emulated time (s) | +|------|------------------:| +| `views::sntrup::tests::test_sntrup_seal_open_roundtrip` | 541.9 | +| `keysplit::tests::roundtrip::roundtrip_rsa` | 534.3 | +| `views::lamport_merkle::tests::test_merkle_roundtrip_all_digests_depth1` | 345.5 | +| `keysplit::tests::roundtrip::roundtrip_frodokem` | 209.6 | +| `views::sntrup::tests::test_sntrup_public_key_derivation` | 206.4 | +| `views::lamport_merkle::tests::test_merkle_depth3_sha3_256` | 171.6 | +| `views::x25519_frodokem640::tests::test_640shake_roundtrip` | 141.2 | +| `mk::tests::key_codecs::test_encryption_roundtrip` | 94.8 | +| `views::mayo::tests::test_mayo5_sign_verify_roundtrip` | 89.0 | +| `views::sntrup::tests::test_sntrup_fingerprint` | 82.2 | +| `views::x25519_frodokem640::tests::test_640aes_roundtrip` | 69.1 | + +Five of the tests behind `slow-tests` exceed the 1,800 s measurement cap +under emulation. They report the cap value as a lower bound, so their +true serial time is larger. None of those tests appears in the table +above. + +## Budget rule + +The wall clock of one complete run with the CI feature list is the budget +measure. The measured budgets: 20-22 s on aarch64 and 76-86 s on +riscv64gc against a 300 s target. A test that grows past 60 s in a +single-test measurement on that target belongs behind that target's +feature again. Re-measure with that gate enabled. The CI job stays +correct as long as the sum of the ungated tests, doctests included, stays +well under the job budget. diff --git a/src/keysplit.rs b/src/keysplit.rs index bd6b35c..3a97641 100644 --- a/src/keysplit.rs +++ b/src/keysplit.rs @@ -697,7 +697,7 @@ mod tests { } // ── RSA ── - #[cfg(feature = "rsa")] + #[cfg(all(feature = "rsa", feature = "slow-tests-riscv"))] #[test] fn roundtrip_rsa() { assert_all(&crate::mk::RSA_KEY_CODECS); @@ -748,7 +748,7 @@ mod tests { assert_all(&crate::mk::MCELIECE_KEY_CODECS); } - #[cfg(feature = "frodokem")] + #[cfg(all(feature = "frodokem", feature = "slow-tests-riscv"))] #[test] fn roundtrip_frodokem() { assert_all(&crate::mk::FRODOKEM_KEY_CODECS); diff --git a/src/mk.rs b/src/mk.rs index e733b5f..75b4572 100644 --- a/src/mk.rs +++ b/src/mk.rs @@ -2818,12 +2818,10 @@ mod tests { ))] mod key_codecs { use super::*; - #[cfg(all(feature = "bcrypt", feature = "chacha20"))] - use crate::{cipher, kdf}; - - #[cfg(all(feature = "bcrypt", feature = "chacha20"))] + #[cfg(all(feature = "bcrypt", feature = "chacha20", feature = "slow-tests-riscv"))] #[test] fn test_encryption_roundtrip() { + use crate::{cipher, kdf}; for codec in KEY_CODECS { let mut rng = rand::rng(); let mk1 = Builder::new_from_random_bytes(codec, &mut rng) diff --git a/src/views/lamport_merkle.rs b/src/views/lamport_merkle.rs index 922f955..05e7c88 100644 --- a/src/views/lamport_merkle.rs +++ b/src/views/lamport_merkle.rs @@ -1012,6 +1012,7 @@ const MAX_DECODED_SIZE: usize = crate::mk::MAX_DECODED_SIZE; #[cfg(test)] mod tests { use super::*; + #[cfg(feature = "slow-tests-riscv")] use crate::LAMPORT_MERKLE_KEY_CODECS; use crate::ViewBuilder; use multi_sig::AttrId as MsAttrId; @@ -1024,6 +1025,7 @@ mod tests { .unwrap() } + #[cfg(feature = "slow-tests-riscv")] fn merkle_priv_codecs() -> impl Iterator { LAMPORT_MERKLE_KEY_CODECS.into_iter().filter(|c| { matches!( @@ -1043,6 +1045,7 @@ mod tests { }) } + #[cfg(feature = "slow-tests-riscv")] #[test] fn test_merkle_roundtrip_all_digests_depth1() { for codec in merkle_priv_codecs() { @@ -1166,6 +1169,7 @@ mod tests { assert_eq!(av.remaining_signatures().unwrap(), 1); } + #[cfg(feature = "slow-tests-riscv")] #[test] fn test_merkle_depth3_sha3_256() { let sk = build_priv(Codec::LamportMerkleSha3256Priv, 3); diff --git a/src/views/mayo.rs b/src/views/mayo.rs index b103167..6b9d2d5 100644 --- a/src/views/mayo.rs +++ b/src/views/mayo.rs @@ -446,6 +446,7 @@ mod tests { sign_verify_roundtrip(Codec::Mayo3Priv); } + #[cfg(feature = "slow-tests-riscv")] #[test] fn test_mayo5_sign_verify_roundtrip() { sign_verify_roundtrip(Codec::Mayo5Priv); diff --git a/src/views/sntrup.rs b/src/views/sntrup.rs index 6177b39..751f01e 100644 --- a/src/views/sntrup.rs +++ b/src/views/sntrup.rs @@ -426,6 +426,7 @@ mod tests { } } + #[cfg(feature = "slow-tests-riscv")] #[test] fn test_sntrup_public_key_derivation() { for codec in SNTRUP_KEY_CODECS { @@ -448,6 +449,7 @@ mod tests { } } + #[cfg(feature = "slow-tests-riscv")] #[test] fn test_sntrup_fingerprint() { for codec in SNTRUP_KEY_CODECS { @@ -474,6 +476,7 @@ mod tests { } } + #[cfg(feature = "slow-tests-riscv")] #[test] fn test_sntrup_seal_open_roundtrip() { let aead_codecs = [ diff --git a/src/views/x25519_frodokem640.rs b/src/views/x25519_frodokem640.rs index f0b87dc..08cbb70 100644 --- a/src/views/x25519_frodokem640.rs +++ b/src/views/x25519_frodokem640.rs @@ -380,7 +380,7 @@ impl<'a> OpenView for View<'a> { } } -#[cfg(test)] +#[cfg(all(test, feature = "slow-tests-riscv"))] mod tests { use super::*; use crate::ViewBuilder;