INNER CODE UNIT · Rust
wide_encrypt
AChep/keyguard-app · thirdParty/rust/ocb3-0.1.0-keyguard/src/lib.rs:382
fn wide_encrypt(&self, nonce: &Nonce<NonceSize>, buffer: &mut [u8]) -> (usize, Block, Block) {
const WIDTH: usize = 2;
let split_into_blocks = crate::util::split_into_two_blocks;
let mut i = 1;
let mut offset_i = [Block::default(); WIDTH];
offset_i[offset_i.len() - 1] = initial_offset(&self.cipher, nonce, TagSize::to_u32());
let mut checksum_i = Block::default();
for wide_blocks in buffer.chunks_exact_mut(16 * WIDTH) {
let p_i = split_into_blocks(wide_blocks);
// checksum_i = checksum_{i-1} xor p_i
for p_ij in &p_i {
inplace_xor(&mut checksum_i, p_ij);
}
// offset_i = offset_{i-1} xor L_{ntz(i)}