feat: both XEX enc/dec are working in atomic tests

This commit is contained in:
0xalivecow 2024-10-28 00:35:39 +01:00
parent 5c1c0f6c5e
commit c34557ea29
No known key found for this signature in database
6 changed files with 140 additions and 16 deletions

View file

@ -1,4 +1,7 @@
use anyhow::{Ok, Result};
use base64::Engine;
use crate::tasks::tasks01::gfmul::gfmul;
pub fn xor_bytes(vec1: &Vec<u8>, mut vec2: Vec<u8>) -> Result<Vec<u8>> {
for (byte1, byte2) in vec1.iter().zip(vec2.iter_mut()) {
@ -22,6 +25,13 @@ impl ByteArray {
carry
}
pub fn left_shift_reduce(&mut self) {
let alpha_poly: Vec<u8> = base64::prelude::BASE64_STANDARD
.decode("AgAAAAAAAAAAAAAAAAAAAA==")
.expect("Decode failed");
self.0 = gfmul(self.0.clone(), alpha_poly).unwrap();
}
pub fn right_shift(&mut self) -> u8 {
let mut carry = 0u8;
for byte in self.0.iter_mut().rev() {