primitives/ciphers/
block.rs1use aes::{cipher::BlockEncrypt, Aes128Enc};
2
3use crate::algebra::field::binary::Gf2_128;
4
5pub type U8x16 = Gf2_128;
6
7pub trait BlockCipher {
8 type Block: AsRef<[u8]> + AsMut<[u8]> + Default + Copy;
9
10 fn block_byte_len() -> usize;
11 fn encrypt(&self, inp: &Self::Block) -> Self::Block;
12}
13
14impl BlockCipher for Aes128Enc {
15 type Block = Gf2_128;
16
17 fn block_byte_len() -> usize {
18 16
19 }
20
21 fn encrypt(&self, block: &U8x16) -> U8x16 {
22 let mut out_block = U8x16::default();
23 self.encrypt_block_b2b(&block.to_le_block(), out_block.as_ne_block_mut());
24 out_block
25 }
26}