aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-02-15 21:38:22 +0100
committerMattias Andrée <maandree@operamail.com>2013-02-15 21:38:22 +0100
commit1f17f92a16e0e7b499061ac0a0ffdcc1cf46e77e (patch)
tree2adbca9365126176210542f0563022dc510322ff
parent8th bit error detected on c version (diff)
downloadsha3sum-1f17f92a16e0e7b499061ac0a0ffdcc1cf46e77e.tar.gz
sha3sum-1f17f92a16e0e7b499061ac0a0ffdcc1cf46e77e.tar.bz2
sha3sum-1f17f92a16e0e7b499061ac0a0ffdcc1cf46e77e.tar.xz
support 8th bit in c version
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--README.md2
-rw-r--r--c/sha3.c18
2 files changed, 10 insertions, 10 deletions
diff --git a/README.md b/README.md
index bef47a0..d652952 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@ COMPLETE STATUS:
Pure Java 1.2+ :: optimised
Python 3 :: optimised
- C ISO C90 :: optimised -- ERROR ON NON-ASCII DATA AND WITH ITERATIONS --
+ C ISO C90 :: optimised
Java/C JNI :: under development
Vala :: correct, under development
NASM :: planned (maybe, after jni)
diff --git a/c/sha3.c b/c/sha3.c
index 8e3f44d..d8981ed 100644
--- a/c/sha3.c
+++ b/c/sha3.c
@@ -365,7 +365,7 @@ inline llong toLane(byte* message, long msglen, long rr, long ww, long off)
llong rc = 0;
long n = min(msglen, rr), i;
for (i = off + ww - 1; i >= off; i--)
- rc = (rc << 8) | ((i < n) ? (llong)(message[i]) : 0L);
+ rc = (rc << 8) | ((i < n) ? (llong)(message[i] & 255) : 0L);
return rc;
}
@@ -382,14 +382,14 @@ inline llong toLane(byte* message, long msglen, long rr, long ww, long off)
inline llong toLane64(byte* message, long msglen, long rr, long off)
{
long n = min(msglen, rr);
- return ((off + 7 < n) ? ((llong)(message[off + 7]) << 56) : 0L) |
- ((off + 6 < n) ? ((llong)(message[off + 6]) << 48) : 0L) |
- ((off + 5 < n) ? ((llong)(message[off + 5]) << 40) : 0L) |
- ((off + 4 < n) ? ((llong)(message[off + 4]) << 32) : 0L) |
- ((off + 3 < n) ? ((llong)(message[off + 3]) << 24) : 0L) |
- ((off + 2 < n) ? ((llong)(message[off + 2]) << 16) : 0L) |
- ((off + 1 < n) ? ((llong)(message[off + 1]) << 8) : 0L) |
- ((off < n) ? ((llong)(message[off ]) ) : 0L);
+ return ((off + 7 < n) ? ((llong)(message[off + 7] & 255) << 56) : 0L) |
+ ((off + 6 < n) ? ((llong)(message[off + 6] & 255) << 48) : 0L) |
+ ((off + 5 < n) ? ((llong)(message[off + 5] & 255) << 40) : 0L) |
+ ((off + 4 < n) ? ((llong)(message[off + 4] & 255) << 32) : 0L) |
+ ((off + 3 < n) ? ((llong)(message[off + 3] & 255) << 24) : 0L) |
+ ((off + 2 < n) ? ((llong)(message[off + 2] & 255) << 16) : 0L) |
+ ((off + 1 < n) ? ((llong)(message[off + 1] & 255) << 8) : 0L) |
+ ((off < n) ? ((llong)(message[off ] & 255) ) : 0L);
}