diff options
author | Jack Lloyd <[email protected]> | 2020-05-12 08:04:33 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2020-05-12 08:04:33 -0400 |
commit | 8dc9c35dd2ee0f6dacd8cb6c5ee33861837b8526 (patch) | |
tree | 38ea34c5f2ea3991243466325052f8d4e4551b1e /src/lib/block | |
parent | 057f8e18a0fc059628af8614b2c8a9f23eebfda9 (diff) |
Save one NOT instruction in AES Sbox
~(X ^ Y) == X ^ ~Y and both uses of tc18 are inverted so by
inverting the value of tc18 we save one NOT.
The circuit minimization team work considers XOR and NXOR equal in
cost but that's not the case for CPUs.
Diffstat (limited to 'src/lib/block')
-rw-r--r-- | src/lib/block/aes/aes.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/block/aes/aes.cpp b/src/lib/block/aes/aes.cpp index 0ecc49bd8..95f11fc39 100644 --- a/src/lib/block/aes/aes.cpp +++ b/src/lib/block/aes/aes.cpp @@ -193,12 +193,12 @@ void AES_SBOX(uint32_t V[8]) const uint32_t S3 = tc3 ^ tc11; const uint32_t tc16 = z6 ^ tc8; const uint32_t tc17 = z14 ^ tc10; - const uint32_t tc18 = tc13 ^ tc14; - const uint32_t S7 = ~(z12 ^ tc18); + const uint32_t tc18 = ~tc13 ^ tc14; + const uint32_t S7 = z12 ^ tc18; const uint32_t tc20 = z15 ^ tc16; const uint32_t tc21 = tc2 ^ z11; const uint32_t S0 = tc3 ^ tc16; - const uint32_t S6 = ~(tc10 ^ tc18); + const uint32_t S6 = tc10 ^ tc18; const uint32_t S4 = tc14 ^ S3; const uint32_t S1 = ~(S3 ^ tc16); const uint32_t tc26 = tc17 ^ tc20; |