aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);
}