1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! Maximum number of blocks that can be encrypted with ChaCha before the
//! counter overflows.

/// Marker type for the maximum ChaCha counter value
pub trait MaxCounter: Copy {
    const MAX_BLOCKS: Option<u64>;
}

/// 32-bit counter
#[derive(Copy, Clone)]
pub struct C32;

impl MaxCounter for C32 {
    const MAX_BLOCKS: Option<u64> = Some(u32::MAX as u64);
}

/// 64-bit counter
#[derive(Copy, Clone)]
pub struct C64;

impl MaxCounter for C64 {
    const MAX_BLOCKS: Option<u64> = None;
}