[][src]Struct xts_mode::Xts128

pub struct Xts128<C: BlockCipher> { /* fields omitted */ }

Xts128 block cipher. Does not implement implement BlockMode due to XTS differences detailed here.

Implementations

impl<C: BlockCipher> Xts128<C>[src]

pub fn new(cipher_1: C, cipher_2: C) -> Xts128<C>[src]

Creates a new Xts128 using two cipher instances: the first one's used to encrypt the blocks and the second one to compute the tweak at the start of each sector.

Usually both cipher's are the same algorithm and the key is stored as double sized (256 bits for Aes128), and the key is split in half, the first half used for cipher_1 and the other for cipher_2.

If you require support for different cipher types, or block sizes different than 16 bytes, open an issue.

pub fn encrypt_sector(&self, sector: &mut [u8], tweak: [u8; 16])[src]

Encrypts a single sector in place using the given tweak.

Panics

  • If the block size is not 16 bytes.
  • If there's less than a single block in the sector.

pub fn decrypt_sector(&self, sector: &mut [u8], tweak: [u8; 16])[src]

Decrypts a single sector in place using the given tweak.

Panics

  • If the block size is not 16 bytes.
  • If there's less than a single block in the sector.

pub fn encrypt_area(
    &self,
    area: &mut [u8],
    sector_size: usize,
    first_sector_index: u128,
    get_tweak_fn: impl Fn(u128) -> [u8; 16]
)
[src]

Encrypts a whole area in place, usually consisting of multiple sectors.

The tweak is computed at the start of every sector using get_tweak_fn(sector_index). get_tweak_fn is usually get_tweak_default.

Panics

  • If the block size is not 16 bytes.
  • If there's less than a single block in the last sector.

pub fn decrypt_area(
    &self,
    area: &mut [u8],
    sector_size: usize,
    first_sector_index: u128,
    get_tweak_fn: impl Fn(u128) -> [u8; 16]
)
[src]

Decrypts a whole area in place, usually consisting of multiple sectors.

The tweak is computed at the start of every sector using get_tweak_fn(sector_index). get_tweak_fn is usually get_tweak_default.

Panics

  • If the block size is not 16 bytes.
  • If there's less than a single block in the last sector.

Auto Trait Implementations

impl<C> RefUnwindSafe for Xts128<C> where
    C: RefUnwindSafe
[src]

impl<C> Send for Xts128<C> where
    C: Send
[src]

impl<C> Sync for Xts128<C> where
    C: Sync
[src]

impl<C> Unpin for Xts128<C> where
    C: Unpin
[src]

impl<C> UnwindSafe for Xts128<C> where
    C: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.