[−][src]Struct xts_mode::Xts128
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]
&self,
area: &mut [u8],
sector_size: usize,
first_sector_index: u128,
get_tweak_fn: impl Fn(u128) -> [u8; 16]
)
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]
&self,
area: &mut [u8],
sector_size: usize,
first_sector_index: u128,
get_tweak_fn: impl Fn(u128) -> [u8; 16]
)
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]
C: RefUnwindSafe,
impl<C> Send for Xts128<C> where
C: Send,
[src]
C: Send,
impl<C> Sync for Xts128<C> where
C: Sync,
[src]
C: Sync,
impl<C> Unpin for Xts128<C> where
C: Unpin,
[src]
C: Unpin,
impl<C> UnwindSafe for Xts128<C> where
C: UnwindSafe,
[src]
C: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,