embassy-crypto

Crates

git

Versions

default

Flavors

Skip to main content

ChaCha8

Trait ChaCha8 

Source
pub trait ChaCha8 {
    type Context: Send + Sync + Clone;

    // Required methods
    fn init(key: &[u8; 32], nonce: &[u8; 12], counter: u32) -> Self::Context;
    fn apply_keystream(ctx: &mut Self::Context, buf: InOutBuf<'_, '_, u8>);
}
Expand description

ChaCha8 (8 rounds) stream cipher driver.

Required Associated Types§

Source

type Context: Send + Sync + Clone

Opaque storage for the key, nonce, block counter and partial keystream.

Required Methods§

Source

fn init(key: &[u8; 32], nonce: &[u8; 12], counter: u32) -> Self::Context

Initialize with a 256-bit key, a 96-bit nonce and the initial 32-bit block counter.

Source

fn apply_keystream(ctx: &mut Self::Context, buf: InOutBuf<'_, '_, u8>)

XOR the keystream into buf.

The counter and any unused keystream are carried in the context, so buf need not be block-aligned.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§