Chctr2

Struct Chctr2 

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

Generic CHCTR2 cipher parameterized by AES key size.

Implementations§

Source§

impl<Aes: AesCipher> Chctr2<Aes>

Source

pub const KEY_LENGTH: usize

Total key length in bytes (two AES keys).

Source

pub const SINGLE_KEY_LENGTH: usize = Aes::KEY_LEN

Single AES key length.

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_split(key1: &[u8], key2: &[u8]) -> Self

Initialize CHCTR2 from two separate keys.

Source

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

Encrypt plaintext to ciphertext using CHCTR2.

Source

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

Decrypt ciphertext to plaintext using CHCTR2.

Source§

impl Chctr2<Aes128>

Source

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

Initialize CHCTR2-128 from a combined key (K1 || K2).

Source§

impl Chctr2<Aes256>

Source

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

Initialize CHCTR2-256 from a combined key (K1 || K2).

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<Aes> UnwindSafe for Chctr2<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.