aboutsummaryrefslogtreecommitdiffstats
path: root/c
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 /c
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>
Diffstat (limited to 'c')
-rw-r--r--c/sha3.c18
1 files changed, 9 insertions, 9 deletions
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);
}