aboutsummaryrefslogtreecommitdiffstats
path: root/sha3sum.py
diff options
context:
space:
mode:
Diffstat (limited to 'sha3sum.py')
-rwxr-xr-xsha3sum.py136
1 files changed, 91 insertions, 45 deletions
diff --git a/sha3sum.py b/sha3sum.py
index 0e9e0dc..872edce 100755
--- a/sha3sum.py
+++ b/sha3sum.py
@@ -389,36 +389,59 @@ class SHA3:
if ww == 8:
for i in range(0, nnn, rr):
SHA3.S[ 0] ^= SHA3.toLane64(message, rr, 0)
- SHA3.S[ 1] ^= SHA3.toLane64(message, rr, 8)
- SHA3.S[ 2] ^= SHA3.toLane64(message, rr, 16)
- SHA3.S[ 3] ^= SHA3.toLane64(message, rr, 24)
- SHA3.S[ 4] ^= SHA3.toLane64(message, rr, 32)
- SHA3.S[ 5] ^= SHA3.toLane64(message, rr, 40)
+ SHA3.S[ 5] ^= SHA3.toLane64(message, rr, 8)
+ SHA3.S[10] ^= SHA3.toLane64(message, rr, 16)
+ SHA3.S[15] ^= SHA3.toLane64(message, rr, 24)
+ SHA3.S[20] ^= SHA3.toLane64(message, rr, 32)
+ SHA3.S[ 1] ^= SHA3.toLane64(message, rr, 40)
SHA3.S[ 6] ^= SHA3.toLane64(message, rr, 48)
- SHA3.S[ 7] ^= SHA3.toLane64(message, rr, 56)
- SHA3.S[ 8] ^= SHA3.toLane64(message, rr, 64)
- SHA3.S[ 9] ^= SHA3.toLane64(message, rr, 72)
- SHA3.S[10] ^= SHA3.toLane64(message, rr, 80)
- SHA3.S[11] ^= SHA3.toLane64(message, rr, 88)
+ SHA3.S[11] ^= SHA3.toLane64(message, rr, 56)
+ SHA3.S[16] ^= SHA3.toLane64(message, rr, 64)
+ SHA3.S[21] ^= SHA3.toLane64(message, rr, 72)
+ SHA3.S[ 2] ^= SHA3.toLane64(message, rr, 80)
+ SHA3.S[ 7] ^= SHA3.toLane64(message, rr, 88)
SHA3.S[12] ^= SHA3.toLane64(message, rr, 96)
- SHA3.S[13] ^= SHA3.toLane64(message, rr, 104)
- SHA3.S[14] ^= SHA3.toLane64(message, rr, 112)
- SHA3.S[15] ^= SHA3.toLane64(message, rr, 120)
- SHA3.S[16] ^= SHA3.toLane64(message, rr, 128)
- SHA3.S[17] ^= SHA3.toLane64(message, rr, 136)
+ SHA3.S[17] ^= SHA3.toLane64(message, rr, 104)
+ SHA3.S[22] ^= SHA3.toLane64(message, rr, 112)
+ SHA3.S[ 3] ^= SHA3.toLane64(message, rr, 120)
+ SHA3.S[ 8] ^= SHA3.toLane64(message, rr, 128)
+ SHA3.S[13] ^= SHA3.toLane64(message, rr, 136)
SHA3.S[18] ^= SHA3.toLane64(message, rr, 144)
- SHA3.S[19] ^= SHA3.toLane64(message, rr, 152)
- SHA3.S[20] ^= SHA3.toLane64(message, rr, 160)
- SHA3.S[21] ^= SHA3.toLane64(message, rr, 168)
- SHA3.S[22] ^= SHA3.toLane64(message, rr, 176)
- SHA3.S[23] ^= SHA3.toLane64(message, rr, 184)
+ SHA3.S[23] ^= SHA3.toLane64(message, rr, 152)
+ SHA3.S[ 4] ^= SHA3.toLane64(message, rr, 160)
+ SHA3.S[ 9] ^= SHA3.toLane64(message, rr, 168)
+ SHA3.S[14] ^= SHA3.toLane64(message, rr, 176)
+ SHA3.S[19] ^= SHA3.toLane64(message, rr, 184)
SHA3.S[24] ^= SHA3.toLane64(message, rr, 192)
SHA3.keccakF(SHA3.S)
message = message[rr:]
else:
for i in range(0, nnn, rr):
- for j in range(25):
- SHA3.S[j] ^= SHA3.toLane(message, rr, ww, j * ww)
+ SHA3.S[ 0] ^= SHA3.toLane(message, rr, ww, 0)
+ SHA3.S[ 5] ^= SHA3.toLane(message, rr, ww, ww)
+ SHA3.S[10] ^= SHA3.toLane(message, rr, ww, 2 * ww)
+ SHA3.S[15] ^= SHA3.toLane(message, rr, ww, 3 * ww)
+ SHA3.S[20] ^= SHA3.toLane(message, rr, ww, 4 * ww)
+ SHA3.S[ 1] ^= SHA3.toLane(message, rr, ww, 5 * ww)
+ SHA3.S[ 6] ^= SHA3.toLane(message, rr, ww, 6 * ww)
+ SHA3.S[11] ^= SHA3.toLane(message, rr, ww, 7 * ww)
+ SHA3.S[16] ^= SHA3.toLane(message, rr, ww, 8 * ww)
+ SHA3.S[21] ^= SHA3.toLane(message, rr, ww, 9 * ww)
+ SHA3.S[ 2] ^= SHA3.toLane(message, rr, ww, 10 * ww)
+ SHA3.S[ 7] ^= SHA3.toLane(message, rr, ww, 11 * ww)
+ SHA3.S[12] ^= SHA3.toLane(message, rr, ww, 12 * ww)
+ SHA3.S[17] ^= SHA3.toLane(message, rr, ww, 13 * ww)
+ SHA3.S[22] ^= SHA3.toLane(message, rr, ww, 14 * ww)
+ SHA3.S[ 3] ^= SHA3.toLane(message, rr, ww, 15 * ww)
+ SHA3.S[ 8] ^= SHA3.toLane(message, rr, ww, 16 * ww)
+ SHA3.S[13] ^= SHA3.toLane(message, rr, ww, 17 * ww)
+ SHA3.S[18] ^= SHA3.toLane(message, rr, ww, 18 * ww)
+ SHA3.S[23] ^= SHA3.toLane(message, rr, ww, 19 * ww)
+ SHA3.S[ 4] ^= SHA3.toLane(message, rr, ww, 20 * ww)
+ SHA3.S[ 9] ^= SHA3.toLane(message, rr, ww, 21 * ww)
+ SHA3.S[14] ^= SHA3.toLane(message, rr, ww, 22 * ww)
+ SHA3.S[19] ^= SHA3.toLane(message, rr, ww, 23 * ww)
+ SHA3.S[24] ^= SHA3.toLane(message, rr, ww, 24 * ww)
message = message[rr:]
SHA3.keccakF(SHA3.S)
@@ -446,36 +469,59 @@ class SHA3:
if ww == 8:
for i in range(0, nnn, rr):
SHA3.S[ 0] ^= SHA3.toLane64(message, rr, 0)
- SHA3.S[ 1] ^= SHA3.toLane64(message, rr, 8)
- SHA3.S[ 2] ^= SHA3.toLane64(message, rr, 16)
- SHA3.S[ 3] ^= SHA3.toLane64(message, rr, 24)
- SHA3.S[ 4] ^= SHA3.toLane64(message, rr, 32)
- SHA3.S[ 5] ^= SHA3.toLane64(message, rr, 40)
+ SHA3.S[ 5] ^= SHA3.toLane64(message, rr, 8)
+ SHA3.S[10] ^= SHA3.toLane64(message, rr, 16)
+ SHA3.S[15] ^= SHA3.toLane64(message, rr, 24)
+ SHA3.S[20] ^= SHA3.toLane64(message, rr, 32)
+ SHA3.S[ 1] ^= SHA3.toLane64(message, rr, 40)
SHA3.S[ 6] ^= SHA3.toLane64(message, rr, 48)
- SHA3.S[ 7] ^= SHA3.toLane64(message, rr, 56)
- SHA3.S[ 8] ^= SHA3.toLane64(message, rr, 64)
- SHA3.S[ 9] ^= SHA3.toLane64(message, rr, 72)
- SHA3.S[10] ^= SHA3.toLane64(message, rr, 80)
- SHA3.S[11] ^= SHA3.toLane64(message, rr, 88)
+ SHA3.S[11] ^= SHA3.toLane64(message, rr, 56)
+ SHA3.S[16] ^= SHA3.toLane64(message, rr, 64)
+ SHA3.S[21] ^= SHA3.toLane64(message, rr, 72)
+ SHA3.S[ 2] ^= SHA3.toLane64(message, rr, 80)
+ SHA3.S[ 7] ^= SHA3.toLane64(message, rr, 88)
SHA3.S[12] ^= SHA3.toLane64(message, rr, 96)
- SHA3.S[13] ^= SHA3.toLane64(message, rr, 104)
- SHA3.S[14] ^= SHA3.toLane64(message, rr, 112)
- SHA3.S[15] ^= SHA3.toLane64(message, rr, 120)
- SHA3.S[16] ^= SHA3.toLane64(message, rr, 128)
- SHA3.S[17] ^= SHA3.toLane64(message, rr, 136)
+ SHA3.S[17] ^= SHA3.toLane64(message, rr, 104)
+ SHA3.S[22] ^= SHA3.toLane64(message, rr, 112)
+ SHA3.S[ 3] ^= SHA3.toLane64(message, rr, 120)
+ SHA3.S[ 8] ^= SHA3.toLane64(message, rr, 128)
+ SHA3.S[13] ^= SHA3.toLane64(message, rr, 136)
SHA3.S[18] ^= SHA3.toLane64(message, rr, 144)
- SHA3.S[19] ^= SHA3.toLane64(message, rr, 152)
- SHA3.S[20] ^= SHA3.toLane64(message, rr, 160)
- SHA3.S[21] ^= SHA3.toLane64(message, rr, 168)
- SHA3.S[22] ^= SHA3.toLane64(message, rr, 176)
- SHA3.S[23] ^= SHA3.toLane64(message, rr, 184)
+ SHA3.S[23] ^= SHA3.toLane64(message, rr, 152)
+ SHA3.S[ 4] ^= SHA3.toLane64(message, rr, 160)
+ SHA3.S[ 9] ^= SHA3.toLane64(message, rr, 168)
+ SHA3.S[14] ^= SHA3.toLane64(message, rr, 176)
+ SHA3.S[19] ^= SHA3.toLane64(message, rr, 184)
SHA3.S[24] ^= SHA3.toLane64(message, rr, 192)
SHA3.keccakF(SHA3.S)
message = message[rr:]
else:
for i in range(0, nnn, rr):
- for j in range(25):
- SHA3.S[j] ^= SHA3.toLane(message, rr, ww, j * ww)
+ SHA3.S[ 0] ^= SHA3.toLane(message, rr, ww, 0)
+ SHA3.S[ 5] ^= SHA3.toLane(message, rr, ww, ww)
+ SHA3.S[10] ^= SHA3.toLane(message, rr, ww, 2 * ww)
+ SHA3.S[15] ^= SHA3.toLane(message, rr, ww, 3 * ww)
+ SHA3.S[20] ^= SHA3.toLane(message, rr, ww, 4 * ww)
+ SHA3.S[ 1] ^= SHA3.toLane(message, rr, ww, 5 * ww)
+ SHA3.S[ 6] ^= SHA3.toLane(message, rr, ww, 6 * ww)
+ SHA3.S[11] ^= SHA3.toLane(message, rr, ww, 7 * ww)
+ SHA3.S[16] ^= SHA3.toLane(message, rr, ww, 8 * ww)
+ SHA3.S[21] ^= SHA3.toLane(message, rr, ww, 9 * ww)
+ SHA3.S[ 2] ^= SHA3.toLane(message, rr, ww, 10 * ww)
+ SHA3.S[ 7] ^= SHA3.toLane(message, rr, ww, 11 * ww)
+ SHA3.S[12] ^= SHA3.toLane(message, rr, ww, 12 * ww)
+ SHA3.S[17] ^= SHA3.toLane(message, rr, ww, 13 * ww)
+ SHA3.S[22] ^= SHA3.toLane(message, rr, ww, 14 * ww)
+ SHA3.S[ 3] ^= SHA3.toLane(message, rr, ww, 15 * ww)
+ SHA3.S[ 8] ^= SHA3.toLane(message, rr, ww, 16 * ww)
+ SHA3.S[13] ^= SHA3.toLane(message, rr, ww, 17 * ww)
+ SHA3.S[18] ^= SHA3.toLane(message, rr, ww, 18 * ww)
+ SHA3.S[23] ^= SHA3.toLane(message, rr, ww, 19 * ww)
+ SHA3.S[ 4] ^= SHA3.toLane(message, rr, ww, 20 * ww)
+ SHA3.S[ 9] ^= SHA3.toLane(message, rr, ww, 21 * ww)
+ SHA3.S[14] ^= SHA3.toLane(message, rr, ww, 22 * ww)
+ SHA3.S[19] ^= SHA3.toLane(message, rr, ww, 23 * ww)
+ SHA3.S[24] ^= SHA3.toLane(message, rr, ww, 24 * ww)
message = message[rr:]
SHA3.keccakF(SHA3.S)
@@ -486,7 +532,7 @@ class SHA3:
while (olen > 0):
i = 0
while (i < ni) and (j < nn):
- v = SHA3.S[i]
+ v = SHA3.S[(i % 5) * 5 + i // 5] # FIXME
for _ in range(ww):
if (j < nn):
rc[ptr] = v & 255