diff options
author | Jack Lloyd <[email protected]> | 2018-11-05 18:13:15 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-11-05 18:13:15 -0500 |
commit | b7fad32c861607a05575e16a7300233bd2eecacc (patch) | |
tree | 7188f2f43bf444d0d9714695feff938063f6b484 | |
parent | f4756ed6e393e91e0991e35bc862f258513889cb (diff) |
Remove SIMD_32 typedef
It is confusing since its not clear from the name how many
elements it has, and this gives consistency with SIMD_8x32 type.
-rw-r--r-- | src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp | 52 | ||||
-rw-r--r-- | src/lib/block/serpent/serpent_simd/serpent_simd.cpp | 32 | ||||
-rw-r--r-- | src/lib/block/shacal2/shacal2_simd/shacal2_simd.cpp | 12 | ||||
-rw-r--r-- | src/lib/utils/simd/simd_32.h | 2 |
4 files changed, 48 insertions, 50 deletions
diff --git a/src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp b/src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp index f9a696d29..83467a054 100644 --- a/src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp +++ b/src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp @@ -15,7 +15,7 @@ namespace Botan { */ #define NOK_SIMD_THETA(A0, A1, A2, A3, K0, K1, K2, K3) \ do { \ - SIMD_32 T = A0 ^ A2; \ + SIMD_4x32 T = A0 ^ A2; \ T ^= T.rotl<8>() ^ T.rotr<8>(); \ A1 ^= T; \ A3 ^= T; \ @@ -40,7 +40,7 @@ namespace Botan { A1 ^= A3.andc(~A2); \ A0 ^= A2 & A1; \ \ - SIMD_32 T = A3; \ + SIMD_4x32 T = A3; \ A3 = A0; \ A0 = T; \ \ @@ -55,21 +55,21 @@ namespace Botan { */ void Noekeon::simd_encrypt_4(const uint8_t in[], uint8_t out[]) const { - const SIMD_32 K0 = SIMD_32::splat(m_EK[0]); - const SIMD_32 K1 = SIMD_32::splat(m_EK[1]); - const SIMD_32 K2 = SIMD_32::splat(m_EK[2]); - const SIMD_32 K3 = SIMD_32::splat(m_EK[3]); + const SIMD_4x32 K0 = SIMD_4x32::splat(m_EK[0]); + const SIMD_4x32 K1 = SIMD_4x32::splat(m_EK[1]); + const SIMD_4x32 K2 = SIMD_4x32::splat(m_EK[2]); + const SIMD_4x32 K3 = SIMD_4x32::splat(m_EK[3]); - SIMD_32 A0 = SIMD_32::load_be(in ); - SIMD_32 A1 = SIMD_32::load_be(in + 16); - SIMD_32 A2 = SIMD_32::load_be(in + 32); - SIMD_32 A3 = SIMD_32::load_be(in + 48); + SIMD_4x32 A0 = SIMD_4x32::load_be(in ); + SIMD_4x32 A1 = SIMD_4x32::load_be(in + 16); + SIMD_4x32 A2 = SIMD_4x32::load_be(in + 32); + SIMD_4x32 A3 = SIMD_4x32::load_be(in + 48); - SIMD_32::transpose(A0, A1, A2, A3); + SIMD_4x32::transpose(A0, A1, A2, A3); for(size_t i = 0; i != 16; ++i) { - A0 ^= SIMD_32::splat(RC[i]); + A0 ^= SIMD_4x32::splat(RC[i]); NOK_SIMD_THETA(A0, A1, A2, A3, K0, K1, K2, K3); @@ -84,10 +84,10 @@ void Noekeon::simd_encrypt_4(const uint8_t in[], uint8_t out[]) const A3 = A3.rotr<2>(); } - A0 ^= SIMD_32::splat(RC[16]); + A0 ^= SIMD_4x32::splat(RC[16]); NOK_SIMD_THETA(A0, A1, A2, A3, K0, K1, K2, K3); - SIMD_32::transpose(A0, A1, A2, A3); + SIMD_4x32::transpose(A0, A1, A2, A3); A0.store_be(out); A1.store_be(out + 16); @@ -100,23 +100,23 @@ void Noekeon::simd_encrypt_4(const uint8_t in[], uint8_t out[]) const */ void Noekeon::simd_decrypt_4(const uint8_t in[], uint8_t out[]) const { - const SIMD_32 K0 = SIMD_32::splat(m_DK[0]); - const SIMD_32 K1 = SIMD_32::splat(m_DK[1]); - const SIMD_32 K2 = SIMD_32::splat(m_DK[2]); - const SIMD_32 K3 = SIMD_32::splat(m_DK[3]); + const SIMD_4x32 K0 = SIMD_4x32::splat(m_DK[0]); + const SIMD_4x32 K1 = SIMD_4x32::splat(m_DK[1]); + const SIMD_4x32 K2 = SIMD_4x32::splat(m_DK[2]); + const SIMD_4x32 K3 = SIMD_4x32::splat(m_DK[3]); - SIMD_32 A0 = SIMD_32::load_be(in ); - SIMD_32 A1 = SIMD_32::load_be(in + 16); - SIMD_32 A2 = SIMD_32::load_be(in + 32); - SIMD_32 A3 = SIMD_32::load_be(in + 48); + SIMD_4x32 A0 = SIMD_4x32::load_be(in ); + SIMD_4x32 A1 = SIMD_4x32::load_be(in + 16); + SIMD_4x32 A2 = SIMD_4x32::load_be(in + 32); + SIMD_4x32 A3 = SIMD_4x32::load_be(in + 48); - SIMD_32::transpose(A0, A1, A2, A3); + SIMD_4x32::transpose(A0, A1, A2, A3); for(size_t i = 0; i != 16; ++i) { NOK_SIMD_THETA(A0, A1, A2, A3, K0, K1, K2, K3); - A0 ^= SIMD_32::splat(RC[16-i]); + A0 ^= SIMD_4x32::splat(RC[16-i]); A1 = A1.rotl<1>(); A2 = A2.rotl<5>(); @@ -130,9 +130,9 @@ void Noekeon::simd_decrypt_4(const uint8_t in[], uint8_t out[]) const } NOK_SIMD_THETA(A0, A1, A2, A3, K0, K1, K2, K3); - A0 ^= SIMD_32::splat(RC[0]); + A0 ^= SIMD_4x32::splat(RC[0]); - SIMD_32::transpose(A0, A1, A2, A3); + SIMD_4x32::transpose(A0, A1, A2, A3); A0.store_be(out); A1.store_be(out + 16); diff --git a/src/lib/block/serpent/serpent_simd/serpent_simd.cpp b/src/lib/block/serpent/serpent_simd/serpent_simd.cpp index 8148e321f..7d882c61e 100644 --- a/src/lib/block/serpent/serpent_simd/serpent_simd.cpp +++ b/src/lib/block/serpent/serpent_simd/serpent_simd.cpp @@ -13,10 +13,10 @@ namespace Botan { #define key_xor(round, B0, B1, B2, B3) \ do { \ - B0 ^= SIMD_32::splat(m_round_key[4*round ]); \ - B1 ^= SIMD_32::splat(m_round_key[4*round+1]); \ - B2 ^= SIMD_32::splat(m_round_key[4*round+2]); \ - B3 ^= SIMD_32::splat(m_round_key[4*round+3]); \ + B0 ^= SIMD_4x32::splat(m_round_key[4*round ]); \ + B1 ^= SIMD_4x32::splat(m_round_key[4*round+1]); \ + B2 ^= SIMD_4x32::splat(m_round_key[4*round+2]); \ + B3 ^= SIMD_4x32::splat(m_round_key[4*round+3]); \ } while(0) /* @@ -55,12 +55,12 @@ namespace Botan { */ void Serpent::simd_encrypt_4(const uint8_t in[64], uint8_t out[64]) const { - SIMD_32 B0 = SIMD_32::load_le(in); - SIMD_32 B1 = SIMD_32::load_le(in + 16); - SIMD_32 B2 = SIMD_32::load_le(in + 32); - SIMD_32 B3 = SIMD_32::load_le(in + 48); + SIMD_4x32 B0 = SIMD_4x32::load_le(in); + SIMD_4x32 B1 = SIMD_4x32::load_le(in + 16); + SIMD_4x32 B2 = SIMD_4x32::load_le(in + 32); + SIMD_4x32 B3 = SIMD_4x32::load_le(in + 48); - SIMD_32::transpose(B0, B1, B2, B3); + SIMD_4x32::transpose(B0, B1, B2, B3); key_xor( 0,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor( 1,B0,B1,B2,B3); SBoxE2(B0,B1,B2,B3); transform(B0,B1,B2,B3); @@ -98,7 +98,7 @@ void Serpent::simd_encrypt_4(const uint8_t in[64], uint8_t out[64]) const key_xor(30,B0,B1,B2,B3); SBoxE7(B0,B1,B2,B3); transform(B0,B1,B2,B3); key_xor(31,B0,B1,B2,B3); SBoxE8(B0,B1,B2,B3); key_xor(32,B0,B1,B2,B3); - SIMD_32::transpose(B0, B1, B2, B3); + SIMD_4x32::transpose(B0, B1, B2, B3); B0.store_le(out); B1.store_le(out + 16); @@ -111,12 +111,12 @@ void Serpent::simd_encrypt_4(const uint8_t in[64], uint8_t out[64]) const */ void Serpent::simd_decrypt_4(const uint8_t in[64], uint8_t out[64]) const { - SIMD_32 B0 = SIMD_32::load_le(in); - SIMD_32 B1 = SIMD_32::load_le(in + 16); - SIMD_32 B2 = SIMD_32::load_le(in + 32); - SIMD_32 B3 = SIMD_32::load_le(in + 48); + SIMD_4x32 B0 = SIMD_4x32::load_le(in); + SIMD_4x32 B1 = SIMD_4x32::load_le(in + 16); + SIMD_4x32 B2 = SIMD_4x32::load_le(in + 32); + SIMD_4x32 B3 = SIMD_4x32::load_le(in + 48); - SIMD_32::transpose(B0, B1, B2, B3); + SIMD_4x32::transpose(B0, B1, B2, B3); key_xor(32,B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor(31,B0,B1,B2,B3); i_transform(B0,B1,B2,B3); SBoxD7(B0,B1,B2,B3); key_xor(30,B0,B1,B2,B3); @@ -154,7 +154,7 @@ void Serpent::simd_decrypt_4(const uint8_t in[64], uint8_t out[64]) const i_transform(B0,B1,B2,B3); SBoxD2(B0,B1,B2,B3); key_xor( 1,B0,B1,B2,B3); i_transform(B0,B1,B2,B3); SBoxD1(B0,B1,B2,B3); key_xor( 0,B0,B1,B2,B3); - SIMD_32::transpose(B0, B1, B2, B3); + SIMD_4x32::transpose(B0, B1, B2, B3); B0.store_le(out); B1.store_le(out + 16); diff --git a/src/lib/block/shacal2/shacal2_simd/shacal2_simd.cpp b/src/lib/block/shacal2/shacal2_simd/shacal2_simd.cpp index bdcac1482..6d15faf1a 100644 --- a/src/lib/block/shacal2/shacal2_simd/shacal2_simd.cpp +++ b/src/lib/block/shacal2/shacal2_simd/shacal2_simd.cpp @@ -13,23 +13,23 @@ namespace Botan { namespace { inline -void SHACAL2_Fwd(const SIMD_32& A, const SIMD_32& B, const SIMD_32& C, SIMD_32& D, - const SIMD_32& E, const SIMD_32& F, const SIMD_32& G, SIMD_32& H, +void SHACAL2_Fwd(const SIMD_4x32& A, const SIMD_4x32& B, const SIMD_4x32& C, SIMD_4x32& D, + const SIMD_4x32& E, const SIMD_4x32& F, const SIMD_4x32& G, SIMD_4x32& H, uint32_t RK) { - H += E.rho<6,11,25>() + ((E & F) ^ (~E & G)) + SIMD_32::splat(RK); + H += E.rho<6,11,25>() + ((E & F) ^ (~E & G)) + SIMD_4x32::splat(RK); D += H; H += A.rho<2,13,22>() + ((A & B) | ((A | B) & C)); } inline -void SHACAL2_Rev(const SIMD_32& A, const SIMD_32& B, const SIMD_32& C, SIMD_32& D, - const SIMD_32& E, const SIMD_32& F, const SIMD_32& G, SIMD_32& H, +void SHACAL2_Rev(const SIMD_4x32& A, const SIMD_4x32& B, const SIMD_4x32& C, SIMD_4x32& D, + const SIMD_4x32& E, const SIMD_4x32& F, const SIMD_4x32& G, SIMD_4x32& H, uint32_t RK) { H -= A.rho<2,13,22>() + ((A & B) | ((A | B) & C)); D -= H; - H -= E.rho<6,11,25>() + ((E & F) ^ (~E & G)) + SIMD_32::splat(RK); + H -= E.rho<6,11,25>() + ((E & F) ^ (~E & G)) + SIMD_4x32::splat(RK); } } diff --git a/src/lib/utils/simd/simd_32.h b/src/lib/utils/simd/simd_32.h index 0198028ba..533dadfa5 100644 --- a/src/lib/utils/simd/simd_32.h +++ b/src/lib/utils/simd/simd_32.h @@ -645,8 +645,6 @@ class SIMD_4x32 final #endif }; -typedef SIMD_4x32 SIMD_32; - } #endif |