pub struct NonceGenerator { /* private fields */ }Expand description
Monotonically increasing nonce generator.
Each session gets its own nonce generator. The counter MUST NOT be reused – nonce reuse breaks AES-GCM catastrophically.
Implementations§
Source§impl NonceGenerator
impl NonceGenerator
Sourcepub fn next(&mut self, _cipher: Cipher) -> [u8; 16]
pub fn next(&mut self, _cipher: Cipher) -> [u8; 16]
Generate the next nonce for the given cipher.
Returns the full 16-byte nonce field for the TRANSFORM_HEADER.
- CCM: 8-byte LE counter in bytes 0..8, zeros in bytes 8..16 (the cipher uses the first 11 bytes as the nonce).
- GCM: 8-byte LE counter in bytes 0..8, zeros in bytes 8..16 (the cipher uses the first 12 bytes as the nonce).
§Panics
Panics if the counter overflows u64::MAX. In practice this
can never happen (2^64 messages at line speed would take millennia).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NonceGenerator
impl RefUnwindSafe for NonceGenerator
impl Send for NonceGenerator
impl Sync for NonceGenerator
impl Unpin for NonceGenerator
impl UnsafeUnpin for NonceGenerator
impl UnwindSafe for NonceGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more