Skip to main content

ChaCha20Poly1305Stream

Struct ChaCha20Poly1305Stream 

Source
pub struct ChaCha20Poly1305Stream { /* private fields */ }
Expand description

STREAM chunked AEAD using XChaCha20-Poly1305.

Nonce layout: 19-byte prefix ‖ 4-byte counter (big-endian) ‖ 1-byte flag.

Provide a 19-byte prefix to init.

Trait Implementations§

Source§

impl Debug for ChaCha20Poly1305Stream

Source§

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

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

impl StreamingAead for ChaCha20Poly1305Stream

Source§

fn init(key: &[u8], nonce: &[u8], aad: &[u8]) -> Result<Self, CryptoError>

Initialise the stream.

nonce must be exactly 19 bytes (XChaCha20 nonce prefix).

Source§

fn encrypt_update( &mut self, chunk: &[u8], out: &mut [u8], ) -> Result<usize, CryptoError>

Feed a plaintext chunk; write ciphertext bytes into out. Returns the number of bytes written.
Source§

fn encrypt_finalize(self, out: &mut [u8]) -> Result<[u8; 16], CryptoError>

Flush remaining ciphertext into out and return the 16-byte authentication tag.
Source§

fn decrypt_update( &mut self, chunk: &[u8], out: &mut [u8], ) -> Result<usize, CryptoError>

Feed a ciphertext chunk; write plaintext bytes into out. Returns the number of bytes written.
Source§

fn decrypt_finalize(self, expected_tag: &[u8]) -> Result<(), CryptoError>

Verify expected_tag in constant time and flush remaining plaintext.
Source§

fn reset(&mut self)

Reset to initial (un-initialised) state for reuse.

Auto Trait Implementations§

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.