Struct ChaCha20Poly1305

Source
pub struct ChaCha20Poly1305 { /* private fields */ }
Available on crate feature chacha20poly1305 only.
Expand description

OpenSSH variant of ChaCha20Poly1305: chacha20-poly1305@openssh.com as described in PROTOCOL.chacha20poly1305.

Differences from ChaCha20Poly1305-IETF as described in RFC8439:

  • Nonce is 64-bit instead of 96-bit (i.e. uses legacy “djb” ChaCha20 variant).
  • The AAD and ciphertext inputs of Poly1305 are not padded.
  • The lengths of ciphertext and AAD are not authenticated using Poly1305.
  • Maximum supported AAD size is 16.

§Usage notes

  • In the context of SSH packet encryption, AAD will be 4 bytes and contain the encrypted length.
  • In the context of SSH key encryption, AAD will be empty.

Trait Implementations§

Source§

impl AeadCore for ChaCha20Poly1305

Source§

const TAG_POSITION: TagPosition = TagPosition::Postfix

The AEAD tag position.
Source§

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

The length of a nonce.
Source§

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

The maximum length of the tag.
Source§

impl AeadInOut for ChaCha20Poly1305

Source§

fn encrypt_inout_detached( &self, nonce: &ChaChaNonce, associated_data: &[u8], buffer: InOutBuf<'_, '_, u8>, ) -> Result<Tag>

Encrypt the data in the provided InOutBuf, returning the authentication tag.
Source§

fn decrypt_inout_detached( &self, nonce: &ChaChaNonce, associated_data: &[u8], buffer: InOutBuf<'_, '_, u8>, tag: &Tag, ) -> Result<()>

Decrypt the data in the provided InOutBuf, returning an error in the event the provided authentication tag is invalid for the given ciphertext (i.e. ciphertext is modified/unauthentic)
Source§

fn encrypt_in_place( &self, nonce: &Array<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: &Array<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 Clone for ChaCha20Poly1305

Source§

fn clone(&self) -> ChaCha20Poly1305

Returns a duplicate 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 Drop for ChaCha20Poly1305

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl KeyInit for ChaCha20Poly1305

Source§

fn new(key: &ChaChaKey) -> Self

Create new value from fixed size key.
Source§

fn weak_key_test(_key: &Array<u8, Self::KeySize>) -> Result<(), WeakKeyError>

Check if the key might be considered weak.
Source§

fn new_checked(key: &Array<u8, Self::KeySize>) -> Result<Self, WeakKeyError>

Create new value from fixed size key after checking it for weakness.
Source§

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

Create new value from variable size key.
Source§

impl KeySizeUser for ChaCha20Poly1305

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 ZeroizeOnDrop for ChaCha20Poly1305

Available on crate feature zeroize only.

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.