pub struct Siv<C, M> where
C: BlockCipher<BlockSize = U16> + BlockEncryptMut + KeyInit + KeySizeUser,
M: Mac<OutputSize = U16>, { /* private fields */ }
Expand description
Synthetic Initialization Vector (SIV) mode, providing misuse-resistant authenticated encryption (MRAE).
Implementations
sourceimpl<C, M> Siv<C, M> where
C: BlockCipher<BlockSize = U16> + BlockEncryptMut + KeyInit + KeySizeUser,
M: Mac<OutputSize = U16> + FixedOutputReset + KeyInit,
impl<C, M> Siv<C, M> where
C: BlockCipher<BlockSize = U16> + BlockEncryptMut + KeyInit + KeySizeUser,
M: Mac<OutputSize = U16> + FixedOutputReset + KeyInit,
sourcepub fn encrypt<I, T>(
&mut self,
headers: I,
plaintext: &[u8]
) -> Result<Vec<u8>, Error> where
I: IntoIterator<Item = T>,
T: AsRef<[u8]>,
pub fn encrypt<I, T>(
&mut self,
headers: I,
plaintext: &[u8]
) -> Result<Vec<u8>, Error> where
I: IntoIterator<Item = T>,
T: AsRef<[u8]>,
Encrypt the given plaintext, allocating and returning a Vec<u8>
for
the ciphertext.
Errors
Returns Error
if plaintext.len()
is less than M::OutputSize
.
Returns Error
if headers.len()
is greater than MAX_HEADERS
.
sourcepub fn encrypt_in_place<I, T>(
&mut self,
headers: I,
buffer: &mut dyn Buffer
) -> Result<(), Error> where
I: IntoIterator<Item = T>,
T: AsRef<[u8]>,
pub fn encrypt_in_place<I, T>(
&mut self,
headers: I,
buffer: &mut dyn Buffer
) -> Result<(), Error> where
I: IntoIterator<Item = T>,
T: AsRef<[u8]>,
Encrypt the given buffer containing a plaintext message in-place.
Errors
Returns Error
if plaintext.len()
is less than M::OutputSize
.
Returns Error
if headers.len()
is greater than MAX_HEADERS
.
sourcepub fn encrypt_in_place_detached<I, T>(
&mut self,
headers: I,
plaintext: &mut [u8]
) -> Result<Tag, Error> where
I: IntoIterator<Item = T>,
T: AsRef<[u8]>,
pub fn encrypt_in_place_detached<I, T>(
&mut self,
headers: I,
plaintext: &mut [u8]
) -> Result<Tag, Error> where
I: IntoIterator<Item = T>,
T: AsRef<[u8]>,
Encrypt the given plaintext in-place, returning the SIV tag on success.
Errors
Returns Error
if plaintext.len()
is less than M::OutputSize
.
Returns Error
if headers.len()
is greater than MAX_HEADERS
.
sourcepub fn decrypt<I, T>(
&mut self,
headers: I,
ciphertext: &[u8]
) -> Result<Vec<u8>, Error> where
I: IntoIterator<Item = T>,
T: AsRef<[u8]>,
pub fn decrypt<I, T>(
&mut self,
headers: I,
ciphertext: &[u8]
) -> Result<Vec<u8>, Error> where
I: IntoIterator<Item = T>,
T: AsRef<[u8]>,
Decrypt the given ciphertext, allocating and returning a Vec
sourcepub fn decrypt_in_place<I, T>(
&mut self,
headers: I,
buffer: &mut dyn Buffer
) -> Result<(), Error> where
I: IntoIterator<Item = T>,
T: AsRef<[u8]>,
pub fn decrypt_in_place<I, T>(
&mut self,
headers: I,
buffer: &mut dyn Buffer
) -> Result<(), Error> where
I: IntoIterator<Item = T>,
T: AsRef<[u8]>,
Decrypt the message in-place, returning an error in the event the provided authentication tag does not match the given ciphertext.
The buffer will be truncated to the length of the original plaintext message upon success.
sourcepub fn decrypt_in_place_detached<I, T>(
&mut self,
headers: I,
ciphertext: &mut [u8],
siv_tag: &Tag
) -> Result<(), Error> where
I: IntoIterator<Item = T>,
T: AsRef<[u8]>,
pub fn decrypt_in_place_detached<I, T>(
&mut self,
headers: I,
ciphertext: &mut [u8],
siv_tag: &Tag
) -> Result<(), Error> where
I: IntoIterator<Item = T>,
T: AsRef<[u8]>,
Trait Implementations
sourceimpl<C, M> Drop for Siv<C, M> where
C: BlockCipher<BlockSize = U16> + BlockEncryptMut + KeyInit + KeySizeUser,
M: Mac<OutputSize = U16>,
impl<C, M> Drop for Siv<C, M> where
C: BlockCipher<BlockSize = U16> + BlockEncryptMut + KeyInit + KeySizeUser,
M: Mac<OutputSize = U16>,
sourceimpl<C, M> KeyInit for Siv<C, M> where
C: BlockCipher<BlockSize = U16> + BlockEncryptMut + KeyInit + KeySizeUser,
M: Mac<OutputSize = U16> + FixedOutputReset + KeyInit,
<C as KeySizeUser>::KeySize: Add,
KeySize<C>: ArrayLength<u8>,
impl<C, M> KeyInit for Siv<C, M> where
C: BlockCipher<BlockSize = U16> + BlockEncryptMut + KeyInit + KeySizeUser,
M: Mac<OutputSize = U16> + FixedOutputReset + KeyInit,
<C as KeySizeUser>::KeySize: Add,
KeySize<C>: ArrayLength<u8>,
fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
Create new value from variable size key.
sourceimpl<C, M> KeySizeUser for Siv<C, M> where
C: BlockCipher<BlockSize = U16> + BlockEncryptMut + KeyInit + KeySizeUser,
M: Mac<OutputSize = U16> + FixedOutputReset + KeyInit,
<C as KeySizeUser>::KeySize: Add,
KeySize<C>: ArrayLength<u8>,
impl<C, M> KeySizeUser for Siv<C, M> where
C: BlockCipher<BlockSize = U16> + BlockEncryptMut + KeyInit + KeySizeUser,
M: Mac<OutputSize = U16> + FixedOutputReset + KeyInit,
<C as KeySizeUser>::KeySize: Add,
KeySize<C>: ArrayLength<u8>,
type KeySize = <<C as KeySizeUser>::KeySize as Add<<C as KeySizeUser>::KeySize>>::Output
type KeySize = <<C as KeySizeUser>::KeySize as Add<<C as KeySizeUser>::KeySize>>::Output
Key size in bytes.
Auto Trait Implementations
impl<C, M> RefUnwindSafe for Siv<C, M> where
M: RefUnwindSafe,
<<C as KeySizeUser>::KeySize as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
impl<C, M> Send for Siv<C, M> where
M: Send,
impl<C, M> Sync for Siv<C, M> where
M: Sync,
impl<C, M> Unpin for Siv<C, M> where
M: Unpin,
<<C as KeySizeUser>::KeySize as ArrayLength<u8>>::ArrayType: Unpin,
impl<C, M> UnwindSafe for Siv<C, M> where
M: UnwindSafe,
<<C as KeySizeUser>::KeySize as ArrayLength<u8>>::ArrayType: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more