[−][src]Struct miscreant::siv::Siv
Synthetic Initialization Vector (SIV) mode, providing misuse-resistant authenticated encryption (MRAE).
Methods
impl<C, M> Siv<C, M> where
C: NewStreamCipher<NonceSize = U16> + SyncStreamCipher,
M: Mac<OutputSize = U16>,
[src]
impl<C, M> Siv<C, M> where
C: NewStreamCipher<NonceSize = U16> + SyncStreamCipher,
M: Mac<OutputSize = U16>,
pub fn new(key: &[u8]) -> Self | [src] |
Create a new AES-SIV instance
Panics if the key is the wrong length
pub fn seal_in_place<I, T>(&mut self, headers: I, plaintext: &mut [u8]) where | [src] |
Encrypt the given plaintext in-place, replacing it with the SIV tag and ciphertext. Requires a buffer with 16-bytes additional space.
Usage
It's important to note that only the end of the buffer will be treated as the input plaintext:
let buffer = [0u8; 21]; let plaintext = &buffer[..buffer.len() - 16];
In this case, only the last 5 bytes are treated as the plaintext,
since 21 - 16 = 5
(the AES block size is 16-bytes).
The buffer must include an additional 16-bytes of space in which to write the SIV tag (at the beginning of the buffer). Failure to account for this will leave you with plaintext messages that are missing their first 16-bytes!
Panics
Panics if plaintext.len()
is less than M::OutputSize
.
Panics if headers.len()
is greater than MAX_ASSOCIATED_DATA
.
pub fn open_in_place<'a, I, T>( | [src] |
Decrypt the given ciphertext in-place, authenticating it against the synthetic IV included in the message.
Returns a slice containing a decrypted message on success.
pub fn seal<I, T>(&mut self, associated_data: I, plaintext: &[u8]) -> Vec<u8> where | [src] |
Encrypt the given plaintext, allocating and returning a Vec
pub fn open<I, T>( | [src] |
Decrypt the given ciphertext, allocating and returning a Vec
Trait Implementations
impl<C, M> Drop for Siv<C, M> where
C: NewStreamCipher<NonceSize = U16> + SyncStreamCipher,
M: Mac<OutputSize = U16>,
[src]
impl<C, M> Drop for Siv<C, M> where
C: NewStreamCipher<NonceSize = U16> + SyncStreamCipher,
M: Mac<OutputSize = U16>,
Auto Trait Implementations
impl<C, M> Send for Siv<C, M> where
M: Send,
<C as NewStreamCipher>::KeySize: ArrayLength<u8>,
impl<C, M> Send for Siv<C, M> where
M: Send,
<C as NewStreamCipher>::KeySize: ArrayLength<u8>,
impl<C, M> Sync for Siv<C, M> where
M: Sync,
<C as NewStreamCipher>::KeySize: ArrayLength<u8>,
impl<C, M> Sync for Siv<C, M> where
M: Sync,
<C as NewStreamCipher>::KeySize: ArrayLength<u8>,
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> | [src] |
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error> | [src] |
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
ⓘImportant traits for &'_ mut I
fn borrow_mut(&mut self) -> &mut T | [src] |
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId | [src] |
impl<T> Same for T
impl<T> Same for T
type Output = T
Should always be Self