[−][src]Struct pwbox::CipherWithMac
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]
C: UnauthenticatedCipher,
M: Mac,
const KEY_LEN: usize[src]
Equals to the sum of key sizes for the cipher and MAC.
const NONCE_LEN: usize[src]
const MAC_LEN: usize[src]
fn seal(message: &[u8], nonce: &[u8], key: &[u8]) -> CipherOutput[src]
Works as follows:
- Split the key into
cipher_key(first bytes of the key) andmac_key(remaining bytes). - Encrypt the
messageusing the cipher undercipher_keyandnonce. - Compute MAC over the ciphertext with
mac_key.
fn open(
output: &mut [u8],
enc: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>[src]
output: &mut [u8],
enc: &CipherOutput,
nonce: &[u8],
key: &[u8]
) -> Result<(), MacMismatch>
Works as follows:
- Split the key into
cipher_key(first bytes of the key) andmac_key(remaining bytes). - Compute MAC over the ciphertext with
mac_key. If MAC is not equal to the supplied one, returnNone. - Decrypt the ciphertext under the
cipher_keyandnonce.
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,
C: RefUnwindSafe,
M: RefUnwindSafe,
impl<C, M> Send for CipherWithMac<C, M> where
C: Send,
M: Send,
C: Send,
M: Send,
impl<C, M> Sync for CipherWithMac<C, M> where
C: Sync,
M: Sync,
C: Sync,
M: Sync,
impl<C, M> Unpin for CipherWithMac<C, M> where
C: Unpin,
M: Unpin,
C: Unpin,
M: Unpin,
impl<C, M> UnwindSafe for CipherWithMac<C, M> where
C: UnwindSafe,
M: UnwindSafe,
C: UnwindSafe,
M: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,