9#include <botan/internal/scan_name.h>
10#include <botan/exceptn.h>
12#if defined(BOTAN_HAS_ADLER32)
13 #include <botan/internal/adler32.h>
16#if defined(BOTAN_HAS_CRC24)
17 #include <botan/internal/crc24.h>
20#if defined(BOTAN_HAS_CRC32)
21 #include <botan/internal/crc32.h>
24#if defined(BOTAN_HAS_GOST_34_11)
25 #include <botan/internal/gost_3411.h>
28#if defined(BOTAN_HAS_KECCAK)
29 #include <botan/internal/keccak.h>
32#if defined(BOTAN_HAS_MD4)
33 #include <botan/internal/md4.h>
36#if defined(BOTAN_HAS_MD5)
37 #include <botan/internal/md5.h>
40#if defined(BOTAN_HAS_RIPEMD_160)
41 #include <botan/internal/rmd160.h>
44#if defined(BOTAN_HAS_SHA1)
45 #include <botan/internal/sha1.h>
48#if defined(BOTAN_HAS_SHA2_32)
49 #include <botan/internal/sha2_32.h>
52#if defined(BOTAN_HAS_SHA2_64)
53 #include <botan/internal/sha2_64.h>
56#if defined(BOTAN_HAS_SHA3)
57 #include <botan/internal/sha3.h>
60#if defined(BOTAN_HAS_SHAKE)
61 #include <botan/internal/shake.h>
64#if defined(BOTAN_HAS_SKEIN_512)
65 #include <botan/internal/skein_512.h>
68#if defined(BOTAN_HAS_STREEBOG)
69 #include <botan/internal/streebog.h>
72#if defined(BOTAN_HAS_SM3)
73 #include <botan/internal/sm3.h>
76#if defined(BOTAN_HAS_WHIRLPOOL)
77 #include <botan/internal/whrlpool.h>
80#if defined(BOTAN_HAS_PARALLEL_HASH)
81 #include <botan/internal/par_hash.h>
84#if defined(BOTAN_HAS_TRUNCATED_HASH)
85 #include <botan/internal/trunc_hash.h>
88#if defined(BOTAN_HAS_COMB4P)
89 #include <botan/internal/comb4p.h>
92#if defined(BOTAN_HAS_BLAKE2B)
93 #include <botan/internal/blake2b.h>
96#if defined(BOTAN_HAS_COMMONCRYPTO)
97 #include <botan/internal/commoncrypto.h>
103 std::string_view provider)
106#if defined(BOTAN_HAS_COMMONCRYPTO)
120#if defined(BOTAN_HAS_SHA1)
121 if(algo_spec ==
"SHA-1")
123 return std::make_unique<SHA_1>();
127#if defined(BOTAN_HAS_SHA2_32)
128 if(algo_spec ==
"SHA-224")
130 return std::make_unique<SHA_224>();
133 if(algo_spec ==
"SHA-256")
135 return std::make_unique<SHA_256>();
139#if defined(BOTAN_HAS_SHA2_64)
140 if(algo_spec ==
"SHA-384")
142 return std::make_unique<SHA_384>();
145 if(algo_spec ==
"SHA-512")
147 return std::make_unique<SHA_512>();
150 if(algo_spec ==
"SHA-512-256")
152 return std::make_unique<SHA_512_256>();
156#if defined(BOTAN_HAS_RIPEMD_160)
157 if(algo_spec ==
"RIPEMD-160")
159 return std::make_unique<RIPEMD_160>();
163#if defined(BOTAN_HAS_WHIRLPOOL)
164 if(algo_spec ==
"Whirlpool")
166 return std::make_unique<Whirlpool>();
170#if defined(BOTAN_HAS_MD5)
171 if(algo_spec ==
"MD5")
173 return std::make_unique<MD5>();
177#if defined(BOTAN_HAS_MD4)
178 if(algo_spec ==
"MD4")
180 return std::make_unique<MD4>();
184#if defined(BOTAN_HAS_GOST_34_11)
185 if(algo_spec ==
"GOST-R-34.11-94" || algo_spec ==
"GOST-34.11")
187 return std::make_unique<GOST_34_11>();
191#if defined(BOTAN_HAS_ADLER32)
192 if(algo_spec ==
"Adler32")
194 return std::make_unique<Adler32>();
198#if defined(BOTAN_HAS_CRC24)
199 if(algo_spec ==
"CRC24")
201 return std::make_unique<CRC24>();
205#if defined(BOTAN_HAS_CRC32)
206 if(algo_spec ==
"CRC32")
208 return std::make_unique<CRC32>();
212#if defined(BOTAN_HAS_STREEBOG)
213 if(algo_spec ==
"Streebog-256")
215 return std::make_unique<Streebog>(256);
217 if(algo_spec ==
"Streebog-512")
219 return std::make_unique<Streebog>(512);
223#if defined(BOTAN_HAS_SM3)
224 if(algo_spec ==
"SM3")
226 return std::make_unique<SM3>();
232#if defined(BOTAN_HAS_SKEIN_512)
239#if defined(BOTAN_HAS_BLAKE2B)
246#if defined(BOTAN_HAS_KECCAK)
253#if defined(BOTAN_HAS_SHA3)
260#if defined(BOTAN_HAS_SHAKE)
271#if defined(BOTAN_HAS_PARALLEL_HASH)
274 std::vector<std::unique_ptr<HashFunction>> hashes;
276 for(
size_t i = 0; i != req.
arg_count(); ++i)
283 hashes.push_back(std::move(h));
286 return std::make_unique<Parallel>(hashes);
290#if defined(BOTAN_HAS_TRUNCATED_HASH)
303#if defined(BOTAN_HAS_COMB4P)
310 return std::make_unique<Comb4P>(std::move(h1), std::move(h2));
319std::unique_ptr<HashFunction>
321 std::string_view provider)
332 return probe_providers_of<HashFunction>(algo_spec, {
"base",
"commoncrypto"});
static std::vector< std::string > providers(std::string_view algo_spec)
virtual std::string provider() const
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
static std::unique_ptr< HashFunction > create(std::string_view algo_spec, std::string_view provider="")
std::string arg(size_t i) const
const std::string & algo_name() const
size_t arg_as_integer(size_t i, size_t def_value) const
std::unique_ptr< HashFunction > make_commoncrypto_hash(std::string_view name)