diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2017-02-18 12:10:05 +0000 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2017-02-18 12:10:05 +0000 |
commit | ee47a0c6478ab4e6478ad3b7fe5a35eb5775decb (patch) | |
tree | 7bcc999a668eed4247e9e9d203b84aec5338a15b /src/lib | |
parent | 787fb78ff2fc54c36b37ecdf9b9c094800b9ef4c (diff) | |
parent | 61848f89db3c42d6cc67c8498c7e6aabb6202a9b (diff) | |
download | ouroboros-ee47a0c6478ab4e6478ad3b7fe5a35eb5775decb.tar.gz ouroboros-ee47a0c6478ab4e6478ad3b7fe5a35eb5775decb.zip |
Merged in dstaesse/ouroboros/be-sha3 (pull request #380)
lib: Fix bug in sha3
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/sha3.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/sha3.c b/src/lib/sha3.c index b2f9de57..212f645a 100644 --- a/src/lib/sha3.c +++ b/src/lib/sha3.c @@ -47,7 +47,8 @@ #include "sha3.h" -#define IS_ALIGNED_64(p) (0 == (7 & ((const char*) (p) - (const char*) 0))) +#define IS_ALIGNED_64(p) (0 == (7 & ((const uint8_t *) (p) \ + - (const uint8_t *) 0))) #define I64(x) x##LL #define ROTL64(qword, n) ((qword) << (n) ^ ((qword) >> (64 - (n)))) @@ -307,8 +308,9 @@ void rhash_sha3_final(struct sha3_ctx * ctx, uint8_t * res) { size_t digest_length = 100 - ctx->block_size / 2; - const size_t block_size = ctx->block_size; - unsigned int i = 0; + size_t digest_words = digest_length / sizeof(uint64_t); + const size_t block_size = ctx->block_size; + size_t i = 0; if (!(ctx->rest & SHA3_FINALIZED)) { /* clear the rest of the data queue */ @@ -325,7 +327,7 @@ void rhash_sha3_final(struct sha3_ctx * ctx, assert(block_size > digest_length); if (res != NULL) { - for (i = 0; i < digest_length; i++) + for (i = 0; i < digest_words; i++) ctx->hash[i] = htole64(ctx->hash[i]); memcpy(res, ctx->hash, digest_length); |