9#include <botan/scan_name.h>
10#include <botan/exceptn.h>
12#if defined(BOTAN_HAS_ADLER32)
13 #include <botan/adler32.h>
16#if defined(BOTAN_HAS_CRC24)
17 #include <botan/crc24.h>
20#if defined(BOTAN_HAS_CRC32)
21 #include <botan/crc32.h>
24#if defined(BOTAN_HAS_GOST_34_11)
25 #include <botan/gost_3411.h>
28#if defined(BOTAN_HAS_KECCAK)
29 #include <botan/keccak.h>
32#if defined(BOTAN_HAS_MD4)
33 #include <botan/md4.h>
36#if defined(BOTAN_HAS_MD5)
37 #include <botan/md5.h>
40#if defined(BOTAN_HAS_RIPEMD_160)
41 #include <botan/rmd160.h>
44#if defined(BOTAN_HAS_SHA1)
45 #include <botan/sha160.h>
48#if defined(BOTAN_HAS_SHA2_32)
49 #include <botan/sha2_32.h>
52#if defined(BOTAN_HAS_SHA2_64)
53 #include <botan/sha2_64.h>
56#if defined(BOTAN_HAS_SHA3)
57 #include <botan/sha3.h>
60#if defined(BOTAN_HAS_SHAKE)
61 #include <botan/shake.h>
64#if defined(BOTAN_HAS_SKEIN_512)
65 #include <botan/skein_512.h>
68#if defined(BOTAN_HAS_STREEBOG)
69 #include <botan/streebog.h>
72#if defined(BOTAN_HAS_SM3)
73 #include <botan/sm3.h>
76#if defined(BOTAN_HAS_TIGER)
77 #include <botan/tiger.h>
80#if defined(BOTAN_HAS_WHIRLPOOL)
81 #include <botan/whrlpool.h>
84#if defined(BOTAN_HAS_PARALLEL_HASH)
85 #include <botan/par_hash.h>
88#if defined(BOTAN_HAS_COMB4P)
89 #include <botan/comb4p.h>
92#if defined(BOTAN_HAS_BLAKE2B)
93 #include <botan/blake2b.h>
96#if defined(BOTAN_HAS_COMMONCRYPTO)
97 #include <botan/internal/commoncrypto.h>
103 const std::string& provider)
106#if defined(BOTAN_HAS_COMMONCRYPTO)
120#if defined(BOTAN_HAS_SHA1)
121 if(algo_spec ==
"SHA-160" ||
122 algo_spec ==
"SHA-1" ||
125 return std::unique_ptr<HashFunction>(
new SHA_160);
129#if defined(BOTAN_HAS_SHA2_32)
130 if(algo_spec ==
"SHA-224")
132 return std::unique_ptr<HashFunction>(
new SHA_224);
135 if(algo_spec ==
"SHA-256")
137 return std::unique_ptr<HashFunction>(
new SHA_256);
141#if defined(BOTAN_HAS_SHA2_64)
142 if(algo_spec ==
"SHA-384")
144 return std::unique_ptr<HashFunction>(
new SHA_384);
147 if(algo_spec ==
"SHA-512")
149 return std::unique_ptr<HashFunction>(
new SHA_512);
152 if(algo_spec ==
"SHA-512-256")
154 return std::unique_ptr<HashFunction>(
new SHA_512_256);
158#if defined(BOTAN_HAS_RIPEMD_160)
159 if(algo_spec ==
"RIPEMD-160")
161 return std::unique_ptr<HashFunction>(
new RIPEMD_160);
165#if defined(BOTAN_HAS_WHIRLPOOL)
166 if(algo_spec ==
"Whirlpool")
168 return std::unique_ptr<HashFunction>(
new Whirlpool);
172#if defined(BOTAN_HAS_MD5)
173 if(algo_spec ==
"MD5")
175 return std::unique_ptr<HashFunction>(
new MD5);
179#if defined(BOTAN_HAS_MD4)
180 if(algo_spec ==
"MD4")
182 return std::unique_ptr<HashFunction>(
new MD4);
186#if defined(BOTAN_HAS_GOST_34_11)
187 if(algo_spec ==
"GOST-R-34.11-94" || algo_spec ==
"GOST-34.11")
189 return std::unique_ptr<HashFunction>(
new GOST_34_11);
193#if defined(BOTAN_HAS_ADLER32)
194 if(algo_spec ==
"Adler32")
196 return std::unique_ptr<HashFunction>(
new Adler32);
200#if defined(BOTAN_HAS_CRC24)
201 if(algo_spec ==
"CRC24")
203 return std::unique_ptr<HashFunction>(
new CRC24);
207#if defined(BOTAN_HAS_CRC32)
208 if(algo_spec ==
"CRC32")
210 return std::unique_ptr<HashFunction>(
new CRC32);
216#if defined(BOTAN_HAS_TIGER)
219 return std::unique_ptr<HashFunction>(
225#if defined(BOTAN_HAS_SKEIN_512)
228 return std::unique_ptr<HashFunction>(
233#if defined(BOTAN_HAS_BLAKE2B)
236 return std::unique_ptr<HashFunction>(
241#if defined(BOTAN_HAS_KECCAK)
244 return std::unique_ptr<HashFunction>(
249#if defined(BOTAN_HAS_SHA3)
252 return std::unique_ptr<HashFunction>(
257#if defined(BOTAN_HAS_SHAKE)
268#if defined(BOTAN_HAS_STREEBOG)
269 if(algo_spec ==
"Streebog-256")
273 if(algo_spec ==
"Streebog-512")
279#if defined(BOTAN_HAS_SM3)
280 if(algo_spec ==
"SM3")
282 return std::unique_ptr<HashFunction>(
new SM3);
286#if defined(BOTAN_HAS_WHIRLPOOL)
289 return std::unique_ptr<HashFunction>(
new Whirlpool);
293#if defined(BOTAN_HAS_PARALLEL_HASH)
296 std::vector<std::unique_ptr<HashFunction>> hashes;
298 for(
size_t i = 0; i != req.
arg_count(); ++i)
305 hashes.push_back(std::move(h));
308 return std::unique_ptr<HashFunction>(
new Parallel(hashes));
312#if defined(BOTAN_HAS_COMB4P)
319 return std::unique_ptr<HashFunction>(
new Comb4P(h1.release(), h2.release()));
328std::unique_ptr<HashFunction>
330 const std::string& provider)
341 return probe_providers_of<HashFunction>(algo_spec, {
"base",
"openssl",
"commoncrypto"});
static std::vector< std::string > providers(const std::string &algo_spec)
virtual std::string provider() const
static std::unique_ptr< HashFunction > create_or_throw(const std::string &algo_spec, const std::string &provider="")
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &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(const std::string &name)