aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/keccak.c
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-07-02 21:07:49 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-07-04 22:13:16 +0000
commitc2238327d0c20f2a1e601ec120db51a13cebfc35 (patch)
tree2fd87e79f624ed7f32df0a8966ce7a87124ae1cd /src/crypto/keccak.c
parentMerge pull request #5641 (diff)
downloadmonero-c2238327d0c20f2a1e601ec120db51a13cebfc35.tar.xz
keccak: guard against misaligned memory accesses on ARM
The code generated is exactly the same as the direct access one on x86_64
Diffstat (limited to 'src/crypto/keccak.c')
-rw-r--r--src/crypto/keccak.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/crypto/keccak.c b/src/crypto/keccak.c
index 18ed3152f..851c70a25 100644
--- a/src/crypto/keccak.c
+++ b/src/crypto/keccak.c
@@ -105,9 +105,12 @@ void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen)
memset(st, 0, sizeof(st));
for ( ; inlen >= rsiz; inlen -= rsiz, in += rsiz) {
- for (i = 0; i < rsizw; i++)
- st[i] ^= swap64le(((uint64_t *) in)[i]);
- keccakf(st, KECCAK_ROUNDS);
+ for (i = 0; i < rsizw; i++) {
+ uint64_t ina;
+ memcpy(&ina, in + i * 8, 8);
+ st[i] ^= swap64le(ina);
+ }
+ keccakf(st, KECCAK_ROUNDS);
}
// last block and padding