Struct Cipher

Source
pub struct Cipher<C>
where C: BlockCipher<BlockSize = U16>,
{ /* private fields */ }
Expand description

Cipher is an instance of the HCTR2 cipher.

Implementations§

Source§

impl<C> Cipher<C>
where C: BlockCipher<BlockSize = U16> + BlockEncrypt + BlockDecrypt,

Source

pub fn encrypt(&mut self, ciphertext: &mut [u8], plaintext: &[u8], tweak: &[u8])

Encrypts plaintext into ciphertext using tweak.

It panics if either plaintext or ciphertext are less than BLOCK_SIZE bytes.

Source

pub fn decrypt(&mut self, plaintext: &mut [u8], ciphertext: &[u8], tweak: &[u8])

Decrypts ciphertext into plaintext using tweak.

It panics if either ciphertext or plaintext are less than BLOCK_SIZE bytes.

Source

pub fn encrypt_in_place(&mut self, plaintext: &mut [u8], tweak: &[u8])

Encrypts plaintext in-place using tweak.

It panics if plaintext is less than BLOCK_SIZE bytes.

Source

pub fn decrypt_in_place(&mut self, ciphertext: &mut [u8], tweak: &[u8])

Decrypts ciphertext in-place using tweak.

It panics if ciphertext is less than BLOCK_SIZE bytes.

Trait Implementations§

Source§

impl<C> Clone for Cipher<C>
where C: BlockCipher<BlockSize = U16> + Clone,

Source§

fn clone(&self) -> Cipher<C>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C> Drop for Cipher<C>
where C: BlockCipher<BlockSize = U16>,

Available on crate feature zeroize only.
Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<C> KeyInit for Cipher<C>
where C: BlockCipher<BlockSize = U16> + BlockEncrypt + KeyInit,

Source§

fn new(key: &Key<C>) -> Self

new creates an HCTR2 cipher.

The provided block cipher must have a block size of exactly BLOCK_SIZE bytes.

Source§

fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>

Create new value from variable size key.
Source§

impl<C> KeySizeUser for Cipher<C>
where C: BlockCipher<BlockSize = U16> + KeyInit,

Source§

type KeySize = <C as KeySizeUser>::KeySize

Key size in bytes.
Source§

fn key_size() -> usize

Return key size in bytes.
Source§

impl<C> ZeroizeOnDrop for Cipher<C>
where C: BlockCipher<BlockSize = U16>,

Available on crate feature zeroize only.

Auto Trait Implementations§

§

impl<C> Freeze for Cipher<C>
where C: Freeze,

§

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

§

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

§

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

§

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

§

impl<C> UnwindSafe for Cipher<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
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.