pub struct ChaChaCore<R: Rounds, V: Variant> {
pub(crate) state: [u32; 16],
pub(crate) tokens: (InitToken, InitToken),
pub(crate) _pd: PhantomData<(R, V)>,
}Expand description
The ChaCha core function.
Fields§
§state: [u32; 16]Internal state of the core function
tokens: (InitToken, InitToken)CPU target feature tokens
_pd: PhantomData<(R, V)>Number of rounds to perform and the cipher variant
Implementations§
Source§impl<R: Rounds, V: Variant> ChaChaCore<R, V>
impl<R: Rounds, V: Variant> ChaChaCore<R, V>
Sourcepub(crate) fn new_internal(key: &[u8; 32], iv: &[u8]) -> Self
pub(crate) fn new_internal(key: &[u8; 32], iv: &[u8]) -> Self
Constructs a ChaChaCore with the specified key and iv.
You must ensure that the iv is of the correct size when using this method directly.
§Panics
If iv.len() is not equal to 4, 8, or 12.
Sourcepub fn get_block_pos(&self) -> V::Counter
pub fn get_block_pos(&self) -> V::Counter
Get the current block position.
Sourcepub fn set_block_pos(&mut self, pos: V::Counter)
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.
impl<R: Rounds, V: Variant> BlockSizeUser for ChaChaCore<R, V>
Available on crate feature
cipher only.Source§impl<R: Rounds, V: Variant> Drop for ChaChaCore<R, V>
Available on crate feature zeroize only.
impl<R: Rounds, V: Variant> Drop for ChaChaCore<R, V>
Available on crate feature
zeroize only.Source§impl<R: Rounds> IvSizeUser for ChaChaCore<R, Ietf>
impl<R: Rounds> IvSizeUser for ChaChaCore<R, Ietf>
Source§impl<R: Rounds> KeyIvInit for ChaChaCore<R, Ietf>
impl<R: Rounds> KeyIvInit for ChaChaCore<R, Ietf>
Source§fn new_from_slices(key: &[u8], iv: &[u8]) -> Result<Self, InvalidLength>
fn new_from_slices(key: &[u8], iv: &[u8]) -> Result<Self, InvalidLength>
Create new value from variable length key and nonce. Read more
Source§fn generate_key<R>(rng: &mut R) -> Array<u8, Self::KeySize>where
R: CryptoRng,
fn generate_key<R>(rng: &mut R) -> Array<u8, Self::KeySize>where
R: CryptoRng,
👎Deprecated since 0.2.0: use the
Generate trait impl on Key insteadSource§impl<R: Rounds> KeySizeUser for ChaChaCore<R, Ietf>
impl<R: Rounds> KeySizeUser for ChaChaCore<R, Ietf>
Source§impl<R: Rounds, V: Variant> SeedableRng for ChaChaCore<R, V>
impl<R: Rounds, V: Variant> SeedableRng for ChaChaCore<R, V>
Source§type Seed = [u8; 32]
type Seed = [u8; 32]
Seed type, which is restricted to types mutably-dereferenceable as
u8
arrays (we recommend [u8; N] for some N). Read moreSource§fn seed_from_u64(state: u64) -> Self
fn seed_from_u64(state: u64) -> Self
Create a new PRNG using a
u64 seed. Read moreSource§impl<R: Rounds, V: Variant> StreamCipherCore for ChaChaCore<R, V>
Available on crate feature cipher only.
impl<R: Rounds, V: Variant> StreamCipherCore for ChaChaCore<R, V>
Available on crate feature
cipher only.Source§fn remaining_blocks(&self) -> Option<usize>
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>,
)
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>)
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>])
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>>,
)
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>])
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>>,
)
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>
fn try_apply_keystream_partial( self, buf: InOutBuf<'_, '_, u8>, ) -> Result<(), StreamCipherError>
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.
impl<R: Rounds, V: Variant> StreamCipherSeekCore for ChaChaCore<R, V>
Available on crate feature
cipher only.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>where
R: RefUnwindSafe,
V: RefUnwindSafe,
impl<R, V> Send for ChaChaCore<R, V>
impl<R, V> Sync for ChaChaCore<R, V>
impl<R, V> Unpin for ChaChaCore<R, V>
impl<R, V> UnsafeUnpin for ChaChaCore<R, V>
impl<R, V> UnwindSafe for ChaChaCore<R, V>where
R: UnwindSafe,
V: UnwindSafe,
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