Skip to main content

Siv

Struct Siv 

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

RFC 5297 SIV construction parameterized by two block-cipher instances.

Implementations§

Source§

impl<C> Siv<C>

Source

pub fn new(mac_cipher: C, ctr_cipher: C) -> Self

Construct from separate CMAC and CTR ciphers.

Source

pub fn mac_cipher(&self) -> &C

Borrow the CMAC-side cipher.

Source

pub fn ctr_cipher(&self) -> &C

Borrow the CTR-side cipher.

Source§

impl<C: BlockCipher> Siv<C>

Source

pub fn encrypt_with_components( &self, components: &[&[u8]], plaintext: &[u8], ) -> (Vec<u8>, [u8; 16])

Encrypt using an explicit ordered vector of associated-data components.

Source

pub fn decrypt_with_components( &self, components: &[&[u8]], ciphertext: &mut [u8], tag: &[u8; 16], ) -> bool

Decrypt/authenticate using an explicit vector of associated-data components.

Source

pub fn encrypt( &self, nonce: &[u8], aad: &[u8], plaintext: &[u8], ) -> (Vec<u8>, [u8; 16])

Encrypt and return (ciphertext, detached_tag).

RFC 5297 treats the nonce as an associated-data component.

Source

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

Authenticate and decrypt in place.

Returns false and leaves ciphertext unchanged on failure.

Trait Implementations§

Source§

impl<C: BlockCipher> Aead for Siv<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 Siv<C>
where C: Freeze,

§

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

§

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

§

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

§

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

§

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

§

impl<C> UnwindSafe for Siv<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.