diff options
Diffstat (limited to 'src/ext/keccak-tiny/keccak-tiny-unrolled.c')
-rw-r--r-- | src/ext/keccak-tiny/keccak-tiny-unrolled.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/ext/keccak-tiny/keccak-tiny-unrolled.c b/src/ext/keccak-tiny/keccak-tiny-unrolled.c index d1342c3601..07e8c95bcf 100644 --- a/src/ext/keccak-tiny/keccak-tiny-unrolled.c +++ b/src/ext/keccak-tiny/keccak-tiny-unrolled.c @@ -9,29 +9,22 @@ #include "keccak-tiny.h" #include <string.h> -#include "crypto.h" +#include "crypto_util.h" +#include "byteorder.h" /******** Endianness conversion helpers ********/ static inline uint64_t loadu64le(const unsigned char *x) { - uint64_t r = 0; - size_t i; - - for (i = 0; i < 8; ++i) { - r |= (uint64_t)x[i] << 8 * i; - } - return r; + uint64_t r; + memcpy(&r, x, sizeof(r)); + return _le64toh(r); } static inline void storeu64le(uint8_t *x, uint64_t u) { - size_t i; - - for(i=0; i<8; ++i) { - x[i] = u; - u >>= 8; - } + uint64_t val = _le64toh(u); + memcpy(x, &val, sizeof(u)); } /******** The Keccak-f[1600] permutation ********/ |