XChachaPoly

Struct XChachaPoly 

Source
pub struct XChachaPoly;
Expand description

An implementation of XChaChaPoly

Implementations§

Source§

impl XChachaPoly

Source

pub fn cipher() -> Box<dyn Cipher>

Creates a Cipher instance with XChachaPolyIetf as underlying cipher

Source

pub fn aead_cipher() -> Box<dyn AeadCipher>

Creates a AeadCipher instance with XChachaPolyIetf as underlying AEAD cipher

Trait Implementations§

Source§

impl AeadCipher for XChachaPoly

Source§

fn seal( &self, buf: &mut [u8], plaintext_len: usize, ad: &[u8], key: &[u8], nonce: &[u8], ) -> Result<usize, Box<dyn Error + 'static>>

AEAD-seals plaintext_len bytes in-place in buf together with ad using key and nonce and returns the ciphertext length
Source§

fn seal_to( &self, buf: &mut [u8], plaintext: &[u8], ad: &[u8], key: &[u8], nonce: &[u8], ) -> Result<usize, Box<dyn Error + 'static>>

AEAD-seals plaintext into buf together with ad using key and nonce and returns the ciphertext length
Source§

fn open( &self, buf: &mut [u8], ciphertext_len: usize, ad: &[u8], key: &[u8], nonce: &[u8], ) -> Result<usize, Box<dyn Error + 'static>>

AEAD-opens ciphertext_len bytes in-place in buf together with ad using key and nonce and returns the plaintext length
Source§

fn open_to( &self, buf: &mut [u8], ciphertext: &[u8], ad: &[u8], key: &[u8], nonce: &[u8], ) -> Result<usize, Box<dyn Error + 'static>>

AEAD-opens ciphertext into buf together with ad using key and nonce and returns the plaintext length
Source§

impl Cipher for XChachaPoly

Source§

fn info(&self) -> CipherInfo

Returns information about the cipher
Source§

fn encrypted_len_max(&self, plaintext_len: usize) -> usize

Predicts the maximum encrypted length for plaintext_len bytes
Source§

fn encrypt( &self, buf: &mut [u8], plaintext_len: usize, key: &[u8], nonce: &[u8], ) -> Result<usize, Box<dyn Error + 'static>>

Encrypts plaintext_len bytes in-place in buf using key and nonce and returns the ciphertext length
Source§

fn encrypt_to( &self, buf: &mut [u8], plaintext: &[u8], key: &[u8], nonce: &[u8], ) -> Result<usize, Box<dyn Error + 'static>>

Encrypts plaintext into buf using key and nonce and returns the ciphertext length
Source§

fn decrypt( &self, buf: &mut [u8], ciphertext_len: usize, key: &[u8], nonce: &[u8], ) -> Result<usize, Box<dyn Error + 'static>>

Decrypts ciphertext_len bytes in-place in buf using key and nonce and returns the plaintext length
Source§

fn decrypt_to( &self, buf: &mut [u8], ciphertext: &[u8], key: &[u8], nonce: &[u8], ) -> Result<usize, Box<dyn Error + 'static>>

Decrypts ciphertext into buf using key and nonce and returns the plaintext length
Source§

impl SecKeyGen for XChachaPoly

Source§

fn new_sec_key( &self, buf: &mut [u8], rng: &mut dyn SecureRng, ) -> Result<usize, Box<dyn Error + 'static>>

Generates a new key into buf using rng and returns the length of the secret key

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