From 51d7b7a96ccb01e0c5ccdec4ceab92db844792f1 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sun, 15 Oct 2017 11:32:46 -0400 Subject: Correct usage of std::aligned_storage This ended up allocating 256 KiB! --- src/lib/block/aes/aes.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/lib/block/aes/aes.cpp') diff --git a/src/lib/block/aes/aes.cpp b/src/lib/block/aes/aes.cpp index 6afa5133a..8a82ad942 100644 --- a/src/lib/block/aes/aes.cpp +++ b/src/lib/block/aes/aes.cpp @@ -124,7 +124,7 @@ const uint32_t* AES_TE() public: TE_Table() { - uint32_t* p = reinterpret_cast(data); + uint32_t* p = reinterpret_cast(&data); for(size_t i = 0; i != 256; ++i) { const uint8_t s = SE[i]; @@ -134,10 +134,10 @@ const uint32_t* AES_TE() const uint32_t* ptr() const { - return reinterpret_cast(data); + return reinterpret_cast(&data); } private: - std::aligned_storage<256*sizeof(uint32_t), 64>::type data[256]; + std::aligned_storage<256*sizeof(uint32_t), 64>::type data; }; static TE_Table table; @@ -151,7 +151,7 @@ const uint32_t* AES_TD() public: TD_Table() { - uint32_t* p = reinterpret_cast(data); + uint32_t* p = reinterpret_cast(&data); for(size_t i = 0; i != 256; ++i) { const uint8_t s = SD[i]; @@ -161,10 +161,10 @@ const uint32_t* AES_TD() const uint32_t* ptr() const { - return reinterpret_cast(data); + return reinterpret_cast(&data); } private: - std::aligned_storage::type data[256]; + std::aligned_storage<256*sizeof(uint32_t), 64>::type data; }; static TD_Table table; -- cgit v1.2.3