aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/hash/sha2_64
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2021-01-09 09:12:04 -0500
committerJack Lloyd <[email protected]>2021-01-09 10:11:11 -0500
commit2aca7afa7224ab83acc4c6dd4455e420a21450ed (patch)
treeb90ffac9e06b36ed92da51cc5162f06cf3dfdc14 /src/lib/hash/sha2_64
parent55c40989d4bbad795f928eaf71a111eb45c2c636 (diff)
Add choose and majority functions
Diffstat (limited to 'src/lib/hash/sha2_64')
-rw-r--r--src/lib/hash/sha2_64/sha2_64.cpp5
-rw-r--r--src/lib/hash/sha2_64/sha2_64_bmi2/sha2_64_bmi2.cpp5
2 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/hash/sha2_64/sha2_64.cpp b/src/lib/hash/sha2_64/sha2_64.cpp
index b34623070..cc4690bbd 100644
--- a/src/lib/hash/sha2_64/sha2_64.cpp
+++ b/src/lib/hash/sha2_64/sha2_64.cpp
@@ -8,6 +8,7 @@
#include <botan/internal/sha2_64.h>
#include <botan/internal/loadstor.h>
#include <botan/internal/rotate.h>
+#include <botan/internal/bit_ops.h>
#include <botan/internal/cpuid.h>
namespace Botan {
@@ -55,9 +56,9 @@ std::unique_ptr<HashFunction> SHA_512_256::copy_state() const
const uint64_t A_rho = rotr<28>(A) ^ rotr<34>(A) ^ rotr<39>(A); \
const uint64_t M2_sigma = rotr<19>(M2) ^ rotr<61>(M2) ^ (M2 >> 6); \
const uint64_t M4_sigma = rotr<1>(M4) ^ rotr<8>(M4) ^ (M4 >> 7); \
- H += magic + E_rho + ((E & F) ^ (~E & G)) + M1; \
+ H += magic + E_rho + choose(E, F, G) + M1; \
D += H; \
- H += A_rho + ((A & B) | ((A | B) & C)); \
+ H += A_rho + majority(A, B, C); \
M1 += M2_sigma + M3 + M4_sigma; \
} while(0);
diff --git a/src/lib/hash/sha2_64/sha2_64_bmi2/sha2_64_bmi2.cpp b/src/lib/hash/sha2_64/sha2_64_bmi2/sha2_64_bmi2.cpp
index b53da8cb4..9ebf76c78 100644
--- a/src/lib/hash/sha2_64/sha2_64_bmi2/sha2_64_bmi2.cpp
+++ b/src/lib/hash/sha2_64/sha2_64_bmi2/sha2_64_bmi2.cpp
@@ -7,6 +7,7 @@
#include <botan/internal/sha2_64.h>
#include <botan/internal/loadstor.h>
#include <botan/internal/rotate.h>
+#include <botan/internal/bit_ops.h>
namespace Botan {
@@ -22,9 +23,9 @@ namespace Botan {
const uint64_t A_rho = rotr<28>(A) ^ rotr<34>(A) ^ rotr<39>(A); \
const uint64_t M2_sigma = rotr<19>(M2) ^ rotr<61>(M2) ^ (M2 >> 6); \
const uint64_t M4_sigma = rotr<1>(M4) ^ rotr<8>(M4) ^ (M4 >> 7); \
- H += magic + E_rho + ((E & F) ^ (~E & G)) + M1; \
+ H += magic + E_rho + choose(E, F, G) + M1; \
D += H; \
- H += A_rho + ((A & B) | ((A | B) & C)); \
+ H += A_rho + majority(A, B, C); \
M1 += M2_sigma + M3 + M4_sigma; \
} while(0);