Hctr2

Struct Hctr2 

Source
pub struct Hctr2<Aes: AesCipher> { /* private fields */ }
Expand description

Generic HCTR2 cipher parameterized by AES key size.

Implementations§

Source§

impl<Aes: AesCipher> Hctr2<Aes>

Source

pub const KEY_LENGTH: usize = Aes::KEY_LEN

Encryption key length in bytes.

Source

pub const BLOCK_LENGTH: usize = BLOCK_LENGTH

AES block length in bytes (always 16).

Source

pub const MIN_INPUT_LENGTH: usize = BLOCK_LENGTH

Minimum input length in bytes.

Source

pub fn new(key: &[u8]) -> Self

Initialize HCTR2 cipher state from an encryption key.

Source

pub fn encrypt( &self, plaintext: &[u8], tweak: &[u8], ciphertext: &mut [u8], ) -> Result<(), Error>

Encrypt plaintext to ciphertext using HCTR2.

§Arguments
  • plaintext - Input data to encrypt (minimum 16 bytes)
  • tweak - Tweak value for domain separation
  • ciphertext - Output buffer (must be same length as plaintext)
§Errors

Returns Error::InputTooShort if plaintext is less than 16 bytes.

Source

pub fn decrypt( &self, ciphertext: &[u8], tweak: &[u8], plaintext: &mut [u8], ) -> Result<(), Error>

Decrypt ciphertext to plaintext using HCTR2.

§Arguments
  • ciphertext - Input data to decrypt (minimum 16 bytes)
  • tweak - Tweak value used during encryption
  • plaintext - Output buffer (must be same length as ciphertext)
§Errors

Returns Error::InputTooShort if ciphertext is less than 16 bytes.

Auto Trait Implementations§

§

impl<Aes> Freeze for Hctr2<Aes>
where Aes: Freeze, <Aes as AesCipher>::Dec: Freeze,

§

impl<Aes> RefUnwindSafe for Hctr2<Aes>
where Aes: RefUnwindSafe, <Aes as AesCipher>::Dec: RefUnwindSafe,

§

impl<Aes> Send for Hctr2<Aes>
where Aes: Send, <Aes as AesCipher>::Dec: Send,

§

impl<Aes> Sync for Hctr2<Aes>
where Aes: Sync, <Aes as AesCipher>::Dec: Sync,

§

impl<Aes> Unpin for Hctr2<Aes>
where Aes: Unpin, <Aes as AesCipher>::Dec: Unpin,

§

impl<Aes> UnwindSafe for Hctr2<Aes>
where Aes: UnwindSafe, <Aes as AesCipher>::Dec: 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> 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.