Skip to main content

lib_q_romulus/
lib.rs

1//! Romulus-N and Romulus-M authenticated encryption (Romulus v1.3).
2//!
3//! # Modes
4//!
5//! - **Romulus-N** ([`RomulusN`]): nonce-based AEAD. Unique nonces are required for security.
6//! - **Romulus-M** ([`RomulusM`]): misuse-resistant AEAD (SIV-style). Reusing a nonce does not
7//!   allow forgery; confidentiality impact is bounded by the MRAE goal of the mode.
8//!
9//! # API
10//!
11//! The primary interface is RustCrypto [`aead::AeadInPlace`] (and [`aead::AeadCore`]) with
12//! 16-byte key, 16-byte nonce, and 16-byte tag. Use [`aead::KeyInit::new`] to build a cipher
13//! from a key.
14//!
15//! Allocating helpers ([`aead::Aead`]) are available when the `alloc` feature is enabled.
16//!
17//! When `alloc` is enabled, [`RomulusNAead`] and [`RomulusMAead`] implement [`lib_q_core::Aead`]
18//! for integration with the lib-Q AEAD registry.
19//!
20//! # Targets
21//!
22//! The cryptographic core is `#![no_std]`, avoids OS services and RNG, and is intended to compile
23//! for embedded and `wasm32-unknown-unknown` without `wasm-bindgen` in this crate.
24//!
25//! # Feature flags
26//!
27//! | Feature | Effect |
28//! |---------|--------|
29//! *(none)* | `no_std`, in-place AEAD only |
30//! | `alloc` | `aead::Aead`, `lib_q_core::Aead` wrappers |
31//! | `std` | Standard library (implies `alloc`) |
32
33#![no_std]
34#![deny(unsafe_code)]
35#![deny(unused_qualifications)]
36
37#[cfg(feature = "alloc")]
38extern crate alloc;
39
40mod backend;
41pub mod romulus_m;
42pub mod romulus_n;
43mod skinny;
44mod stack_secret;
45
46#[cfg(feature = "alloc")]
47mod libq_aead;
48
49pub use aead::consts::{
50    U0,
51    U16,
52};
53#[cfg(feature = "alloc")]
54pub use libq_aead::{
55    RomulusMAead,
56    RomulusNAead,
57};
58pub use romulus_m::RomulusM;
59pub use romulus_n::RomulusN;
60
61/// Key size as a [`aead::consts`] typenum (128 bits).
62pub type KeySize = U16;
63/// Nonce size (128 bits).
64pub type NonceSize = U16;
65/// Tag size (128 bits).
66pub type TagSize = U16;
67/// Ciphertext expansion for in-place API (tag is detached).
68pub type CiphertextOverhead = U0;