Revert "Merge branch 'master' of github.com:Guilleag01/sha3"
This reverts commitc344498fb6, reversing changes made to315b85b2f5.
This commit is contained in:
@@ -256,34 +256,3 @@ pub const LFSR_LUT: [(bool, u8); 256] = [
|
|||||||
(false, 0x8d),
|
(false, 0x8d),
|
||||||
(true, 0x8f),
|
(true, 0x8f),
|
||||||
];
|
];
|
||||||
|
|
||||||
pub const R_TABLE: [usize; 24] = [
|
|
||||||
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14, 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44,
|
|
||||||
];
|
|
||||||
|
|
||||||
pub const XOR_TABLE: [u64; 24] = [
|
|
||||||
0x1,
|
|
||||||
0x8083,
|
|
||||||
0x8000000000000009,
|
|
||||||
0x80008009,
|
|
||||||
0x80000082,
|
|
||||||
0x83,
|
|
||||||
0x8000000080008002,
|
|
||||||
0x8000000b,
|
|
||||||
0x80000081,
|
|
||||||
0x80000009,
|
|
||||||
0x8000,
|
|
||||||
0x8000800a,
|
|
||||||
0x81,
|
|
||||||
0x800000000000000a,
|
|
||||||
0x8083,
|
|
||||||
0x8000000000000080,
|
|
||||||
0x8082,
|
|
||||||
0x8000000000008002,
|
|
||||||
0x8000000000000008,
|
|
||||||
0x80000002,
|
|
||||||
0x8000000000008083,
|
|
||||||
0x3,
|
|
||||||
0x80000002,
|
|
||||||
0x800000000000800a,
|
|
||||||
];
|
|
||||||
|
|||||||
26
src/sha3.rs
26
src/sha3.rs
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
use std::array;
|
use std::array;
|
||||||
|
|
||||||
use crate::consts::*;
|
use crate::consts::LFSR_LUT;
|
||||||
|
|
||||||
const RATE_256: usize = 136;
|
const RATE_256: usize = 136;
|
||||||
const TOTAL_STATE_SIZE: usize = 200;
|
const TOTAL_STATE_SIZE: usize = 200;
|
||||||
@@ -82,11 +82,11 @@ fn keccak_permute(input: &mut [u8; TOTAL_STATE_SIZE]) {
|
|||||||
for _ in 0..ROUNDS {
|
for _ in 0..ROUNDS {
|
||||||
// θ step
|
// θ step
|
||||||
let c: [u64; 5] = array::from_fn(|x| {
|
let c: [u64; 5] = array::from_fn(|x| {
|
||||||
get_lane(lanes, x, 0)
|
get_lane2(lanes, x, 0)
|
||||||
^ get_lane(lanes, x, 1)
|
^ get_lane2(lanes, x, 1)
|
||||||
^ get_lane(lanes, x, 2)
|
^ get_lane2(lanes, x, 2)
|
||||||
^ get_lane(lanes, x, 3)
|
^ get_lane2(lanes, x, 3)
|
||||||
^ get_lane(lanes, x, 4)
|
^ get_lane2(lanes, x, 4)
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut d: u64;
|
let mut d: u64;
|
||||||
@@ -95,13 +95,13 @@ fn keccak_permute(input: &mut [u8; TOTAL_STATE_SIZE]) {
|
|||||||
d = c[(x + 4) % 5] ^ rol64(c[(x + 1) % 5], 1);
|
d = c[(x + 4) % 5] ^ rol64(c[(x + 1) % 5], 1);
|
||||||
|
|
||||||
for y in 0..5 {
|
for y in 0..5 {
|
||||||
xor_lane(d, lanes, x, y);
|
xor_lane2(d, lanes, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ρ and π steps
|
// ρ and π steps
|
||||||
let (mut x, mut y) = (1, 0);
|
let (mut x, mut y) = (1, 0);
|
||||||
let mut current = get_lane(lanes, x, y);
|
let mut current = get_lane2(lanes, x, y);
|
||||||
let mut temp: u64;
|
let mut temp: u64;
|
||||||
|
|
||||||
for t in 0..24 {
|
for t in 0..24 {
|
||||||
@@ -110,8 +110,8 @@ fn keccak_permute(input: &mut [u8; TOTAL_STATE_SIZE]) {
|
|||||||
x = y;
|
x = y;
|
||||||
y = y2;
|
y = y2;
|
||||||
|
|
||||||
temp = get_lane(lanes, x, y);
|
temp = get_lane2(lanes, x, y);
|
||||||
set_lane(rol64(current, r), x, y, lanes);
|
set_lane2(rol64(current, r), x, y, lanes);
|
||||||
current = temp;
|
current = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ fn keccak_permute(input: &mut [u8; TOTAL_STATE_SIZE]) {
|
|||||||
for y in 0..5 {
|
for y in 0..5 {
|
||||||
let temp2: [u64; 5] = array::from_fn(|x| get_lane2(lanes, x, y));
|
let temp2: [u64; 5] = array::from_fn(|x| get_lane2(lanes, x, y));
|
||||||
for x in 0..5 {
|
for x in 0..5 {
|
||||||
set_lane(
|
set_lane2(
|
||||||
temp2[x] ^ ((!temp2[(x + 1) % 5]) & temp2[(x + 2) % 5]),
|
temp2[x] ^ ((!temp2[(x + 1) % 5]) & temp2[(x + 2) % 5]),
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
@@ -130,8 +130,8 @@ fn keccak_permute(input: &mut [u8; TOTAL_STATE_SIZE]) {
|
|||||||
|
|
||||||
// ι step
|
// ι step
|
||||||
|
|
||||||
// println!("aaaa");
|
|
||||||
for j in 0..7 {
|
for j in 0..7 {
|
||||||
|
let bit_pos: usize = (1 << j) - 1;
|
||||||
let (lfsr_out, new_lfsr) = LFSR_LUT[lfsr_state as usize];
|
let (lfsr_out, new_lfsr) = LFSR_LUT[lfsr_state as usize];
|
||||||
lfsr_state = new_lfsr;
|
lfsr_state = new_lfsr;
|
||||||
|
|
||||||
@@ -139,8 +139,6 @@ fn keccak_permute(input: &mut [u8; TOTAL_STATE_SIZE]) {
|
|||||||
xor_lane2((1_u64) << bit_pos, lanes, 0, 0);
|
xor_lane2((1_u64) << bit_pos, lanes, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// lanes[0] ^= XOR_TABLE[round];
|
|
||||||
// println!("bbbb");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user