aboutsummaryrefslogtreecommitdiffstats
path: root/python3/sha3sum.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-05-03 20:06:03 +0200
committerMattias Andrée <maandree@operamail.com>2013-05-03 20:06:03 +0200
commit25fdad62e84a4d1c61a52d5b96dc5325982a30de (patch)
treec1df8b5f928bc3618be90949ff1c732e0b2c4830 /python3/sha3sum.py
parentapply change made to pure-java to other versions (diff)
downloadsha3sum-25fdad62e84a4d1c61a52d5b96dc5325982a30de.tar.gz
sha3sum-25fdad62e84a4d1c61a52d5b96dc5325982a30de.tar.bz2
sha3sum-25fdad62e84a4d1c61a52d5b96dc5325982a30de.tar.xz
fix partial byte output
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rwxr-xr-xpython3/sha3sum.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/python3/sha3sum.py b/python3/sha3sum.py
index 43bdf2f..aa0cced 100755
--- a/python3/sha3sum.py
+++ b/python3/sha3sum.py
@@ -465,7 +465,7 @@ class SHA3:
ptr = 0
rr = SHA3.r >> 3
- nn = (SHA3.n + 3) >> 3
+ nn = (SHA3.n + 7) >> 3
ww = SHA3.w >> 3
# Absorbing phase
@@ -546,6 +546,8 @@ class SHA3:
olen -= SHA3.r
if olen > 0:
SHA3.keccakF(SHA3.S)
+ if (SHA3.n & 7) != 0:
+ rc[len(rc) - 1] &= (1 << (SHA3.n & 7)) - 1
return bytes(rc)