Skip to main content

ChaChaCore

Struct ChaChaCore 

Source
pub struct ChaChaCore<R: Rounds, V: Variant> { /* private fields */ }
Expand description

The ChaCha core function.

Implementations§

Source§

impl<R: Rounds, V: Variant> ChaChaCore<R, V>

Source

pub fn get_block_pos(&self) -> V::Counter

Get the current block position.

Source

pub fn set_block_pos(&mut self, pos: V::Counter)

Set the block position.

Trait Implementations§

Source§

impl<R: Rounds, V: Variant> BlockSizeUser for ChaChaCore<R, V>

Available on crate feature cipher only.
Source§

type BlockSize = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>

Size of the block in bytes.
Source§

fn block_size() -> usize

Return block size in bytes.
Source§

impl<R: Rounds, V: Variant> Debug for ChaChaCore<R, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<R: Rounds, V: Variant> Drop for ChaChaCore<R, V>

Available on crate feature zeroize only.
Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<R: Rounds, V: Variant> Generator for ChaChaCore<R, V>

Available on crate feature rng only.
Source§

fn generate(&mut self, buffer: &mut [u32; 64])

Generates 4 blocks in parallel with avx2 & neon, but merely fills 4 blocks with sse2 & soft

Source§

type Output = [u32; 64]

The output type. Read more
Source§

fn drop(&mut self, output: &mut Self::Output)

Destruct the output buffer Read more
Source§

impl<R: Rounds> IvSizeUser for ChaChaCore<R, Ietf>

Available on crate feature cipher only.
Source§

type IvSize = UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>

Initialization vector size in bytes.
Source§

fn iv_size() -> usize

Return IV size in bytes.
Source§

impl IvSizeUser for ChaChaCore<R20, Legacy>

Available on crate feature legacy only.
Source§

type IvSize = UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>

Initialization vector size in bytes.
Source§

fn iv_size() -> usize

Return IV size in bytes.
Source§

impl<R: Rounds> KeyIvInit for ChaChaCore<R, Ietf>

Available on crate feature cipher only.
Source§

fn new(key: &Key, iv: &Array<u8, U12>) -> Self

Create new value from fixed length key and nonce.
Source§

fn new_from_slices(key: &[u8], iv: &[u8]) -> Result<Self, InvalidLength>

Create new value from variable length key and nonce. Read more
Source§

impl KeyIvInit for ChaChaCore<R20, Legacy>

Available on crate feature legacy only.
Source§

fn new(key: &Key, iv: &LegacyNonce) -> Self

Create new value from fixed length key and nonce.
Source§

fn new_from_slices(key: &[u8], iv: &[u8]) -> Result<Self, InvalidLength>

Create new value from variable length key and nonce. Read more
Source§

impl<R: Rounds> KeySizeUser for ChaChaCore<R, Ietf>

Available on crate feature cipher only.
Source§

type KeySize = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>

Key size in bytes.
Source§

fn key_size() -> usize

Return key size in bytes.
Source§

impl KeySizeUser for ChaChaCore<R20, Legacy>

Available on crate feature legacy only.
Source§

type KeySize = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>

Key size in bytes.
Source§

fn key_size() -> usize

Return key size in bytes.
Source§

impl<R: Rounds, V: Variant> SeedableRng for ChaChaCore<R, V>

Available on crate feature rng only.
Source§

type Seed = [u8; 32]

Seed type, which is restricted to types mutably-dereferenceable as u8 arrays (we recommend [u8; N] for some N). Read more
Source§

fn from_seed(seed: Self::Seed) -> Self

Create a new PRNG using the given seed. Read more
Source§

fn seed_from_u64(state: u64) -> Self

Create a new PRNG using a u64 seed. Read more
Source§

fn from_rng<R>(rng: &mut R) -> Self
where R: Rng + ?Sized,

Create a new PRNG seeded from an infallible Rng. Read more
Source§

fn try_from_rng<R>(rng: &mut R) -> Result<Self, <R as TryRng>::Error>
where R: TryRng + ?Sized,

Create a new PRNG seeded from a potentially fallible Rng. Read more
Source§

impl<R: Rounds, V: Variant> StreamCipherCore for ChaChaCore<R, V>

Available on crate feature cipher only.
Source§

fn remaining_blocks(&self) -> Option<usize>

Return number of remaining blocks before the cipher wraps around. Read more
Source§

fn process_with_backend( &mut self, f: impl StreamCipherClosure<BlockSize = Self::BlockSize>, )

Process data using backend provided to the rank-2 closure.
Source§

fn write_keystream_block(&mut self, block: &mut Array<u8, Self::BlockSize>)

Write keystream block. Read more
Source§

fn write_keystream_blocks(&mut self, blocks: &mut [Array<u8, Self::BlockSize>])

Write keystream blocks. Read more
Source§

fn apply_keystream_block_inout( &mut self, block: InOut<'_, '_, Array<u8, Self::BlockSize>>, )

Apply keystream block. Read more
Source§

fn apply_keystream_blocks(&mut self, blocks: &mut [Array<u8, Self::BlockSize>])

Apply keystream blocks. Read more
Source§

fn apply_keystream_blocks_inout( &mut self, blocks: InOutBuf<'_, '_, Array<u8, Self::BlockSize>>, )

Apply keystream blocks. Read more
Source§

fn try_apply_keystream_partial( self, buf: InOutBuf<'_, '_, u8>, ) -> Result<(), StreamCipherError>

Try to apply keystream to data not divided into blocks. Read more
Source§

fn apply_keystream_partial(self, buf: InOutBuf<'_, '_, u8>)

Try to apply keystream to data not divided into blocks. Read more
Source§

impl<R: Rounds, V: Variant> StreamCipherSeekCore for ChaChaCore<R, V>

Available on crate feature cipher only.
Source§

type Counter = <V as Variant>::Counter

Counter type used inside stream cipher.
Source§

fn get_block_pos(&self) -> Self::Counter

Get current block position.
Source§

fn set_block_pos(&mut self, pos: Self::Counter)

Set block position.
Source§

impl<R: Rounds, V: Variant> ZeroizeOnDrop for ChaChaCore<R, V>

Available on crate feature zeroize only.

Auto Trait Implementations§

§

impl<R, V> Freeze for ChaChaCore<R, V>

§

impl<R, V> RefUnwindSafe for ChaChaCore<R, V>

§

impl<R, V> Send for ChaChaCore<R, V>
where R: Send, V: Send,

§

impl<R, V> Sync for ChaChaCore<R, V>
where R: Sync, V: Sync,

§

impl<R, V> Unpin for ChaChaCore<R, V>
where R: Unpin, V: Unpin,

§

impl<R, V> UnwindSafe for ChaChaCore<R, V>
where R: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.