diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-11-11 20:11:17 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-11-11 20:11:17 +0100 |
commit | fb8f4a68e12dc6659077b9397a7bc39059eff8f6 (patch) | |
tree | c76d8c77c2da864eca1af3638ee2712b8080a882 /java-c-jni | |
parent | m + fix for issue #14 (diff) | |
download | sha3sum-fb8f4a68e12dc6659077b9397a7bc39059eff8f6.tar.gz sha3sum-fb8f4a68e12dc6659077b9397a7bc39059eff8f6.tar.bz2 sha3sum-fb8f4a68e12dc6659077b9397a7bc39059eff8f6.tar.xz |
fix bug in the c versions for smaller state sizes
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | java-c-jni/SHA3.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/java-c-jni/SHA3.c b/java-c-jni/SHA3.c index 73b161d..e785406 100644 --- a/java-c-jni/SHA3.c +++ b/java-c-jni/SHA3.c @@ -274,14 +274,14 @@ static void keccakFRound(llong* A, llong rc) __C(4, 20, 21, 22, 23, 24); #undef __C - da = C[4] ^ rotate64(C[1], 1); - dd = C[2] ^ rotate64(C[4], 1); - db = C[0] ^ rotate64(C[2], 1); - de = C[3] ^ rotate64(C[0], 1); - dc = C[1] ^ rotate64(C[3], 1); - if (w == 64) { + da = C[4] ^ rotate64(C[1], 1); + dd = C[2] ^ rotate64(C[4], 1); + db = C[0] ^ rotate64(C[2], 1); + de = C[3] ^ rotate64(C[0], 1); + dc = C[1] ^ rotate64(C[3], 1); + /* ρ and π steps, with last two part of θ */ #define __B(Bi, Ai, Dv, R) B[Bi] = rotate64(A[Ai] ^ Dv, R) B[0] = A[0] ^ da; __B( 1, 15, dd, 28); __B( 2, 5, db, 1); __B( 3, 20, de, 27); __B( 4, 10, dc, 62); @@ -293,6 +293,12 @@ static void keccakFRound(llong* A, llong rc) } else { + da = C[4] ^ rotate(C[1], 1); + dd = C[2] ^ rotate(C[4], 1); + db = C[0] ^ rotate(C[2], 1); + de = C[3] ^ rotate(C[0], 1); + dc = C[1] ^ rotate(C[3], 1); + /* ρ and π steps, with last two part of θ */ #define __B(Bi, Ai, Dv, R) B[Bi] = rotate(A[Ai] ^ Dv, R) B[0] = A[0] ^ da; __B( 1, 15, dd, 28); __B( 2, 5, db, 1); __B( 3, 20, de, 27); __B( 4, 10, dc, 62); |