feat: add more shifting capabilities for gfmul
This commit is contained in:
parent
f4c49a9137
commit
ccf0b03ec0
2 changed files with 57 additions and 17 deletions
|
|
@ -19,21 +19,21 @@ pub fn gfmul(poly_a: Vec<u8>, poly_b: Vec<u8>, semantic: &str) -> Result<Vec<u8>
|
|||
|
||||
if poly2.LSB_is_one() {
|
||||
result.xor_byte_arrays(&poly1);
|
||||
poly2.right_shift(semantic);
|
||||
poly2.right_shift(semantic)?;
|
||||
} else {
|
||||
poly2.right_shift(semantic);
|
||||
poly2.right_shift(semantic)?;
|
||||
}
|
||||
|
||||
while !poly2.is_empty() {
|
||||
if poly2.LSB_is_one() {
|
||||
poly1.left_shift();
|
||||
poly1.left_shift(semantic)?;
|
||||
poly1.xor_byte_arrays(&red_poly_bytes);
|
||||
result.xor_byte_arrays(&poly1);
|
||||
} else {
|
||||
poly1.left_shift();
|
||||
poly1.left_shift(semantic)?;
|
||||
poly1.xor_byte_arrays(&red_poly_bytes);
|
||||
}
|
||||
poly2.right_shift(semantic);
|
||||
poly2.right_shift(semantic)?;
|
||||
}
|
||||
|
||||
result.0.remove(16);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue