lum_ccc_rust/crates/ccc-cascade/src/suites.rs

69 lines
2.0 KiB
Rust

//! Built-in suites (R3-1): the registry's named, versioned suites. IDs are
//! stable: they are part of every envelope and of the AAD.
//!
//! LetUsMsg's profiles pick from these in `lum-crypto` (R3-10).
use ccc_crypto_core::AeadAlgorithm::{AesGcm256, AesGcmSiv256, AsconAead128, XChaCha20Poly1305};
use crate::suite::{Layer, Suite};
const fn layer(aead: ccc_crypto_core::AeadAlgorithm, provider: &'static str) -> Layer {
Layer { aead, provider }
}
/// Floor: one vetted layer (AES-256-GCM from wolfCrypt).
pub fn floor_aes() -> Suite {
Suite { id: 1, name: "floor-aes", layers: vec![layer(AesGcm256, "wolfssl")] }
}
/// Standard+: two layers, two providers, two design families.
pub fn standard_2() -> Suite {
Suite {
id: 2,
name: "standard-2",
layers: vec![layer(AesGcm256, "wolfssl"), layer(XChaCha20Poly1305, "rustcrypto")],
}
}
/// High: three layers alternating providers.
pub fn high_3() -> Suite {
Suite {
id: 3,
name: "high-3",
layers: vec![
layer(XChaCha20Poly1305, "rustcrypto"),
layer(AesGcm256, "wolfssl"),
layer(AesGcmSiv256, "rustcrypto"),
],
}
}
/// Ultra: three layers from two providers including a conservative
/// alternative (Ascon-AEAD128), with adjacent layers from different providers.
pub fn ultra_3() -> Suite {
Suite {
id: 4,
name: "ultra-3",
layers: vec![
layer(XChaCha20Poly1305, "rustcrypto"),
layer(AesGcm256, "wolfssl"),
layer(AsconAead128, "rustcrypto"),
],
}
}
/// Storage at rest for Standard: two layers (design: storage cascade row).
pub fn storage_2() -> Suite {
Suite { id: 5, name: "storage-2", layers: vec![layer(AesGcm256, "wolfssl"), layer(AesGcmSiv256, "rustcrypto")] }
}
/// Every built-in suite.
pub fn all() -> Vec<Suite> {
vec![floor_aes(), standard_2(), high_3(), ultra_3(), storage_2()]
}
/// The built-in suite with `id`.
pub fn by_id(id: u16) -> Option<Suite> {
all().into_iter().find(|s| s.id == id)
}