aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-02-05 01:29:20 +0100
committerMattias Andrée <maandree@operamail.com>2013-02-05 01:29:20 +0100
commitf302ecfb119b4a0909652258d648b14c2353629c (patch)
tree9b707f1caf4f5ec6daf10e42ae0ffe442a8d1720
parentdifferent commands for different output sizes (diff)
downloadsha3sum-f302ecfb119b4a0909652258d648b14c2353629c.tar.gz
sha3sum-f302ecfb119b4a0909652258d648b14c2353629c.tar.bz2
sha3sum-f302ecfb119b4a0909652258d648b14c2353629c.tar.xz
optimise keccak-f and rotate
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--java/SHA3.java32
1 files changed, 4 insertions, 28 deletions
diff --git a/java/SHA3.java b/java/SHA3.java
index bb1daf9..abf2ebc 100644
--- a/java/SHA3.java
+++ b/java/SHA3.java
@@ -132,8 +132,8 @@ public class SHA3
*/
private static long rotate(long x, int n)
{
- long m = n % SHA3.w;
- return ((x >>> (SHA3.w - m)) + (x << m)) & SHA3.wmod;
+ long m;
+ return ((x >>> (SHA3.w - (m = n % SHA3.w))) + (x << m)) & SHA3.wmod;
}
@@ -307,32 +307,8 @@ public class SHA3
private static void keccakF(long[] A)
{
if (SHA3.nr == 24)
- {
- SHA3.keccakFRound(A, 0x0000000000000001L);
- SHA3.keccakFRound(A, 0x0000000000008082L);
- SHA3.keccakFRound(A, 0x800000000000808AL);
- SHA3.keccakFRound(A, 0x8000000080008000L);
- SHA3.keccakFRound(A, 0x000000000000808BL);
- SHA3.keccakFRound(A, 0x0000000080000001L);
- SHA3.keccakFRound(A, 0x8000000080008081L);
- SHA3.keccakFRound(A, 0x8000000000008009L);
- SHA3.keccakFRound(A, 0x000000000000008AL);
- SHA3.keccakFRound(A, 0x0000000000000088L);
- SHA3.keccakFRound(A, 0x0000000080008009L);
- SHA3.keccakFRound(A, 0x000000008000000AL);
- SHA3.keccakFRound(A, 0x000000008000808BL);
- SHA3.keccakFRound(A, 0x800000000000008BL);
- SHA3.keccakFRound(A, 0x8000000000008089L);
- SHA3.keccakFRound(A, 0x8000000000008003L);
- SHA3.keccakFRound(A, 0x8000000000008002L);
- SHA3.keccakFRound(A, 0x8000000000000080L);
- SHA3.keccakFRound(A, 0x000000000000800AL);
- SHA3.keccakFRound(A, 0x800000008000000AL);
- SHA3.keccakFRound(A, 0x8000000080008081L);
- SHA3.keccakFRound(A, 0x8000000000008080L);
- SHA3.keccakFRound(A, 0x0000000080000001L);
- SHA3.keccakFRound(A, 0x8000000080008008L);
- }
+ for (int i = 0; i < SHA3.nr; i++)
+ SHA3.keccakFRound(A, SHA3.RC[i]);
else
for (int i = 0; i < SHA3.nr; i++)
SHA3.keccakFRound(A, SHA3.RC[i] & SHA3.wmod);