mirror of
https://github.com/monero-project/monero.git
synced 2025-05-03 20:24:49 -04:00
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:
parent
6335509727
commit
c2238327d0
2 changed files with 23 additions and 3 deletions
|
@ -148,3 +148,20 @@ TEST(keccak, 137_and_1_136)
|
|||
TEST_KECCAK(137, chunks);
|
||||
}
|
||||
|
||||
TEST(keccak, alignment)
|
||||
{
|
||||
uint8_t data[6064];
|
||||
__attribute__ ((aligned(16))) char adata[6000];
|
||||
|
||||
for (size_t i = 0; i < sizeof(data) / sizeof(data[0]); ++i)
|
||||
data[i] = i & 1;
|
||||
|
||||
uint8_t md[32], amd[32];
|
||||
for (int offset = 0; offset < 64; ++offset)
|
||||
{
|
||||
memcpy(adata, data + offset, 6000);
|
||||
keccak((const uint8_t*)&data[offset], 6000, md, 32);
|
||||
keccak((const uint8_t*)adata, 6000, amd, 32);
|
||||
ASSERT_TRUE(!memcmp(md, amd, 32));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue