diff options
author | Jack Lloyd <[email protected]> | 2020-12-11 11:26:57 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2020-12-11 12:03:37 -0500 |
commit | 884a22fa2ade86bb12e503d6ef37784de7fe6f36 (patch) | |
tree | 5ad38f4218e416352a6d5cd28c100b15cc3c929f /src | |
parent | 9bcc30f212bc502e51bcc386e0bd9ed65adf36a7 (diff) |
Incrase the alignment of all lookup tables
We had done this in an ad-hoc way in the past for eg the AES tables
but given how easy C++'s alignas is to use we should apply it
universally.
Use 256 byte alignment for larger tables since that heads of any
possible issues that arise from machines with large cache lines.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/block/aria/aria.cpp | 12 | ||||
-rw-r--r-- | src/lib/block/camellia/camellia.cpp | 12 | ||||
-rw-r--r-- | src/lib/block/cast128/cast128.cpp | 16 | ||||
-rw-r--r-- | src/lib/block/des/des.cpp | 3 | ||||
-rw-r--r-- | src/lib/block/seed/seed.cpp | 4 | ||||
-rw-r--r-- | src/lib/block/sm4/sm4.cpp | 6 | ||||
-rw-r--r-- | src/lib/block/sm4/sm4_armv8/sm4_armv8.cpp | 4 | ||||
-rw-r--r-- | src/lib/block/twofish/twofish_tab.cpp | 18 | ||||
-rw-r--r-- | src/lib/codec/base32/base32.cpp | 6 | ||||
-rw-r--r-- | src/lib/codec/base64/base64.cpp | 4 | ||||
-rw-r--r-- | src/lib/codec/hex/hex.cpp | 6 | ||||
-rw-r--r-- | src/lib/hash/checksum/crc24/crc24.cpp | 8 | ||||
-rw-r--r-- | src/lib/hash/checksum/crc32/crc32.cpp | 2 | ||||
-rw-r--r-- | src/lib/hash/whirlpool/whrl_tab.cpp | 16 | ||||
-rw-r--r-- | src/lib/passhash/bcrypt/bcrypt.cpp | 4 |
15 files changed, 54 insertions, 67 deletions
diff --git a/src/lib/block/aria/aria.cpp b/src/lib/block/aria/aria.cpp index 687c13238..867ee7915 100644 --- a/src/lib/block/aria/aria.cpp +++ b/src/lib/block/aria/aria.cpp @@ -27,8 +27,7 @@ namespace { namespace ARIA_F { -alignas(64) -const uint8_t S1[256]={ +alignas(256) const uint8_t S1[256] = { 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, @@ -54,8 +53,7 @@ const uint8_t S1[256]={ 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16 }; -alignas(64) -const uint8_t S2[256]={ +alignas(256) const uint8_t S2[256] = { 0xE2, 0x4E, 0x54, 0xFC, 0x94, 0xC2, 0x4A, 0xCC, 0x62, 0x0D, 0x6A, 0x46, 0x3C, 0x4D, 0x8B, 0xD1, 0x5E, 0xFA, 0x64, 0xCB, 0xB4, 0x97, 0xBE, 0x2B, 0xBC, 0x77, 0x2E, 0x03, 0xD3, 0x19, 0x59, 0xC1, 0x1D, @@ -81,8 +79,7 @@ const uint8_t S2[256]={ 0xE0, 0xA5, 0x3D, 0x22, 0xB3, 0xF8, 0x89, 0xDE, 0x71, 0x1A, 0xAF, 0xBA, 0xB5, 0x81 }; -alignas(64) -const uint8_t X1[256]={ +alignas(256) const uint8_t X1[256] = { 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB, 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, 0x54, @@ -108,8 +105,7 @@ const uint8_t X1[256]={ 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D }; -alignas(64) -const uint8_t X2[256]={ +alignas(256) const uint8_t X2[256] = { 0x30, 0x68, 0x99, 0x1B, 0x87, 0xB9, 0x21, 0x78, 0x50, 0x39, 0xDB, 0xE1, 0x72, 0x09, 0x62, 0x3C, 0x3E, 0x7E, 0x5E, 0x8E, 0xF1, 0xA0, 0xCC, 0xA3, 0x2A, 0x1D, 0xFB, 0xB6, 0xD6, 0x20, 0xC4, 0x8D, 0x81, diff --git a/src/lib/block/camellia/camellia.cpp b/src/lib/block/camellia/camellia.cpp index 295b008a4..8741e5475 100644 --- a/src/lib/block/camellia/camellia.cpp +++ b/src/lib/block/camellia/camellia.cpp @@ -15,8 +15,7 @@ namespace { namespace Camellia_F { -alignas(64) -static const uint8_t SBOX1[256] = { +alignas(256) static const uint8_t SBOX1[256] = { 0x70, 0x82, 0x2C, 0xEC, 0xB3, 0x27, 0xC0, 0xE5, 0xE4, 0x85, 0x57, 0x35, 0xEA, 0x0C, 0xAE, 0x41, 0x23, 0xEF, 0x6B, 0x93, 0x45, 0x19, 0xA5, 0x21, 0xED, 0x0E, 0x4F, 0x4E, 0x1D, 0x65, 0x92, 0xBD, 0x86, @@ -43,8 +42,7 @@ static const uint8_t SBOX1[256] = { 0xC7, 0x80, 0x9E }; // SBOX2[x] = rotl<1>(SBOX1[x]) -alignas(64) -static const uint8_t SBOX2[256] = { +alignas(256) static const uint8_t SBOX2[256] = { 0xE0, 0x05, 0x58, 0xD9, 0x67, 0x4E, 0x81, 0xCB, 0xC9, 0x0B, 0xAE, 0x6A, 0xD5, 0x18, 0x5D, 0x82, 0x46, 0xDF, 0xD6, 0x27, 0x8A, 0x32, 0x4B, 0x42, 0xDB, 0x1C, 0x9E, 0x9C, 0x3A, 0xCA, 0x25, 0x7B, 0x0D, @@ -71,8 +69,7 @@ static const uint8_t SBOX2[256] = { 0x8F, 0x01, 0x3D }; // SBOX3[x] = rotl<7>(SBOX1[x]) -alignas(64) -static const uint8_t SBOX3[256] = { +alignas(256) static const uint8_t SBOX3[256] = { 0x38, 0x41, 0x16, 0x76, 0xD9, 0x93, 0x60, 0xF2, 0x72, 0xC2, 0xAB, 0x9A, 0x75, 0x06, 0x57, 0xA0, 0x91, 0xF7, 0xB5, 0xC9, 0xA2, 0x8C, 0xD2, 0x90, 0xF6, 0x07, 0xA7, 0x27, 0x8E, 0xB2, 0x49, 0xDE, 0x43, @@ -99,8 +96,7 @@ static const uint8_t SBOX3[256] = { 0xE3, 0x40, 0x4F }; // SBOX4[x] = SBOX1[rotl<1>(x)] -alignas(64) -static const uint8_t SBOX4[256] = { +alignas(256) static const uint8_t SBOX4[256] = { 0x70, 0x2C, 0xB3, 0xC0, 0xE4, 0x57, 0xEA, 0xAE, 0x23, 0x6B, 0x45, 0xA5, 0xED, 0x4F, 0x1D, 0x92, 0x86, 0xAF, 0x7C, 0x1F, 0x3E, 0xDC, 0x5E, 0x0B, 0xA6, 0x39, 0xD5, 0x5D, 0xD9, 0x5A, 0x51, 0x6C, 0x8B, diff --git a/src/lib/block/cast128/cast128.cpp b/src/lib/block/cast128/cast128.cpp index e180e58e2..6f2941c67 100644 --- a/src/lib/block/cast128/cast128.cpp +++ b/src/lib/block/cast128/cast128.cpp @@ -13,7 +13,7 @@ namespace Botan { namespace { -const uint32_t CAST_SBOX1[256] = { +alignas(256) const uint32_t CAST_SBOX1[256] = { 0x30FB40D4, 0x9FA0FF0B, 0x6BECCD2F, 0x3F258C7A, 0x1E213F2F, 0x9C004DD3, 0x6003E540, 0xCF9FC949, 0xBFD4AF27, 0x88BBBDB5, 0xE2034090, 0x98D09675, 0x6E63A0E0, 0x15C361D2, 0xC2E7661D, 0x22D4FF8E, 0x28683B6F, 0xC07FD059, @@ -58,7 +58,7 @@ const uint32_t CAST_SBOX1[256] = { 0xB141AB08, 0x7CCA89B9, 0x1A69E783, 0x02CC4843, 0xA2F7C579, 0x429EF47D, 0x427B169C, 0x5AC9F049, 0xDD8F0F00, 0x5C8165BF }; -const uint32_t CAST_SBOX2[256] = { +alignas(256) const uint32_t CAST_SBOX2[256] = { 0x1F201094, 0xEF0BA75B, 0x69E3CF7E, 0x393F4380, 0xFE61CF7A, 0xEEC5207A, 0x55889C94, 0x72FC0651, 0xADA7EF79, 0x4E1D7235, 0xD55A63CE, 0xDE0436BA, 0x99C430EF, 0x5F0C0794, 0x18DCDB7D, 0xA1D6EFF3, 0xA0B52F7B, 0x59E83605, @@ -103,7 +103,7 @@ const uint32_t CAST_SBOX2[256] = { 0x5C038323, 0x3E5D3BB9, 0x43D79572, 0x7E6DD07C, 0x06DFDF1E, 0x6C6CC4EF, 0x7160A539, 0x73BFBE70, 0x83877605, 0x4523ECF1 }; -const uint32_t CAST_SBOX3[256] = { +alignas(256) const uint32_t CAST_SBOX3[256] = { 0x8DEFC240, 0x25FA5D9F, 0xEB903DBF, 0xE810C907, 0x47607FFF, 0x369FE44B, 0x8C1FC644, 0xAECECA90, 0xBEB1F9BF, 0xEEFBCAEA, 0xE8CF1950, 0x51DF07AE, 0x920E8806, 0xF0AD0548, 0xE13C8D83, 0x927010D5, 0x11107D9F, 0x07647DB9, @@ -148,7 +148,7 @@ const uint32_t CAST_SBOX3[256] = { 0x52BCE688, 0x1B03588A, 0xF7BAEFD5, 0x4142ED9C, 0xA4315C11, 0x83323EC5, 0xDFEF4636, 0xA133C501, 0xE9D3531C, 0xEE353783 }; -const uint32_t CAST_SBOX4[256] = { +alignas(256) const uint32_t CAST_SBOX4[256] = { 0x9DB30420, 0x1FB6E9DE, 0xA7BE7BEF, 0xD273A298, 0x4A4F7BDB, 0x64AD8C57, 0x85510443, 0xFA020ED1, 0x7E287AFF, 0xE60FB663, 0x095F35A1, 0x79EBF120, 0xFD059D43, 0x6497B7B1, 0xF3641F63, 0x241E4ADF, 0x28147F5F, 0x4FA2B8CD, @@ -417,7 +417,7 @@ void CAST_128::clear() void CAST_128::cast_ks(secure_vector<uint32_t>& K, secure_vector<uint32_t>& X) { - static const uint32_t S5[256] = { + alignas(256) static const uint32_t S5[256] = { 0x7EC90C04, 0x2C6E74B9, 0x9B0E66DF, 0xA6337911, 0xB86A7FFF, 0x1DD358F5, 0x44DD9D44, 0x1731167F, 0x08FBF1FA, 0xE7F511CC, 0xD2051B00, 0x735ABA00, 0x2AB722D8, 0x386381CB, 0xACF6243A, 0x69BEFD7A, 0xE6A2E77F, 0xF0C720CD, @@ -462,7 +462,7 @@ void CAST_128::cast_ks(secure_vector<uint32_t>& K, 0x34010718, 0xBB30CAB8, 0xE822FE15, 0x88570983, 0x750E6249, 0xDA627E55, 0x5E76FFA8, 0xB1534546, 0x6D47DE08, 0xEFE9E7D4 }; - static const uint32_t S6[256] = { + alignas(256) static const uint32_t S6[256] = { 0xF6FA8F9D, 0x2CAC6CE1, 0x4CA34867, 0xE2337F7C, 0x95DB08E7, 0x016843B4, 0xECED5CBC, 0x325553AC, 0xBF9F0960, 0xDFA1E2ED, 0x83F0579D, 0x63ED86B9, 0x1AB6A6B8, 0xDE5EBE39, 0xF38FF732, 0x8989B138, 0x33F14961, 0xC01937BD, @@ -507,7 +507,7 @@ void CAST_128::cast_ks(secure_vector<uint32_t>& K, 0xB0E93524, 0xBEBB8FBD, 0xA2D762CF, 0x49C92F54, 0x38B5F331, 0x7128A454, 0x48392905, 0xA65B1DB8, 0x851C97BD, 0xD675CF2F }; - static const uint32_t S7[256] = { + alignas(256) static const uint32_t S7[256] = { 0x85E04019, 0x332BF567, 0x662DBFFF, 0xCFC65693, 0x2A8D7F6F, 0xAB9BC912, 0xDE6008A1, 0x2028DA1F, 0x0227BCE7, 0x4D642916, 0x18FAC300, 0x50F18B82, 0x2CB2CB11, 0xB232E75C, 0x4B3695F2, 0xB28707DE, 0xA05FBCF6, 0xCD4181E9, @@ -552,7 +552,7 @@ void CAST_128::cast_ks(secure_vector<uint32_t>& K, 0xC3C0BDAE, 0x4958C24C, 0x518F36B2, 0x84B1D370, 0x0FEDCE83, 0x878DDADA, 0xF2A279C7, 0x94E01BE8, 0x90716F4B, 0x954B8AA3 }; - static const uint32_t S8[256] = { + alignas(256) static const uint32_t S8[256] = { 0xE216300D, 0xBBDDFFFC, 0xA7EBDABD, 0x35648095, 0x7789F8B7, 0xE6C1121B, 0x0E241600, 0x052CE8B5, 0x11A9CFB0, 0xE5952F11, 0xECE7990A, 0x9386D174, 0x2A42931C, 0x76E38111, 0xB12DEF3A, 0x37DDDDFC, 0xDE9ADEB1, 0x0A0CC32C, diff --git a/src/lib/block/des/des.cpp b/src/lib/block/des/des.cpp index 399f27d3a..c7e7befbf 100644 --- a/src/lib/block/des/des.cpp +++ b/src/lib/block/des/des.cpp @@ -16,8 +16,7 @@ namespace Botan { namespace { -alignas(64) -const uint32_t DES_SPBOX[64*8] = { +alignas(256) const uint32_t DES_SPBOX[64*8] = { 0x01010400, 0x00000000, 0x00010000, 0x01010404, 0x01010004, 0x00010404, 0x00000004, 0x00010000, 0x00000400, 0x01010400, 0x01010404, 0x00000400, 0x01000404, 0x01010004, 0x01000000, 0x00000004, 0x00000404, 0x01000400, diff --git a/src/lib/block/seed/seed.cpp b/src/lib/block/seed/seed.cpp index eb37abbd7..5cfd6ac6d 100644 --- a/src/lib/block/seed/seed.cpp +++ b/src/lib/block/seed/seed.cpp @@ -12,7 +12,7 @@ namespace Botan { namespace { -const uint8_t SEED_S0[256] = { +alignas(256) const uint8_t SEED_S0[256] = { 0xA9, 0x85, 0xD6, 0xD3, 0x54, 0x1D, 0xAC, 0x25, 0x5D, 0x43, 0x18, 0x1E, 0x51, 0xFC, 0xCA, 0x63, 0x28, 0x44, 0x20, 0x9D, 0xE0, 0xE2, 0xC8, 0x17, 0xA5, 0x8F, 0x03, 0x7B, 0xBB, 0x13, 0xD2, 0xEE, 0x70, 0x8C, 0x3F, 0xA8, 0x32, 0xDD, 0xF6, 0x74, 0xEC, 0x95, 0x0B, 0x57, 0x5C, 0x5B, 0xBD, 0x01, @@ -31,7 +31,7 @@ const uint8_t SEED_S0[256] = { 0x16, 0x3A, 0x58, 0xD4, 0x62, 0x29, 0x07, 0x33, 0xE8, 0x1B, 0x05, 0x79, 0x90, 0x6A, 0x2A, 0x9A, }; -const uint8_t SEED_S1[256] = { +alignas(256) const uint8_t SEED_S1[256] = { 0x38, 0xE8, 0x2D, 0xA6, 0xCF, 0xDE, 0xB3, 0xB8, 0xAF, 0x60, 0x55, 0xC7, 0x44, 0x6F, 0x6B, 0x5B, 0xC3, 0x62, 0x33, 0xB5, 0x29, 0xA0, 0xE2, 0xA7, 0xD3, 0x91, 0x11, 0x06, 0x1C, 0xBC, 0x36, 0x4B, 0xEF, 0x88, 0x6C, 0xA8, 0x17, 0xC4, 0x16, 0xF4, 0xC2, 0x45, 0xE1, 0xD6, 0x3F, 0x3D, 0x8E, 0x98, diff --git a/src/lib/block/sm4/sm4.cpp b/src/lib/block/sm4/sm4.cpp index 96246ca42..3c0f419df 100644 --- a/src/lib/block/sm4/sm4.cpp +++ b/src/lib/block/sm4/sm4.cpp @@ -15,8 +15,7 @@ namespace Botan { namespace { -alignas(64) -const uint8_t SM4_SBOX[256] = { +alignas(256) const uint8_t SM4_SBOX[256] = { 0xD6, 0x90, 0xE9, 0xFE, 0xCC, 0xE1, 0x3D, 0xB7, 0x16, 0xB6, 0x14, 0xC2, 0x28, 0xFB, 0x2C, 0x05, 0x2B, 0x67, 0x9A, 0x76, 0x2A, 0xBE, 0x04, 0xC3, 0xAA, 0x44, 0x13, 0x26, 0x49, 0x86, 0x06, 0x99, 0x9C, 0x42, 0x50, 0xF4, 0x91, 0xEF, 0x98, 0x7A, 0x33, 0x54, 0x0B, 0x43, 0xED, 0xCF, 0xAC, 0x62, @@ -38,8 +37,7 @@ const uint8_t SM4_SBOX[256] = { /* * SM4_SBOX_T[j] == L(SM4_SBOX[j]). */ -alignas(64) -const uint32_t SM4_SBOX_T[256] = { +alignas(256) const uint32_t SM4_SBOX_T[256] = { 0x8ED55B5B, 0xD0924242, 0x4DEAA7A7, 0x06FDFBFB, 0xFCCF3333, 0x65E28787, 0xC93DF4F4, 0x6BB5DEDE, 0x4E165858, 0x6EB4DADA, 0x44145050, 0xCAC10B0B, 0x8828A0A0, 0x17F8EFEF, 0x9C2CB0B0, 0x11051414, 0x872BACAC, 0xFB669D9D, diff --git a/src/lib/block/sm4/sm4_armv8/sm4_armv8.cpp b/src/lib/block/sm4/sm4_armv8/sm4_armv8.cpp index be9f832c4..6deaf0d50 100644 --- a/src/lib/block/sm4/sm4_armv8/sm4_armv8.cpp +++ b/src/lib/block/sm4/sm4_armv8/sm4_armv8.cpp @@ -11,11 +11,11 @@ namespace Botan { namespace { -static const uint8_t qswap_tbl[16] = { +alignas(16) static const uint8_t qswap_tbl[16] = { 12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3 }; -static const uint8_t bswap_tbl[16] = { +alignas(16) static const uint8_t bswap_tbl[16] = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; diff --git a/src/lib/block/twofish/twofish_tab.cpp b/src/lib/block/twofish/twofish_tab.cpp index 669449c80..cd87c6c14 100644 --- a/src/lib/block/twofish/twofish_tab.cpp +++ b/src/lib/block/twofish/twofish_tab.cpp @@ -9,7 +9,7 @@ namespace Botan { -const uint8_t Twofish::Q0[256] = { +alignas(256) const uint8_t Twofish::Q0[256] = { 0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, 0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, 0x38, 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C, 0x43, 0x75, 0x37, 0x26, 0xFA, 0x13, 0x94, 0x48, 0xF2, 0xD0, 0x8B, 0x30, @@ -33,7 +33,7 @@ const uint8_t Twofish::Q0[256] = { 0xCA, 0x10, 0x21, 0xF0, 0xD3, 0x5D, 0x0F, 0x00, 0x6F, 0x9D, 0x36, 0x42, 0x4A, 0x5E, 0xC1, 0xE0 }; -const uint8_t Twofish::Q1[256] = { +alignas(256) const uint8_t Twofish::Q1[256] = { 0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, 0x4A, 0xD3, 0xE6, 0x6B, 0x45, 0x7D, 0xE8, 0x4B, 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1, 0x30, 0x0F, 0xF8, 0x1B, 0x87, 0xFA, 0x06, 0x3F, 0x5E, 0xBA, 0xAE, 0x5B, @@ -57,12 +57,12 @@ const uint8_t Twofish::Q1[256] = { 0xD7, 0x61, 0x1E, 0xB4, 0x50, 0x04, 0xF6, 0xC2, 0x16, 0x25, 0x86, 0x56, 0x55, 0x09, 0xBE, 0x91 }; -const uint8_t Twofish::RS[32] = { +alignas(64) const uint8_t Twofish::RS[32] = { 0x01, 0xA4, 0x02, 0xA4, 0xA4, 0x56, 0xA1, 0x55, 0x55, 0x82, 0xFC, 0x87, 0x87, 0xF3, 0xC1, 0x5A, 0x5A, 0x1E, 0x47, 0x58, 0x58, 0xC6, 0xAE, 0xDB, 0xDB, 0x68, 0x3D, 0x9E, 0x9E, 0xE5, 0x19, 0x03 }; -const uint8_t Twofish::EXP_TO_POLY[255] = { +alignas(256) const uint8_t Twofish::EXP_TO_POLY[255] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x4D, 0x9A, 0x79, 0xF2, 0xA9, 0x1F, 0x3E, 0x7C, 0xF8, 0xBD, 0x37, 0x6E, 0xDC, 0xF5, 0xA7, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xCD, 0xD7, 0xE3, 0x8B, 0x5B, 0xB6, @@ -86,7 +86,7 @@ const uint8_t Twofish::EXP_TO_POLY[255] = { 0x3B, 0x76, 0xEC, 0x95, 0x67, 0xCE, 0xD1, 0xEF, 0x93, 0x6B, 0xD6, 0xE1, 0x8F, 0x53, 0xA6 }; -const uint8_t Twofish::POLY_TO_EXP[255] = { +alignas(256) const uint8_t Twofish::POLY_TO_EXP[255] = { 0x00, 0x01, 0x17, 0x02, 0x2E, 0x18, 0x53, 0x03, 0x6A, 0x2F, 0x93, 0x19, 0x34, 0x54, 0x45, 0x04, 0x5C, 0x6B, 0xB6, 0x30, 0xA6, 0x94, 0x4B, 0x1A, 0x8C, 0x35, 0x81, 0x55, 0xAA, 0x46, 0x0D, 0x05, 0x24, 0x5D, 0x87, 0x6C, @@ -110,7 +110,7 @@ const uint8_t Twofish::POLY_TO_EXP[255] = { 0xB4, 0x0B, 0x7F, 0x51, 0x15, 0x43, 0x91, 0x10, 0x71, 0xBB, 0xEE, 0xBF, 0x85, 0xC8, 0xA1 }; -const uint32_t Twofish::MDS0[256] = { +alignas(256) const uint32_t Twofish::MDS0[256] = { 0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B, 0xE2E22BFB, 0x9E9EFAC8, 0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B, 0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B, 0x3C3C57D6, 0x93938A32, @@ -155,7 +155,7 @@ const uint32_t Twofish::MDS0[256] = { 0x04047FF6, 0x272746C2, 0xACACA716, 0xD0D07625, 0x50501386, 0xDCDCF756, 0x84841A55, 0xE1E15109, 0x7A7A25BE, 0x1313EF91 }; -const uint32_t Twofish::MDS1[256] = { +alignas(256) const uint32_t Twofish::MDS1[256] = { 0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252, 0xA3658080, 0x76DFE4E4, 0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A, 0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A, 0x0D54E6E6, 0xC6432020, @@ -200,7 +200,7 @@ const uint32_t Twofish::MDS1[256] = { 0x0FE25151, 0x00000000, 0x6F9A1919, 0x9DE01A1A, 0x368F9494, 0x42E6C7C7, 0x4AECC9C9, 0x5EFDD2D2, 0xC1AB7F7F, 0xE0D8A8A8 }; -const uint32_t Twofish::MDS2[256] = { +alignas(256) const uint32_t Twofish::MDS2[256] = { 0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B, 0xE2FBE22B, 0x9EC89EFA, 0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F, 0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7, 0x3CD63C57, 0x9332938A, @@ -245,7 +245,7 @@ const uint32_t Twofish::MDS2[256] = { 0x04F6047F, 0x27C22746, 0xAC16ACA7, 0xD025D076, 0x50865013, 0xDC56DCF7, 0x8455841A, 0xE109E151, 0x7ABE7A25, 0x139113EF }; -const uint32_t Twofish::MDS3[256] = { +alignas(256) const uint32_t Twofish::MDS3[256] = { 0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98, 0x6580A365, 0xDFE476DF, 0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866, 0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836, 0x54E60D54, 0x4320C643, diff --git a/src/lib/codec/base32/base32.cpp b/src/lib/codec/base32/base32.cpp index fc9883c86..b6f82f4c0 100644 --- a/src/lib/codec/base32/base32.cpp +++ b/src/lib/codec/base32/base32.cpp @@ -125,8 +125,7 @@ class Base32 final static const uint8_t m_base32_to_bin[256]; }; -const uint8_t Base32::m_bin_to_base32[32] = - { +alignas(64) const uint8_t Base32::m_bin_to_base32[32] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '2', '3', '4', '5', '6', '7' @@ -136,8 +135,7 @@ const uint8_t Base32::m_bin_to_base32[32] = * base32 Decoder Lookup Table * Warning: assumes ASCII encodings */ -const uint8_t Base32::m_base32_to_bin[256] = - { +alignas(256) const uint8_t Base32::m_base32_to_bin[256] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x80, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, diff --git a/src/lib/codec/base64/base64.cpp b/src/lib/codec/base64/base64.cpp index b4f78bca0..6d6f3aa0c 100644 --- a/src/lib/codec/base64/base64.cpp +++ b/src/lib/codec/base64/base64.cpp @@ -119,7 +119,7 @@ class Base64 final static const uint8_t m_base64_to_bin[256]; }; -const uint8_t Base64::m_bin_to_base64[64] = +alignas(64) const uint8_t Base64::m_bin_to_base64[64] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', @@ -132,7 +132,7 @@ const uint8_t Base64::m_bin_to_base64[64] = * base64 Decoder Lookup Table * Warning: assumes ASCII encodings */ -const uint8_t Base64::m_base64_to_bin[256] = +alignas(256) const uint8_t Base64::m_base64_to_bin[256] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x80, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, diff --git a/src/lib/codec/hex/hex.cpp b/src/lib/codec/hex/hex.cpp index 6bbd7c28e..a3411ea33 100644 --- a/src/lib/codec/hex/hex.cpp +++ b/src/lib/codec/hex/hex.cpp @@ -16,11 +16,11 @@ void hex_encode(char output[], size_t input_length, bool uppercase) { - static const uint8_t BIN_TO_HEX_UPPER[16] = { + alignas(64) static const uint8_t BIN_TO_HEX_UPPER[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - static const uint8_t BIN_TO_HEX_LOWER[16] = { + alignas(64) static const uint8_t BIN_TO_HEX_LOWER[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; @@ -61,7 +61,7 @@ size_t hex_decode(uint8_t output[], * Warning: this table assumes ASCII character encodings */ - static const uint8_t HEX_TO_BIN[256] = { + alignas(256) static const uint8_t HEX_TO_BIN[256] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, diff --git a/src/lib/hash/checksum/crc24/crc24.cpp b/src/lib/hash/checksum/crc24/crc24.cpp index 597dac33b..8db920f8c 100644 --- a/src/lib/hash/checksum/crc24/crc24.cpp +++ b/src/lib/hash/checksum/crc24/crc24.cpp @@ -14,7 +14,7 @@ namespace Botan { namespace { -const uint32_t CRC24_T0[256] = { +alignas(256) const uint32_t CRC24_T0[256] = { 0x00000000, 0x00FB4C86, 0x000DD58A, 0x00F6990C, 0x00E1E693, 0x001AAA15, 0x00EC3319, 0x00177F9F, 0x003981A1, 0x00C2CD27, 0x0034542B, 0x00CF18AD, 0x00D86732, 0x00232BB4, 0x00D5B2B8, 0x002EFE3E, 0x00894EC5, 0x00720243, 0x00849B4F, 0x007FD7C9, 0x0068A856, @@ -53,7 +53,7 @@ const uint32_t CRC24_T0[256] = { 0x000CD1F6, 0x00FA48FA, 0x0001047C, 0x002FFA42, 0x00D4B6C4, 0x00222FC8, 0x00D9634E, 0x00CE1CD1, 0x00355057, 0x00C3C95B, 0x003885DD }; -const uint32_t CRC24_T1[256] = { +alignas(256) const uint32_t CRC24_T1[256] = { 0x00000000, 0x00488F66, 0x00901ECD, 0x00D891AB, 0x00DB711C, 0x0093FE7A, 0x004B6FD1, 0x0003E0B7, 0x00B6E338, 0x00FE6C5E, 0x0026FDF5, 0x006E7293, 0x006D9224, 0x00251D42, 0x00FD8CE9, 0x00B5038F, 0x006CC771, 0x00244817, 0x00FCD9BC, 0x00B456DA, 0x00B7B66D, @@ -92,7 +92,7 @@ const uint32_t CRC24_T1[256] = { 0x00FA442B, 0x0022D580, 0x006A5AE6, 0x00DF5969, 0x0097D60F, 0x004F47A4, 0x0007C8C2, 0x00042875, 0x004CA713, 0x009436B8, 0x00DCB9DE }; -const uint32_t CRC24_T2[256] = { +alignas(256) const uint32_t CRC24_T2[256] = { 0x00000000, 0x00D70983, 0x00555F80, 0x00825603, 0x0051F286, 0x0086FB05, 0x0004AD06, 0x00D3A485, 0x0059A88B, 0x008EA108, 0x000CF70B, 0x00DBFE88, 0x00085A0D, 0x00DF538E, 0x005D058D, 0x008A0C0E, 0x00491C91, 0x009E1512, 0x001C4311, 0x00CB4A92, 0x0018EE17, @@ -131,7 +131,7 @@ const uint32_t CRC24_T2[256] = { 0x002633E5, 0x00A465E6, 0x00736C65, 0x00F9606B, 0x002E69E8, 0x00AC3FEB, 0x007B3668, 0x00A892ED, 0x007F9B6E, 0x00FDCD6D, 0x002AC4EE }; -const uint32_t CRC24_T3[256] = { +alignas(256) const uint32_t CRC24_T3[256] = { 0x00000000, 0x00520936, 0x00A4126C, 0x00F61B5A, 0x004825D8, 0x001A2CEE, 0x00EC37B4, 0x00BE3E82, 0x006B0636, 0x00390F00, 0x00CF145A, 0x009D1D6C, 0x002323EE, 0x00712AD8, 0x00873182, 0x00D538B4, 0x00D60C6C, 0x0084055A, 0x00721E00, 0x00201736, 0x009E29B4, diff --git a/src/lib/hash/checksum/crc32/crc32.cpp b/src/lib/hash/checksum/crc32/crc32.cpp index 75b8456b3..3f6e34996 100644 --- a/src/lib/hash/checksum/crc32/crc32.cpp +++ b/src/lib/hash/checksum/crc32/crc32.cpp @@ -20,7 +20,7 @@ std::unique_ptr<HashFunction> CRC32::copy_state() const */ void CRC32::add_data(const uint8_t input[], size_t length) { - const uint32_t TABLE[256] = { + alignas(256) const uint32_t TABLE[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, diff --git a/src/lib/hash/whirlpool/whrl_tab.cpp b/src/lib/hash/whirlpool/whrl_tab.cpp index 3cf913197..639a350cb 100644 --- a/src/lib/hash/whirlpool/whrl_tab.cpp +++ b/src/lib/hash/whirlpool/whrl_tab.cpp @@ -9,7 +9,7 @@ namespace Botan { -const uint64_t Whirlpool::C0[256] = { +alignas(256) const uint64_t Whirlpool::C0[256] = { 0x18186018C07830D8, 0x23238C2305AF4626, 0xC6C63FC67EF991B8, 0xE8E887E8136FCDFB, 0x878726874CA113CB, 0xB8B8DAB8A9626D11, 0x0101040108050209, 0x4F4F214F426E9E0D, 0x3636D836ADEE6C9B, 0xA6A6A2A6590451FF, 0xD2D26FD2DEBDB90C, 0xF5F5F3F5FB06F70E, @@ -75,7 +75,7 @@ const uint64_t Whirlpool::C0[256] = { 0xCCCC17CC2EDB85E2, 0x424215422A578468, 0x98985A98B4C22D2C, 0xA4A4AAA4490E55ED, 0x2828A0285D885075, 0x5C5C6D5CDA31B886, 0xF8F8C7F8933FED6B, 0x8686228644A411C2 }; -const uint64_t Whirlpool::C1[256] = { +alignas(256) const uint64_t Whirlpool::C1[256] = { 0xD818186018C07830, 0x2623238C2305AF46, 0xB8C6C63FC67EF991, 0xFBE8E887E8136FCD, 0xCB878726874CA113, 0x11B8B8DAB8A9626D, 0x0901010401080502, 0x0D4F4F214F426E9E, 0x9B3636D836ADEE6C, 0xFFA6A6A2A6590451, 0x0CD2D26FD2DEBDB9, 0x0EF5F5F3F5FB06F7, @@ -141,7 +141,7 @@ const uint64_t Whirlpool::C1[256] = { 0xE2CCCC17CC2EDB85, 0x68424215422A5784, 0x2C98985A98B4C22D, 0xEDA4A4AAA4490E55, 0x752828A0285D8850, 0x865C5C6D5CDA31B8, 0x6BF8F8C7F8933FED, 0xC28686228644A411 }; -const uint64_t Whirlpool::C2[256] = { +alignas(256) const uint64_t Whirlpool::C2[256] = { 0x30D818186018C078, 0x462623238C2305AF, 0x91B8C6C63FC67EF9, 0xCDFBE8E887E8136F, 0x13CB878726874CA1, 0x6D11B8B8DAB8A962, 0x0209010104010805, 0x9E0D4F4F214F426E, 0x6C9B3636D836ADEE, 0x51FFA6A6A2A65904, 0xB90CD2D26FD2DEBD, 0xF70EF5F5F3F5FB06, @@ -207,7 +207,7 @@ const uint64_t Whirlpool::C2[256] = { 0x85E2CCCC17CC2EDB, 0x8468424215422A57, 0x2D2C98985A98B4C2, 0x55EDA4A4AAA4490E, 0x50752828A0285D88, 0xB8865C5C6D5CDA31, 0xED6BF8F8C7F8933F, 0x11C28686228644A4 }; -const uint64_t Whirlpool::C3[256] = { +alignas(256) const uint64_t Whirlpool::C3[256] = { 0x7830D818186018C0, 0xAF462623238C2305, 0xF991B8C6C63FC67E, 0x6FCDFBE8E887E813, 0xA113CB878726874C, 0x626D11B8B8DAB8A9, 0x0502090101040108, 0x6E9E0D4F4F214F42, 0xEE6C9B3636D836AD, 0x0451FFA6A6A2A659, 0xBDB90CD2D26FD2DE, 0x06F70EF5F5F3F5FB, @@ -273,7 +273,7 @@ const uint64_t Whirlpool::C3[256] = { 0xDB85E2CCCC17CC2E, 0x578468424215422A, 0xC22D2C98985A98B4, 0x0E55EDA4A4AAA449, 0x8850752828A0285D, 0x31B8865C5C6D5CDA, 0x3FED6BF8F8C7F893, 0xA411C28686228644 }; -const uint64_t Whirlpool::C4[256] = { +alignas(256) const uint64_t Whirlpool::C4[256] = { 0xC07830D818186018, 0x05AF462623238C23, 0x7EF991B8C6C63FC6, 0x136FCDFBE8E887E8, 0x4CA113CB87872687, 0xA9626D11B8B8DAB8, 0x0805020901010401, 0x426E9E0D4F4F214F, 0xADEE6C9B3636D836, 0x590451FFA6A6A2A6, 0xDEBDB90CD2D26FD2, 0xFB06F70EF5F5F3F5, @@ -339,7 +339,7 @@ const uint64_t Whirlpool::C4[256] = { 0x2EDB85E2CCCC17CC, 0x2A57846842421542, 0xB4C22D2C98985A98, 0x490E55EDA4A4AAA4, 0x5D8850752828A028, 0xDA31B8865C5C6D5C, 0x933FED6BF8F8C7F8, 0x44A411C286862286 }; -const uint64_t Whirlpool::C5[256] = { +alignas(256) const uint64_t Whirlpool::C5[256] = { 0x18C07830D8181860, 0x2305AF462623238C, 0xC67EF991B8C6C63F, 0xE8136FCDFBE8E887, 0x874CA113CB878726, 0xB8A9626D11B8B8DA, 0x0108050209010104, 0x4F426E9E0D4F4F21, 0x36ADEE6C9B3636D8, 0xA6590451FFA6A6A2, 0xD2DEBDB90CD2D26F, 0xF5FB06F70EF5F5F3, @@ -405,7 +405,7 @@ const uint64_t Whirlpool::C5[256] = { 0xCC2EDB85E2CCCC17, 0x422A578468424215, 0x98B4C22D2C98985A, 0xA4490E55EDA4A4AA, 0x285D8850752828A0, 0x5CDA31B8865C5C6D, 0xF8933FED6BF8F8C7, 0x8644A411C2868622 }; -const uint64_t Whirlpool::C6[256] = { +alignas(256) const uint64_t Whirlpool::C6[256] = { 0x6018C07830D81818, 0x8C2305AF46262323, 0x3FC67EF991B8C6C6, 0x87E8136FCDFBE8E8, 0x26874CA113CB8787, 0xDAB8A9626D11B8B8, 0x0401080502090101, 0x214F426E9E0D4F4F, 0xD836ADEE6C9B3636, 0xA2A6590451FFA6A6, 0x6FD2DEBDB90CD2D2, 0xF3F5FB06F70EF5F5, @@ -471,7 +471,7 @@ const uint64_t Whirlpool::C6[256] = { 0x17CC2EDB85E2CCCC, 0x15422A5784684242, 0x5A98B4C22D2C9898, 0xAAA4490E55EDA4A4, 0xA0285D8850752828, 0x6D5CDA31B8865C5C, 0xC7F8933FED6BF8F8, 0x228644A411C28686 }; -const uint64_t Whirlpool::C7[256] = { +alignas(256) const uint64_t Whirlpool::C7[256] = { 0x186018C07830D818, 0x238C2305AF462623, 0xC63FC67EF991B8C6, 0xE887E8136FCDFBE8, 0x8726874CA113CB87, 0xB8DAB8A9626D11B8, 0x0104010805020901, 0x4F214F426E9E0D4F, 0x36D836ADEE6C9B36, 0xA6A2A6590451FFA6, 0xD26FD2DEBDB90CD2, 0xF5F3F5FB06F70EF5, diff --git a/src/lib/passhash/bcrypt/bcrypt.cpp b/src/lib/passhash/bcrypt/bcrypt.cpp index 0b53fe42c..d5bd40015 100644 --- a/src/lib/passhash/bcrypt/bcrypt.cpp +++ b/src/lib/passhash/bcrypt/bcrypt.cpp @@ -18,7 +18,7 @@ namespace { std::string bcrypt_base64_encode(const uint8_t input[], size_t length) { // Bcrypt uses a non-standard base64 alphabet - const uint8_t OPENBSD_BASE64_SUB[256] = { + alignas(256) const uint8_t OPENBSD_BASE64_SUB[256] = { 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, @@ -56,7 +56,7 @@ std::string bcrypt_base64_encode(const uint8_t input[], size_t length) std::vector<uint8_t> bcrypt_base64_decode(std::string input) { - const uint8_t OPENBSD_BASE64_SUB[256] = { + alignas(256) const uint8_t OPENBSD_BASE64_SUB[256] = { 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, |