pub struct ChaChaPoly1305<C, N: ArrayLength<u8> = U12>where
    C: NewCipher<KeySize = U32, NonceSize = N> + StreamCipher + StreamCipherSeek,{ /* private fields */ }
Expand description

Generic ChaCha+Poly1305 Authenticated Encryption with Additional Data (AEAD) construction.

See the toplevel documentation for a usage example.

Trait Implementations§

source§

impl<C, N> AeadCore for ChaChaPoly1305<C, N>where C: NewCipher<KeySize = U32, NonceSize = N> + StreamCipher + StreamCipherSeek, N: ArrayLength<u8>,

§

type NonceSize = N

The length of a nonce.
§

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

The maximum length of the nonce.
§

type CiphertextOverhead = UTerm

The upper bound amount of additional space required to support a ciphertext vs. a plaintext.
source§

impl<C, N> AeadInPlace for ChaChaPoly1305<C, N>where C: NewCipher<KeySize = U32, NonceSize = N> + StreamCipher + StreamCipherSeek, N: ArrayLength<u8>,

source§

fn encrypt_in_place_detached( &self, nonce: &Nonce<Self>, associated_data: &[u8], buffer: &mut [u8] ) -> Result<Tag, Error>

Encrypt the data in-place, returning the authentication tag
source§

fn decrypt_in_place_detached( &self, nonce: &Nonce<Self>, associated_data: &[u8], buffer: &mut [u8], tag: &Tag ) -> Result<(), Error>

Decrypt the message in-place, returning an error in the event the provided authentication tag does not match the given ciphertext (i.e. ciphertext is modified/unauthentic)
source§

fn encrypt_in_place( &self, nonce: &GenericArray<u8, Self::NonceSize>, associated_data: &[u8], buffer: &mut dyn Buffer ) -> Result<(), Error>

Encrypt the given buffer containing a plaintext message in-place. Read more
source§

fn decrypt_in_place( &self, nonce: &GenericArray<u8, Self::NonceSize>, associated_data: &[u8], buffer: &mut dyn Buffer ) -> Result<(), Error>

Decrypt the message in-place, returning an error in the event the provided authentication tag does not match the given ciphertext. Read more
source§

impl<C, N> Clone for ChaChaPoly1305<C, N>where C: NewCipher<KeySize = U32, NonceSize = N> + StreamCipher + StreamCipherSeek, N: ArrayLength<u8>,

source§

fn clone(&self) -> Self

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
source§

impl<C, N> Drop for ChaChaPoly1305<C, N>where C: NewCipher<KeySize = U32, NonceSize = N> + StreamCipher + StreamCipherSeek, N: ArrayLength<u8>,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<C, N> NewAead for ChaChaPoly1305<C, N>where C: NewCipher<KeySize = U32, NonceSize = N> + StreamCipher + StreamCipherSeek, N: ArrayLength<u8>,

§

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

The size of the key array required by this algorithm.
source§

fn new(key: &Key) -> Self

Create a new AEAD instance with the given key.
source§

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

Create new AEAD instance from key given as a byte slice.. Read more

Auto Trait Implementations§

§

impl<C, N> RefUnwindSafe for ChaChaPoly1305<C, N>where C: RefUnwindSafe,

§

impl<C, N> Send for ChaChaPoly1305<C, N>where C: Send,

§

impl<C, N> Sync for ChaChaPoly1305<C, N>where C: Sync,

§

impl<C, N> Unpin for ChaChaPoly1305<C, N>where C: Unpin,

§

impl<C, N> UnwindSafe for ChaChaPoly1305<C, N>where C: UnwindSafe,

Blanket Implementations§

source§

impl<Alg> Aead for Algwhere Alg: AeadInPlace,

source§

fn encrypt<'msg, 'aad>( &self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, plaintext: impl Into<Payload<'msg, 'aad>> ) -> Result<Vec<u8, Global>, Error>

Encrypt the given plaintext payload, and return the resulting ciphertext as a vector of bytes. Read more
source§

fn decrypt<'msg, 'aad>( &self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, ciphertext: impl Into<Payload<'msg, 'aad>> ) -> Result<Vec<u8, Global>, Error>

Decrypt the given ciphertext slice, and return the resulting plaintext as a vector of bytes. Read more
source§

impl<Alg> AeadMut for Algwhere Alg: AeadMutInPlace,

source§

fn encrypt<'msg, 'aad>( &mut self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, plaintext: impl Into<Payload<'msg, 'aad>> ) -> Result<Vec<u8, Global>, Error>

Encrypt the given plaintext slice, and return the resulting ciphertext as a vector of bytes. Read more
source§

fn decrypt<'msg, 'aad>( &mut self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, ciphertext: impl Into<Payload<'msg, 'aad>> ) -> Result<Vec<u8, Global>, Error>

Decrypt the given ciphertext slice, and return the resulting plaintext as a vector of bytes. Read more
source§

impl<Alg> AeadMutInPlace for Algwhere Alg: AeadInPlace,

source§

fn encrypt_in_place( &mut self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut impl Buffer ) -> Result<(), Error>

Encrypt the given buffer containing a plaintext message in-place. Read more
source§

fn encrypt_in_place_detached( &mut self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut [u8] ) -> Result<GenericArray<u8, <Alg as AeadCore>::TagSize>, Error>

Encrypt the data in-place, returning the authentication tag
source§

fn decrypt_in_place( &mut self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut impl Buffer ) -> Result<(), Error>

Decrypt the message in-place, returning an error in the event the provided authentication tag does not match the given ciphertext. Read more
source§

fn decrypt_in_place_detached( &mut self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut [u8], tag: &GenericArray<u8, <Alg as AeadCore>::TagSize> ) -> Result<(), Error>

Decrypt the data in-place, returning an error in the event the provided authentication tag does not match the given ciphertext (i.e. ciphertext is modified/unauthentic)
source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.