/// 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.
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).
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 ) .
pub fn decrypt_area(
        &self,
        area: &mut [u8],
        sector_size: usize,
        first_sector_index: u128,
        get_tweak_fn: impl Fn(u128) -> [u8; 16],
    ) {
        let area_len = area.len();
        let mut chunks = area.chunks_exact_mut(sector_size);
        for (i, chunk) in (&mut chunks).enumerate() {
            let tweak = get_tweak_fn(
                u128::try_from(i).expect("usize cannot be bigger than u128") + first_sector_index,
            );
            self.decrypt_sector(chunk, tweak);
        }
        let remainder = chunks.into_remainder();
        if !remainder.is_empty() {
            let i = area_len / sector_size;
            let tweak = get_tweak_fn(
                u128::try_from(i).expect("usize cannot be bigger than u128") + first_sector_index,
            );
            self.decrypt_sector(remainder, tweak);
        }
    }
pub fn decrypt_area ( & self , area : & mut [ u8 ] , sector_size : usize , first_sector_index : u128 , get_tweak_fn : impl Fn ( u128 ) -> [ u8 ; 16 ] , ) { let area_len = area . len ( ) ; let mut chunks = area . chunks_exact_mut ( sector_size ) ; for ( i , chunk ) in ( & mut chunks ) . enumerate ( ) { let tweak = get_tweak_fn ( u128 :: try_from ( i ) . expect ( " " ) + first_sector_index , ) ; self . decrypt_sector ( chunk , tweak ) ; } let remainder = chunks . into_remainder ( ) ; if ! remainder . is_empty ( ) { let i = area_len / sector_size ; let tweak = get_tweak_fn ( u128 :: try_from ( i ) . expect ( " " ) + first_sector_index , ) ; self . decrypt_sector ( remainder , tweak ) ; } }
Decrypts a whole area in place, usually consisting of multiple sectors.
Decrypts a whole area in place usually consisting of multiple sectors .
&self
area
&mut [u8]
sector_size
usize
first_sector_index
u128
get_tweak_fn
impl Fn(u128) -> [u8; 16]
panics
If the block size is not 16 bytes.
If there's less than a single block in the last sector.
If the block size is not 16 bytes . If there ' s less than a single block in the last sector .