Skip to main content

Eax

Struct Eax 

Source
pub struct Eax<C> { /* private fields */ }
Expand description

EAX AEAD with a full 16-byte detached tag.

Implementations§

Source§

impl<C> Eax<C>

Source

pub fn new(cipher: C) -> Self

Wrap a 128-bit block cipher in EAX mode.

Source

pub fn cipher(&self) -> &C

Borrow the wrapped cipher.

Source§

impl<C: BlockCipher> Eax<C>

Source

pub fn encrypt(&self, nonce: &[u8], aad: &[u8], data: &mut [u8]) -> [u8; 16]

Encrypt data in place and return a detached 16-byte tag.

Source

pub fn decrypt( &self, nonce: &[u8], aad: &[u8], data: &mut [u8], tag: &[u8; 16], ) -> bool

Verify and decrypt data in place.

Returns false and leaves data unchanged on authentication failure.

Trait Implementations§

Source§

impl<C: BlockCipher> Aead for Eax<C>

Source§

type Tag = [u8; 16]

Detached authentication tag type.
Source§

fn encrypt_in_place( &self, nonce: &[u8], aad: &[u8], data: &mut [u8], ) -> Self::Tag

Encrypt data in place and return its authentication tag.
Source§

fn decrypt_in_place( &self, nonce: &[u8], aad: &[u8], data: &mut [u8], tag: &Self::Tag, ) -> bool

Decrypt data in place after authenticating tag.
Source§

fn encrypt( &self, nonce: &[u8], aad: &[u8], plaintext: &[u8], ) -> (Vec<u8>, Self::Tag)

Encrypt plaintext and return (ciphertext, tag).
Source§

fn decrypt( &self, nonce: &[u8], aad: &[u8], ciphertext: &[u8], tag: &Self::Tag, ) -> Option<Vec<u8>>

Decrypt ciphertext and return plaintext on successful authentication.

Auto Trait Implementations§

§

impl<C> Freeze for Eax<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for Eax<C>
where C: RefUnwindSafe,

§

impl<C> Send for Eax<C>
where C: Send,

§

impl<C> Sync for Eax<C>
where C: Sync,

§

impl<C> Unpin for Eax<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for Eax<C>
where C: UnsafeUnpin,

§

impl<C> UnwindSafe for Eax<C>
where C: UnwindSafe,

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.