You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Streaming AEAD (STREAM) for chunked encryption of large payloads #156
Every cas-lib AEAD works on a single in-memory buffer, so encrypting a large file means holding all of it (and its ciphertext) in memory, which is a problem for FFI consumers handling uploads or backups. RustCrypto's aead-stream implements the STREAM construction (Hoang, Reyhanitabar, Rogaway, Vizár), which splits a message into authenticated chunks with a nonce prefix, a chunk counter and a last-chunk flag, so chunks can't be reordered, dropped or truncated.
STREAM-BE32 encryptor/decryptor over ChaCha20-Poly1305 (and XChaCha20-Poly1305 once the AEAD-modes issue lands)
A documented wire format (header with the random nonce prefix, then fixed-size chunks)
Implementation notes
Follow the module pattern: trait in cas_<module>.rs, impl in <algorithm>.rs, declared in src/lib.rs (no top-level re-exports).
Return CasResult<T> and never panic (a panic across the FFI boundary is UB); add CasError variants only by appending (stable ABI codes).
Zeroize intermediate secret buffers with zeroize::Zeroizing; structs holding secrets get a redacting Debug impl (see src/pqc/cas_pqc.rs).
The API has to work across FFI without Rust lifetimes. Options: an opaque stateful handle (new / encrypt_next(chunk) / encrypt_last(chunk)), or stateless per-chunk functions that take the nonce prefix and counter explicitly. Prefer the one that makes it impossible to forget the last-chunk flag.
Decryption must fail if the stream ends without a last chunk (truncation).
The nonce prefix is drawn internally from OsRng.
Tests
Round trip across chunk boundaries (empty, exactly one chunk, many chunks, uneven final chunk).
Reordered, duplicated, dropped and truncated chunks are all rejected.
Docs
Add a complete, runnable fn main() example for each new API to docs/EXAMPLES.md and keep its Table of Contents in sync.
Activity
WingZer0o commentedon Nov 27, 2026
Downstream tracking issues: