7#include <botan/internal/hash_engine_sha2_64.h>
9#include <botan/assert.h>
10#include <botan/internal/algorithm_spec.h>
11#include <botan/internal/hash_engine_mdx.h>
12#include <botan/internal/sha2_64.h>
14#if defined(BOTAN_HAS_HASH_ENGINE_SHA2_64_AVX2) || defined(BOTAN_HAS_HASH_ENGINE_SHA2_64_AVX512)
15 #define BOTAN_HASH_ENGINE_SHA2_64_HAS_IMPL
16 #include <botan/internal/cpuid.h>
22 std::span<const uint8_t> common_prefix,
23 std::string_view provider) {
24#if defined(BOTAN_HASH_ENGINE_SHA2_64_HAS_IMPL)
25 size_t output_length = 0;
32 }
else if(req.
matches(
"SHA-384")) {
35 }
else if(req.
matches(
"SHA-512-256")) {
38 }
else if(
auto m = req.
match(
"Truncated(SHA-512,{bits:int})")) {
39 const size_t bits = m->integer(
"bits");
40 if(bits == 0 || bits % 8 != 0 || bits > 512) {
43 output_length = bits / 8;
54 const auto make_engine = [&](std::string_view feat,
58 return std::make_unique<MDx_MB_Engine<uint64_t>>(hash_fn,
70 #if defined(BOTAN_HAS_HASH_ENGINE_SHA2_64_AVX512)
72 if(provider.empty() || provider == *feat) {
78 #if defined(BOTAN_HAS_HASH_ENGINE_SHA2_64_AVX2)
80 if(provider.empty() || provider == *feat) {
bool matches(const AlgorithmPattern &pattern) const
std::optional< AlgorithmMatch > match(const AlgorithmPattern &pattern) const &
static std::optional< std::string > check(CPUID::Feature feat)
void(*)(const uint8_t *states, uint8_t *digests) extract_fn
void(*)(uint8_t *states, const uint8_t *const *blocks, size_t nblocks) compress_fn
static constexpr size_t output_bytes
static void init(digest_type &digest)
static constexpr size_t output_bytes
static void init(digest_type &digest)
static constexpr size_t block_bytes
static constexpr size_t output_bytes
static void init(digest_type &digest)
static constexpr size_t ctr_bytes
secure_vector< uint64_t > digest_type
static void compress_digest(digest_type &digest, std::span< const uint8_t > input, size_t blocks)
std::unique_ptr< Hash_Engine > create_sha2_64_mb_engine(std::string_view hash_fn, std::span< const uint8_t > common_prefix, std::string_view provider)
BOTAN_FN_ISA_SIMD_4X64 void sha2_64_mb_extract_x4(const uint8_t *states, uint8_t *digests)
BOTAN_FN_ISA_SIMD_8X64 void sha2_64_mb_compress_x8(uint8_t *states, const uint8_t *const *blocks, size_t nblocks)
BOTAN_FN_ISA_SIMD_4X64 void sha2_64_mb_compress_x4(uint8_t *states, const uint8_t *const *blocks, size_t nblocks)
BOTAN_FN_ISA_SIMD_8X64 void sha2_64_mb_extract_x8(const uint8_t *states, uint8_t *digests)