Cipher

Struct Cipher 

Source
pub struct Cipher<StreamAlg, BlockAlg>
where StreamAlg: KeySizeUser,
{ /* private fields */ }
Expand description

The Adiantum cipher. Implements KeyInit where key size is equal to key size of the underlying stream cipher.

Implementations§

Source§

impl<StreamAlg, BlockAlg> Cipher<StreamAlg, BlockAlg>
where StreamAlg: KeyIvInit + StreamCipher, StreamAlg::IvSize: IsGreaterOrEqual<U16>, BlockAlg: BlockEncrypt + BlockSizeUser<BlockSize = U16>,

Source

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

page length must be in 0x10..=0x1000 range and divisible by 0x10 tweak must be not greater 0x20

Source§

impl<StreamAlg, BlockAlg> Cipher<StreamAlg, BlockAlg>
where StreamAlg: KeyIvInit + StreamCipher, StreamAlg::IvSize: IsGreaterOrEqual<U16>, BlockAlg: BlockDecrypt + BlockSizeUser<BlockSize = U16>,

Source

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

page length must be in 0x10..=0x1000 and divisible by 0x10 tweak must be not greater 0x20

Trait Implementations§

Source§

impl<StreamAlg, BlockAlg> Drop for Cipher<StreamAlg, BlockAlg>
where StreamAlg: KeySizeUser,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<StreamAlg, BlockAlg> KeyInit for Cipher<StreamAlg, BlockAlg>
where StreamAlg: KeyIvInit + StreamCipher, BlockAlg: KeyInit,

Source§

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

Create new value from fixed size key.
Source§

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

Create new value from variable size key.
Source§

impl<StreamAlg, BlockAlg> KeySizeUser for Cipher<StreamAlg, BlockAlg>
where StreamAlg: KeySizeUser,

Source§

type KeySize = <StreamAlg as KeySizeUser>::KeySize

Key size in bytes.
Source§

fn key_size() -> usize

Return key size in bytes.

Auto Trait Implementations§

§

impl<StreamAlg, BlockAlg> Freeze for Cipher<StreamAlg, BlockAlg>
where BlockAlg: Freeze, <<StreamAlg as KeySizeUser>::KeySize as ArrayLength<u8>>::ArrayType: Freeze,

§

impl<StreamAlg, BlockAlg> RefUnwindSafe for Cipher<StreamAlg, BlockAlg>
where BlockAlg: RefUnwindSafe, <<StreamAlg as KeySizeUser>::KeySize as ArrayLength<u8>>::ArrayType: RefUnwindSafe, StreamAlg: RefUnwindSafe,

§

impl<StreamAlg, BlockAlg> Send for Cipher<StreamAlg, BlockAlg>
where BlockAlg: Send, StreamAlg: Send,

§

impl<StreamAlg, BlockAlg> Sync for Cipher<StreamAlg, BlockAlg>
where BlockAlg: Sync, StreamAlg: Sync,

§

impl<StreamAlg, BlockAlg> Unpin for Cipher<StreamAlg, BlockAlg>
where BlockAlg: Unpin, <<StreamAlg as KeySizeUser>::KeySize as ArrayLength<u8>>::ArrayType: Unpin, StreamAlg: Unpin,

§

impl<StreamAlg, BlockAlg> UnwindSafe for Cipher<StreamAlg, BlockAlg>
where BlockAlg: UnwindSafe, <<StreamAlg as KeySizeUser>::KeySize as ArrayLength<u8>>::ArrayType: UnwindSafe, StreamAlg: 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.