chacha20poly1305

Struct ChaChaPoly1305

Source
pub struct ChaChaPoly1305<C, N: ArrayLength<u8> = U12> { /* 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 N: ArrayLength<u8>,

Source§

type NonceSize = N

The length of a nonce.
Source§

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

The maximum length of the nonce.
Source§

type CiphertextOverhead = UTerm

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

fn generate_nonce( rng: impl CryptoRng + RngCore, ) -> GenericArray<u8, Self::NonceSize>

Generate a random nonce for this AEAD algorithm. Read more
Source§

impl<C, N> AeadInPlace for ChaChaPoly1305<C, N>
where C: KeyIvInit<KeySize = U32, IvSize = 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 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 N: ArrayLength<u8>,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<C, N> KeyInit for ChaChaPoly1305<C, N>
where N: ArrayLength<u8>,

Source§

fn new(key: &Key) -> Self

Create new value from fixed size key.
Source§

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

Create new value from variable size key.
Source§

fn generate_key( rng: impl CryptoRng + RngCore, ) -> GenericArray<u8, Self::KeySize>

Generate random key using the provided CryptoRng.
Source§

impl<C, N> KeySizeUser for ChaChaPoly1305<C, N>
where N: ArrayLength<u8>,

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<C, N: ArrayLength<u8>> ZeroizeOnDrop for ChaChaPoly1305<C, N>

Auto Trait Implementations§

§

impl<C, N> Freeze for ChaChaPoly1305<C, N>

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

Source§

impl<Alg> Aead for Alg
where Alg: AeadInPlace,

Source§

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

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

impl<Alg> AeadMut for Alg
where 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>, 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>, Error>

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

impl<Alg> AeadMutInPlace for Alg
where 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 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

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 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.