cryptoxide/chacha/
mod.rs

1//! ChaCha Stream Cipher -- Engine implementation
2//!
3//! Implementation of [ChaCha spec](https://www.rfc-editor.org/info/rfc7539)
4//! which is a fast and lean stream cipher.
5//!
6//! The maximum amount of data to be processed by a single instance of a ChaCha
7//! Context, is 256Gb (due to the 32 bits counter). Note that this is not
8//! enforced by the context, and using a context to process more than 256Gb of
9//! data would be insecure.
10//!
11//! The Engine is parametrized with the number of rounds to execute, which is
12//! enforced by assertion to be either 8, 12 or 20.
13//!
14//! Note that with stream cipher, there's only one operation [`ChaChaEngine::<N>::process`]
15//! and its variant [`ChaChaEngine::<N>::process_mut`] instead of the typical
16//! cipher operation encrypt and decrypt.
17//!
18
19#[cfg(not(all(
20    any(target_arch = "x86", target_arch = "x86_64"),
21    any(target_feature = "sse2", target_feature = "avx2")
22)))]
23mod reference;
24
25#[cfg(not(all(
26    any(target_arch = "x86", target_arch = "x86_64"),
27    any(target_feature = "sse2", target_feature = "avx2")
28)))]
29pub(crate) type ChaChaEngine<const R: usize> = reference::State<R>;
30
31#[cfg(all(
32    any(target_arch = "x86", target_arch = "x86_64"),
33    target_feature = "sse2",
34))]
35mod sse2;
36
37#[cfg(all(
38    any(target_arch = "x86", target_arch = "x86_64"),
39    target_feature = "sse2",
40))]
41pub(crate) type ChaChaEngine<const R: usize> = sse2::State<R>;