diff options
author | xiphon <xiphon@protonmail.com> | 2018-10-22 06:48:54 +0000 |
---|---|---|
committer | xiphon <xiphon@protonmail.com> | 2018-10-22 18:34:19 +0300 |
commit | ed36335c969a1061e555724467263e22d1738cce (patch) | |
tree | e202e4954a4ea7c7bc98c470d64a7842f463b485 /src/crypto/keccak.c | |
parent | Merge pull request #4524 (diff) | |
download | monero-ed36335c969a1061e555724467263e22d1738cce.tar.xz |
crypto: fixed incremental keccak API on big-endian platforms
Diffstat (limited to '')
-rw-r--r-- | src/crypto/keccak.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/crypto/keccak.c b/src/crypto/keccak.c index b5946036e..b095b5ce2 100644 --- a/src/crypto/keccak.c +++ b/src/crypto/keccak.c @@ -145,7 +145,7 @@ void keccak1600(const uint8_t *in, size_t inlen, uint8_t *md) #define IS_ALIGNED_64(p) (0 == (7 & ((const char*)(p) - (const char*)0))) #define KECCAK_PROCESS_BLOCK(st, block) { \ for (int i_ = 0; i_ < KECCAK_WORDS; i_++){ \ - ((st))[i_] ^= ((block))[i_]; \ + ((st))[i_] ^= swap64le(((block))[i_]); \ }; \ keccakf(st, KECCAK_ROUNDS); } @@ -207,7 +207,8 @@ void keccak_finish(KECCAK_CTX * ctx, uint8_t *md){ } static_assert(KECCAK_BLOCKLEN > KECCAK_DIGESTSIZE, ""); + static_assert(KECCAK_DIGESTSIZE % sizeof(uint64_t) == 0, ""); if (md) { - memcpy(md, ctx->hash, KECCAK_DIGESTSIZE); + memcpy_swap64le(md, ctx->hash, KECCAK_DIGESTSIZE / sizeof(uint64_t)); } } |