60 lines
1.9 KiB
Rust
60 lines
1.9 KiB
Rust
//! # ccc-cascade
|
|
//!
|
|
//! CCC v2 (design: "Cascade encryption: CCC v2", D-8, D-25): a cascade of
|
|
//! AEAD layers from several providers, with an independent HKDF-SHA-512 key
|
|
//! and nonce for every layer of every round, a random 32-byte salt per message
|
|
//! or record, AAD binding, bucket padding and a STREAM mode for blobs. Plus the
|
|
//! suite registry and the policy checks (at least one vetted layer, FIPS vetted
|
|
//! layer in release builds, adjacent provider diversity, self-tests passed).
|
|
//!
|
|
//! Nothing here is specific to LetUsMsg and nothing does I/O.
|
|
#![forbid(unsafe_code)]
|
|
#![warn(missing_docs)]
|
|
|
|
pub mod cascade;
|
|
pub mod padding;
|
|
pub mod secret;
|
|
pub mod stream;
|
|
pub mod suite;
|
|
pub mod suites;
|
|
|
|
pub use cascade::{open, seal, Context, SALT_LEN};
|
|
pub use padding::{pad, unpad, Bucketing};
|
|
pub use secret::{Key32, SecretBytes};
|
|
pub use stream::{StreamOpener, StreamSealer, SEGMENT_LEN};
|
|
pub use suite::{Layer, Policy, ProviderSet, ResolvedSuite, Suite, MAX_ROUNDS};
|
|
|
|
use ccc_crypto_core::CryptoError;
|
|
|
|
/// Errors from the cascade.
|
|
#[derive(Debug, Clone, thiserror::Error)]
|
|
pub enum CascadeError {
|
|
/// A suite, round count or layout breaks the policy (fail closed).
|
|
#[error("policy: {0}")]
|
|
Policy(String),
|
|
/// An algorithm failed its provider's self-test; no fallback (D-28).
|
|
#[error("self-test failed: {0}")]
|
|
SelfTestFailed(String),
|
|
/// Opening failed. Never says which layer.
|
|
#[error("authentication failed")]
|
|
AuthenticationFailed,
|
|
/// Malformed input.
|
|
#[error("invalid input: {0}")]
|
|
InvalidInput(&'static str),
|
|
/// A provider error while sealing or deriving keys.
|
|
#[error("crypto: {0}")]
|
|
Crypto(String),
|
|
}
|
|
|
|
impl From<CryptoError> for CascadeError {
|
|
fn from(e: CryptoError) -> Self {
|
|
match e {
|
|
CryptoError::AuthenticationFailed => Self::AuthenticationFailed,
|
|
other => Self::Crypto(other.to_string()),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests;
|