diff options
author | Jack Lloyd <[email protected]> | 2021-01-04 18:59:43 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2021-04-16 20:08:37 -0400 |
commit | 32bf9784bd6ee29cb3ffa173f0a734e9edce2dac (patch) | |
tree | 05815c2441c0f6964fa6fe587330fda8ed86b617 /src/lib/block/twofish | |
parent | 04fc4b81f0ef44bcfe3a64ffd45bb61f0a92b60d (diff) |
Make get_byte take a compile-time constant index
Add get_byte_var for the few cases that need a variable index
Diffstat (limited to 'src/lib/block/twofish')
-rw-r--r-- | src/lib/block/twofish/twofish.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/block/twofish/twofish.cpp b/src/lib/block/twofish/twofish.cpp index 7115aa689..dfb807c84 100644 --- a/src/lib/block/twofish/twofish.cpp +++ b/src/lib/block/twofish/twofish.cpp @@ -20,10 +20,10 @@ inline void TF_E(uint32_t A, uint32_t B, uint32_t& C, uint32_t& D, uint32_t RK1, uint32_t RK2, const secure_vector<uint32_t>& SB) { - uint32_t X = SB[ get_byte(3, A)] ^ SB[256+get_byte(2, A)] ^ - SB[512+get_byte(1, A)] ^ SB[768+get_byte(0, A)]; - uint32_t Y = SB[ get_byte(0, B)] ^ SB[256+get_byte(3, B)] ^ - SB[512+get_byte(2, B)] ^ SB[768+get_byte(1, B)]; + uint32_t X = SB[ get_byte<3>(A)] ^ SB[256+get_byte<2>(A)] ^ + SB[512+get_byte<1>(A)] ^ SB[768+get_byte<0>(A)]; + uint32_t Y = SB[ get_byte<0>(B)] ^ SB[256+get_byte<3>(B)] ^ + SB[512+get_byte<2>(B)] ^ SB[768+get_byte<1>(B)]; X += Y; Y += X; @@ -39,10 +39,10 @@ inline void TF_D(uint32_t A, uint32_t B, uint32_t& C, uint32_t& D, uint32_t RK1, uint32_t RK2, const secure_vector<uint32_t>& SB) { - uint32_t X = SB[ get_byte(3, A)] ^ SB[256+get_byte(2, A)] ^ - SB[512+get_byte(1, A)] ^ SB[768+get_byte(0, A)]; - uint32_t Y = SB[ get_byte(0, B)] ^ SB[256+get_byte(3, B)] ^ - SB[512+get_byte(2, B)] ^ SB[768+get_byte(1, B)]; + uint32_t X = SB[ get_byte<3>(A)] ^ SB[256+get_byte<2>(A)] ^ + SB[512+get_byte<1>(A)] ^ SB[768+get_byte<0>(A)]; + uint32_t Y = SB[ get_byte<0>(B)] ^ SB[256+get_byte<3>(B)] ^ + SB[512+get_byte<2>(B)] ^ SB[768+get_byte<1>(B)]; X += Y; Y += X; |