[][src]Struct pwbox::CipherWithMac

pub struct CipherWithMac<C, M> { /* fields omitted */ }

Authenticated cipher constructed from an ordinary symmetric cipher and a MAC construction.

See Cipher implementation for details how this implementation works.

Trait Implementations

impl<C, M> Cipher for CipherWithMac<C, M> where
    C: UnauthenticatedCipher,
    M: Mac
[src]

const KEY_LEN: usize[src]

Equals to the sum of key sizes for the cipher and MAC.

fn seal(message: &[u8], nonce: &[u8], key: &[u8]) -> CipherOutput[src]

Works as follows:

  1. Split the key into cipher_key (first bytes of the key) and mac_key (remaining bytes).
  2. Encrypt the message using the cipher under cipher_key and nonce.
  3. Compute MAC over the ciphertext with mac_key.

fn open(
    output: &mut [u8],
    enc: &CipherOutput,
    nonce: &[u8],
    key: &[u8]
) -> Result<(), MacMismatch>
[src]

Works as follows:

  1. Split the key into cipher_key (first bytes of the key) and mac_key (remaining bytes).
  2. Compute MAC over the ciphertext with mac_key. If MAC is not equal to the supplied one, return None.
  3. Decrypt the ciphertext under the cipher_key and nonce.

impl<C: Debug, M: Debug> Debug for CipherWithMac<C, M>[src]

Auto Trait Implementations

impl<C, M> RefUnwindSafe for CipherWithMac<C, M> where
    C: RefUnwindSafe,
    M: RefUnwindSafe

impl<C, M> Send for CipherWithMac<C, M> where
    C: Send,
    M: Send

impl<C, M> Sync for CipherWithMac<C, M> where
    C: Sync,
    M: Sync

impl<C, M> Unpin for CipherWithMac<C, M> where
    C: Unpin,
    M: Unpin

impl<C, M> UnwindSafe for CipherWithMac<C, M> where
    C: UnwindSafe,
    M: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.