diff options
author | Jack Lloyd <[email protected]> | 2019-01-28 15:13:59 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-01-30 19:28:39 -0500 |
commit | d9a5ffe01f33d509afac68563dbb26a9dc8b9ef6 (patch) | |
tree | af3605c57ef457a2987b842908f702966082ec97 /src/lib/block | |
parent | 8c835b3b1238083c4b4bb4a90e4d9e9b38dffb11 (diff) |
Refactor CPUID to make it thread safe
Needed for #1819 and unfortunately Windows does not allow thread local
data to be stored as a member of a DLL exported class. So hide it
behind an accessor function instead.
This slows down CPUID test somewhat and I would like to address that
but it seems hard without breaking the CPUID API, which is for better
or worse public.
Diffstat (limited to 'src/lib/block')
-rw-r--r-- | src/lib/block/aria/aria.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/block/aria/aria.cpp b/src/lib/block/aria/aria.cpp index 2a02330c9..23a8657a1 100644 --- a/src/lib/block/aria/aria.cpp +++ b/src/lib/block/aria/aria.cpp @@ -221,17 +221,18 @@ inline void ARIA_FE(uint32_t& T0, uint32_t& T1, uint32_t& T2, uint32_t& T3) void transform(const uint8_t in[], uint8_t out[], size_t blocks, const secure_vector<uint32_t>& KS) { - // Hit every cache line of S1 and S2 - const size_t cache_line_size = CPUID::cache_line_size(); - /* - * This initializer ensures Z == 0xFFFFFFFF for any cache line size - * in {32,64,128,256,512} + * Hit every cache line of S1, S2, X1, X2 + * + * The initializer of Z ensures Z == 0xFFFFFFFF for any cache line + * size that is a power of 2 and <= 512 */ + const size_t cache_line_size = CPUID::cache_line_size(); + volatile uint32_t Z = 0x11101010; for(size_t i = 0; i < 256; i += cache_line_size / sizeof(uint32_t)) { - Z |= S1[i] | S2[i]; + Z |= S1[i] | S2[i] | X1[i] | X2[i]; } const size_t ROUNDS = (KS.size() / 4) - 1; |