Type Alias XChaCha20

Source
pub type XChaCha20 = StreamCipherCoreWrapper<XChaChaCore<U10>>;
Expand description

XChaCha is a ChaCha20 variant with an extended 192-bit (24-byte) nonce.

The construction is an adaptation of the same techniques used by XChaCha as described in the paper “Extending the Salsa20 Nonce”, applied to the 96-bit nonce variant of ChaCha20, and derive a separate subkey/nonce for each extended nonce:

https://cr.yp.to/snuffle/xsalsa-20081128.pdf

No authoritative specification exists for XChaCha20, however the construction has “rough consensus and running code” in the form of several interoperable libraries and protocols (e.g. libsodium, WireGuard) and is documented in an (expired) IETF draft:

https://tools.ietf.org/html/draft-arciszewski-xchacha-03

Aliased Type§

struct XChaCha20 { /* private fields */ }

Implementations

§

impl<T> StreamCipherCoreWrapper<T>
where T: StreamCipherCore, <T as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>, <<T as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,

pub fn get_core(&self) -> &T

Return reference to the core type.

pub fn from_core(core: T) -> StreamCipherCoreWrapper<T>

Return reference to the core type.

Trait Implementations

§

impl<T> Clone for StreamCipherCoreWrapper<T>
where T: Clone + BlockSizeUser, <T as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>, <<T as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,

§

fn clone(&self) -> StreamCipherCoreWrapper<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> Default for StreamCipherCoreWrapper<T>
where T: Default + BlockSizeUser, <T as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>, <<T as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,

§

fn default() -> StreamCipherCoreWrapper<T>

Returns the “default value” for a type. Read more
§

impl<T> IvSizeUser for StreamCipherCoreWrapper<T>
where T: IvSizeUser + BlockSizeUser, <T as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>, <<T as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,

§

type IvSize = <T as IvSizeUser>::IvSize

Initialization vector size in bytes.
§

fn iv_size() -> usize

Return IV size in bytes.
§

impl<T> KeyInit for StreamCipherCoreWrapper<T>
where T: KeyInit + BlockSizeUser, <T as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>, <<T as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,

§

fn new( key: &GenericArray<u8, <StreamCipherCoreWrapper<T> as KeySizeUser>::KeySize>, ) -> StreamCipherCoreWrapper<T>

Create new value from fixed size key.
§

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

Create new value from variable size key.
§

impl<T> KeyIvInit for StreamCipherCoreWrapper<T>
where T: KeyIvInit + BlockSizeUser, <T as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>, <<T as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,

§

fn new( key: &GenericArray<u8, <StreamCipherCoreWrapper<T> as KeySizeUser>::KeySize>, iv: &GenericArray<u8, <StreamCipherCoreWrapper<T> as IvSizeUser>::IvSize>, ) -> StreamCipherCoreWrapper<T>

Create new value from fixed length key and nonce.
§

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

Create new value from variable length key and nonce.
§

impl<T> KeySizeUser for StreamCipherCoreWrapper<T>
where T: KeySizeUser + BlockSizeUser, <T as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>, <<T as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,

§

type KeySize = <T as KeySizeUser>::KeySize

Key size in bytes.
§

fn key_size() -> usize

Return key size in bytes.
§

impl<T> StreamCipher for StreamCipherCoreWrapper<T>
where T: StreamCipherCore, <T as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>, <<T as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,

§

fn try_apply_keystream_inout( &mut self, data: InOutBuf<'_, '_, u8>, ) -> Result<(), StreamCipherError>

Apply keystream to inout data. Read more
§

fn try_apply_keystream( &mut self, buf: &mut [u8], ) -> Result<(), StreamCipherError>

Apply keystream to data behind buf. Read more
§

fn apply_keystream_inout(&mut self, buf: InOutBuf<'_, '_, u8>)

Apply keystream to inout data. Read more
§

fn apply_keystream(&mut self, buf: &mut [u8])

Apply keystream to data in-place. Read more
§

fn apply_keystream_b2b( &mut self, input: &[u8], output: &mut [u8], ) -> Result<(), StreamCipherError>

Apply keystream to data buffer-to-buffer. Read more
§

impl<T> StreamCipherSeek for StreamCipherCoreWrapper<T>
where T: StreamCipherSeekCore, <T as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>, <<T as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,

§

fn try_current_pos<SN>(&self) -> Result<SN, OverflowError>
where SN: SeekNum,

Try to get current keystream position Read more
§

fn try_seek<SN>(&mut self, new_pos: SN) -> Result<(), StreamCipherError>
where SN: SeekNum,

Try to seek to the given position Read more
§

fn current_pos<T>(&self) -> T
where T: SeekNum,

Get current keystream position Read more
§

fn seek<T>(&mut self, pos: T)
where T: SeekNum,

Seek to the given position Read more