keccak: guard against misaligned memory accesses on ARM

The code generated is exactly the same as the direct access
one on x86_64
This commit is contained in:
moneromooo-monero 2019-07-02 21:07:49 +00:00
parent 6335509727
commit c2238327d0
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
2 changed files with 23 additions and 3 deletions

View file

@ -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