use cipher::{ IvSizeUser, KeyIvInit, KeySizeUser, StreamCipherCoreWrapper, array::Array, consts::{U12, U32, U64}, }; use crate::{ChaChaCore, R8, R12, R20, Rounds, variants::Ietf}; /// Key type used by all ChaCha variants. pub type Key = Array; /// Nonce type used by ChaCha variants. pub type Nonce = Array; /// ChaCha8 stream cipher (reduced-round variant of [`ChaCha20`] with 8 rounds) pub type ChaCha8 = StreamCipherCoreWrapper>; /// ChaCha12 stream cipher (reduced-round variant of [`ChaCha20`] with 12 rounds) pub type ChaCha12 = StreamCipherCoreWrapper>; /// ChaCha20 stream cipher (RFC 8439 version with 96-bit nonce) pub type ChaCha20 = StreamCipherCoreWrapper>; pub(crate) type Block = Array; impl KeySizeUser for ChaChaCore { type KeySize = U32; } impl IvSizeUser for ChaChaCore { type IvSize = U12; } impl KeyIvInit for ChaChaCore { #[inline] fn new(key: &Key, iv: &Nonce) -> Self { ChaChaCore::::new_internal(key.as_ref(), iv.as_ref()) } }