refactor: externalise gfmul to make it more accessible and semantic support

This commit is contained in:
0xalivecow 2024-10-29 13:53:10 +01:00
parent 31050ea696
commit f4c49a9137
No known key found for this signature in database
5 changed files with 96 additions and 64 deletions

View file

@ -83,7 +83,7 @@ pub fn xex_encrypt(mut key: Vec<u8>, tweak: &Vec<u8>, input: &Vec<u8>) -> Result
let cypher_block_intermediate = sea_128_encrypt(&key, &plaintext_intermediate)?;
let mut cypher_block = xor_bytes(&tweak_block.0, cypher_block_intermediate)?;
output.append(cypher_block.as_mut());
tweak_block.left_shift_reduce();
tweak_block.left_shift_reduce("xex");
}
Ok(output)
@ -116,7 +116,7 @@ pub fn xex_decrypt(mut key: Vec<u8>, tweak: &Vec<u8>, input: &Vec<u8>) -> Result
let plaintext_block_intermediate = sea_128_decrypt(&key, &cyphertext_intermediate)?;
let mut cypher_block = xor_bytes(&tweak_block.0, plaintext_block_intermediate)?;
output.append(cypher_block.as_mut());
tweak_block.left_shift_reduce();
tweak_block.left_shift_reduce("xex");
}
Ok(output)