wolf_crypto/chacha/states.rs
1//! State marker types and traits for the [`ChaCha20`] cipher.
2//!
3//! [`ChaCha20`]: crate::chacha::ChaCha20
4
5use crate::sealed::Sealed;
6
7/// Represents the possible states that the [`ChaCha20`] cipher may be in.
8///
9/// [`ChaCha20`]: crate::chacha::ChaCha20
10pub trait State: Sealed {}
11
12/// Represents the states which **can** process (encrypt / decrypt) data.
13pub trait CanProcess: State {}
14
15define_state! {
16 /// The ingress state for `ChaCha`, where the key is set and the instance is constructed.
17 Init,
18 /// The `ChaCha` instance requires a new initialization vector (IV).
19 NeedsIv,
20 /// The `ChaCha` instance is ready to perform encryption / decryption.
21 Ready,
22 /// The `ChaCha` instance is encrypting some stream of unknown length.
23 Streaming
24}
25
26impl CanProcess for Ready {}
27impl CanProcess for Streaming {}