cascade: test built-in suites with both real providers
Each suite resolves and round-trips at 1, 3 and 16 rounds, and release policy refuses this non-FIPS build (fail closed, D-26). Refs: R3-3, R3-7
This commit is contained in:
parent
ba0cda4d26
commit
9ee740497b
|
|
@ -239,6 +239,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa"
|
||||
dependencies = [
|
||||
"hybrid-array",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -256,7 +257,9 @@ name = "ccc-cascade"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ccc-crypto-core",
|
||||
"ccc-crypto-rustcrypto",
|
||||
"ccc-crypto-wolfssl",
|
||||
"hpke",
|
||||
"thiserror",
|
||||
"zeroize",
|
||||
]
|
||||
|
|
@ -536,6 +539,7 @@ dependencies = [
|
|||
"const-oid",
|
||||
"crypto-common 0.2.2",
|
||||
"ctutils",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -598,6 +602,7 @@ dependencies = [
|
|||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"rand_core 0.10.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -641,10 +646,34 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "hybrid-array"
|
||||
version = "0.4.10"
|
||||
name = "hpke"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3944cf8cf766b40e2a1a333ee5e9b563f854d5fa49d6a8ca2764e97c6eddb214"
|
||||
checksum = "8f512e325a1a71bf3273fb9b7fc9e5d96dac136fb4a95d0e6637001b12ea3e09"
|
||||
dependencies = [
|
||||
"aead",
|
||||
"aes-gcm",
|
||||
"curve25519-dalek",
|
||||
"getrandom",
|
||||
"hkdf",
|
||||
"hybrid-array",
|
||||
"ml-kem",
|
||||
"rand_core 0.10.1",
|
||||
"sha2",
|
||||
"sha3",
|
||||
"shake",
|
||||
"subtle",
|
||||
"turboshake",
|
||||
"x-wing",
|
||||
"x25519-dalek",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hybrid-array"
|
||||
version = "0.4.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17"
|
||||
dependencies = [
|
||||
"ctutils",
|
||||
"typenum",
|
||||
|
|
@ -1088,6 +1117,9 @@ name = "sponge-cursor"
|
|||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a0219bd7d979d58245a4f41f695e1ac9f8befdffadd7f61f1bae9e39abc6620"
|
||||
dependencies = [
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
|
|
@ -1127,10 +1159,21 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.19.0"
|
||||
name = "turboshake"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb"
|
||||
checksum = "f892c6904b0bd5a9241eac848347abcbbbd2b9f3892bad23ac3e6efab8d6f06a"
|
||||
dependencies = [
|
||||
"digest 0.11.3",
|
||||
"keccak",
|
||||
"sponge-cursor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.20.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
|
|
|
|||
|
|
@ -13,3 +13,6 @@ thiserror.workspace = true
|
|||
|
||||
[dev-dependencies]
|
||||
ccc-crypto-wolfssl = { path = "../ccc-crypto-wolfssl" }
|
||||
ccc-crypto-rustcrypto = { path = "../ccc-crypto-rustcrypto" }
|
||||
# Independent RFC 9180 implementation, used only as an interop oracle.
|
||||
hpke = { version = "0.15", default-features = false, features = ["alloc", "mlkem", "x25519", "aes", "hkdfsha2", "getrandom"] }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
//! Every built-in suite resolves with the real providers (wolfSSL and
|
||||
//! RustCrypto) and round-trips at every allowed round count, and Ultra meets
|
||||
//! its policy: two providers, a conservative alternative, distinct adjacent
|
||||
//! providers.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use ccc_cascade::{open, seal, suites, Context, Policy, ProviderSet};
|
||||
use ccc_crypto_core::Tier;
|
||||
use ccc_crypto_rustcrypto::RustCryptoProvider;
|
||||
use ccc_crypto_wolfssl::WolfSslProvider;
|
||||
|
||||
fn providers() -> ProviderSet {
|
||||
let mut p = ProviderSet::new();
|
||||
p.add(Arc::new(WolfSslProvider::new()));
|
||||
p.add(Arc::new(RustCryptoProvider::new()));
|
||||
p
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_builtin_suite_round_trips() {
|
||||
let p = providers();
|
||||
let ctx = Context { domain: b"lum/test", aad: b"aad" };
|
||||
for suite in suites::all() {
|
||||
let r = p.resolve(&suite, &Policy::development()).unwrap_or_else(|e| panic!("{}: {e}", suite.name));
|
||||
for rounds in [1u8, 3, 16] {
|
||||
let ct = seal(&r, rounds, &[5; 32], &[6; 32], ctx, b"payload").unwrap();
|
||||
assert_eq!(
|
||||
open(&r, rounds, &[5; 32], &[6; 32], ctx, &ct).unwrap().as_slice(),
|
||||
b"payload",
|
||||
"{}",
|
||||
suite.name
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ultra_meets_its_diversity_rules() {
|
||||
let ultra = suites::ultra_3();
|
||||
let strict = Policy { require_distinct_adjacent_providers: true, min_layers: 3, ..Policy::development() };
|
||||
providers().resolve(&ultra, &strict).unwrap();
|
||||
let names: std::collections::HashSet<_> = ultra.layers.iter().map(|l| l.provider).collect();
|
||||
assert!(names.len() >= 2);
|
||||
assert!(ultra.layers.iter().any(|l| l.aead.tier() == Tier::Conservative));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn release_policy_refuses_this_non_fips_build() {
|
||||
// Fail closed: without the commercial FIPS module no suite resolves (D-26).
|
||||
for suite in suites::all() {
|
||||
assert!(providers().resolve(&suite, &Policy::release()).is_err(), "{}", suite.name);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue