aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--c/sha3.c3
-rw-r--r--java-c-jni/SHA3.c3
-rw-r--r--pure-java/SHA3.java3
-rwxr-xr-xpython3/sha3sum.py4
-rw-r--r--vala/sha3sum.vala3
5 files changed, 15 insertions, 1 deletions
diff --git a/c/sha3.c b/c/sha3.c
index a5e8f69..1dea0d9 100644
--- a/c/sha3.c
+++ b/c/sha3.c
@@ -691,6 +691,9 @@ extern byte* digest(byte* msg, long msglen)
if (olen > 0)
keccakF(S);
}
+ if ((n & 7))
+ rc[n >> 3] &= (1 << (n & 7)) - 1;
+
return rc;
}
diff --git a/java-c-jni/SHA3.c b/java-c-jni/SHA3.c
index 9124743..827458a 100644
--- a/java-c-jni/SHA3.c
+++ b/java-c-jni/SHA3.c
@@ -680,6 +680,9 @@ byte* digest(byte* msg, jint msglen)
if (olen > 0)
keccakF(S);
}
+ if ((n & 7))
+ rc[n >> 3] &= (1 << (n & 7)) - 1;
+
return rc;
}
diff --git a/pure-java/SHA3.java b/pure-java/SHA3.java
index 0dbbae9..5dad5c7 100644
--- a/pure-java/SHA3.java
+++ b/pure-java/SHA3.java
@@ -599,6 +599,9 @@ public class SHA3
if (olen > 0)
SHA3.keccakF(S);
}
+ if ((SHA3.n & 7) != 0)
+ rc[rc.length - 1] &= (1 << (SHA3.n & 7)) - 1
+
return rc;
}
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)
diff --git a/vala/sha3sum.vala b/vala/sha3sum.vala
index da2e2b7..6339d6a 100644
--- a/vala/sha3sum.vala
+++ b/vala/sha3sum.vala
@@ -602,6 +602,9 @@ class SHA3 : Object
if (olen > 0)
this.keccakF(S);
}
+ if ((n & 7) != 0)
+ rc[n >> 3] &= (1 << (n & 7)) - 1;
+
return rc;
}