aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2020-12-19 10:07:24 -0500
committerJack Lloyd <[email protected]>2020-12-19 10:08:46 -0500
commit14b9bc0fa811f92eb0d5b3a9abd872c076377d97 (patch)
tree04cb00e822494c6ca668b3c45a2eef6c5d116acf /src/lib/block
parent3f018280ee14852251503eee86d501bfa3fac20c (diff)
Optimize and cleanup SHACAL2
The SHA-2 Ch and Maj functions can be done very fast on both AltiVec and NEON. Also, we can take advantage of the POWER8 SHA-2 extensions here.
Diffstat (limited to 'src/lib/block')
-rw-r--r--src/lib/block/shacal2/shacal2_avx2/shacal2_avx2.cpp8
-rw-r--r--src/lib/block/shacal2/shacal2_simd/shacal2_simd.cpp8
2 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/block/shacal2/shacal2_avx2/shacal2_avx2.cpp b/src/lib/block/shacal2/shacal2_avx2/shacal2_avx2.cpp
index cb83fece8..e9928d3c1 100644
--- a/src/lib/block/shacal2/shacal2_avx2/shacal2_avx2.cpp
+++ b/src/lib/block/shacal2/shacal2_avx2/shacal2_avx2.cpp
@@ -16,9 +16,9 @@ void BOTAN_FORCE_INLINE BOTAN_FUNC_ISA("avx2")
const SIMD_8x32& E, const SIMD_8x32& F, const SIMD_8x32& G, SIMD_8x32& H,
uint32_t RK)
{
- H += E.rho<6,11,25>() + ((E & F) ^ (~E & G)) + SIMD_8x32::splat(RK);
+ H += E.sigma1() + SIMD_8x32::choose(E, F, G) + SIMD_8x32::splat(RK);
D += H;
- H += A.rho<2,13,22>() + ((A & B) | ((A | B) & C));
+ H += A.sigma0() + SIMD_8x32::majority(A, B, C);
}
void BOTAN_FORCE_INLINE BOTAN_FUNC_ISA("avx2")
@@ -26,9 +26,9 @@ void BOTAN_FORCE_INLINE BOTAN_FUNC_ISA("avx2")
const SIMD_8x32& E, const SIMD_8x32& F, const SIMD_8x32& G, SIMD_8x32& H,
uint32_t RK)
{
- H -= A.rho<2,13,22>() + ((A & B) | ((A | B) & C));
+ H -= A.sigma0() + SIMD_8x32::majority(A, B, C);
D -= H;
- H -= E.rho<6,11,25>() + ((E & F) ^ (~E & G)) + SIMD_8x32::splat(RK);
+ H -= E.sigma1() + SIMD_8x32::choose(E, F, G) + SIMD_8x32::splat(RK);
}
}
diff --git a/src/lib/block/shacal2/shacal2_simd/shacal2_simd.cpp b/src/lib/block/shacal2/shacal2_simd/shacal2_simd.cpp
index c7b6182f2..7b541a1a4 100644
--- a/src/lib/block/shacal2/shacal2_simd/shacal2_simd.cpp
+++ b/src/lib/block/shacal2/shacal2_simd/shacal2_simd.cpp
@@ -17,9 +17,9 @@ void SHACAL2_Fwd(const SIMD_4x32& A, const SIMD_4x32& B, const SIMD_4x32& C, SIM
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_4x32::splat(RK);
+ H += E.sigma1() + SIMD_4x32::choose(E, F, G) + SIMD_4x32::splat(RK);
D += H;
- H += A.rho<2,13,22>() + ((A & B) | ((A | B) & C));
+ H += A.sigma0() + SIMD_4x32::majority(A, B, C);
}
inline
@@ -27,9 +27,9 @@ void SHACAL2_Rev(const SIMD_4x32& A, const SIMD_4x32& B, const SIMD_4x32& C, SIM
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));
+ H -= A.sigma0() + SIMD_4x32::majority(A, B, C);
D -= H;
- H -= E.rho<6,11,25>() + ((E & F) ^ (~E & G)) + SIMD_4x32::splat(RK);
+ H -= E.sigma1() + SIMD_4x32::choose(E, F, G) + SIMD_4x32::splat(RK);
}
}