diff options
author | luigi1111 <luigi1111w@gmail.com> | 2019-07-12 20:23:08 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2019-07-12 20:23:08 -0500 |
commit | e4e8954c040ebcf9f87232bbe98f5537adbac1ae (patch) | |
tree | 74ac913ac130d50c91735dad8ed4ab9073a1064f /tests/unit_tests/keccak.cpp | |
parent | Merge pull request #5704 (diff) | |
parent | keccak: guard against misaligned memory accesses on ARM (diff) | |
download | monero-e4e8954c040ebcf9f87232bbe98f5537adbac1ae.tar.xz |
Merge pull request #5724
c223832 keccak: guard against misaligned memory accesses on ARM (moneromooo-monero)
Diffstat (limited to 'tests/unit_tests/keccak.cpp')
-rw-r--r-- | tests/unit_tests/keccak.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/unit_tests/keccak.cpp b/tests/unit_tests/keccak.cpp index 37da65d76..f4d41a8fa 100644 --- a/tests/unit_tests/keccak.cpp +++ b/tests/unit_tests/keccak.cpp @@ -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)); + } +} |