8 #include <botan/hash.h>
9 #include <botan/scan_name.h>
11 #if defined(BOTAN_HAS_ADLER32)
12 #include <botan/adler32.h>
15 #if defined(BOTAN_HAS_CRC24)
16 #include <botan/crc24.h>
19 #if defined(BOTAN_HAS_CRC32)
20 #include <botan/crc32.h>
23 #if defined(BOTAN_HAS_GOST_34_11)
24 #include <botan/gost_3411.h>
27 #if defined(BOTAN_HAS_KECCAK)
28 #include <botan/keccak.h>
31 #if defined(BOTAN_HAS_MD4)
32 #include <botan/md4.h>
35 #if defined(BOTAN_HAS_MD5)
36 #include <botan/md5.h>
39 #if defined(BOTAN_HAS_RIPEMD_160)
40 #include <botan/rmd160.h>
43 #if defined(BOTAN_HAS_SHA1)
44 #include <botan/sha160.h>
47 #if defined(BOTAN_HAS_SHA2_32)
48 #include <botan/sha2_32.h>
51 #if defined(BOTAN_HAS_SHA2_64)
52 #include <botan/sha2_64.h>
55 #if defined(BOTAN_HAS_SHA3)
56 #include <botan/sha3.h>
59 #if defined(BOTAN_HAS_SHAKE)
60 #include <botan/shake.h>
63 #if defined(BOTAN_HAS_SKEIN_512)
64 #include <botan/skein_512.h>
67 #if defined(BOTAN_HAS_TIGER)
68 #include <botan/tiger.h>
71 #if defined(BOTAN_HAS_WHIRLPOOL)
72 #include <botan/whrlpool.h>
75 #if defined(BOTAN_HAS_PARALLEL_HASH)
76 #include <botan/par_hash.h>
79 #if defined(BOTAN_HAS_COMB4P)
80 #include <botan/comb4p.h>
83 #if defined(BOTAN_HAS_BLAKE2B)
84 #include <botan/blake2b.h>
87 #if defined(BOTAN_HAS_OPENSSL)
88 #include <botan/internal/openssl.h>
94 const std::string& provider)
96 #if defined(BOTAN_HAS_OPENSSL)
97 if(provider.empty() || provider ==
"openssl")
102 if(!provider.empty())
109 if(provider.empty() ==
false && provider !=
"base")
112 #if defined(BOTAN_HAS_SHA1)
113 if(algo_spec ==
"SHA-160" ||
114 algo_spec ==
"SHA-1" ||
117 return std::unique_ptr<HashFunction>(
new SHA_160);
121 #if defined(BOTAN_HAS_SHA2_32)
122 if(algo_spec ==
"SHA-224")
124 return std::unique_ptr<HashFunction>(
new SHA_224);
127 if(algo_spec ==
"SHA-256")
129 return std::unique_ptr<HashFunction>(
new SHA_256);
133 #if defined(BOTAN_HAS_SHA2_64)
134 if(algo_spec ==
"SHA-384")
136 return std::unique_ptr<HashFunction>(
new SHA_384);
139 if(algo_spec ==
"SHA-512")
141 return std::unique_ptr<HashFunction>(
new SHA_512);
144 if(algo_spec ==
"SHA-512-256")
146 return std::unique_ptr<HashFunction>(
new SHA_512_256);
150 #if defined(BOTAN_HAS_RIPEMD_160)
151 if(algo_spec ==
"RIPEMD-160")
153 return std::unique_ptr<HashFunction>(
new RIPEMD_160);
157 #if defined(BOTAN_HAS_WHIRLPOOL)
158 if(algo_spec ==
"Whirlpool")
160 return std::unique_ptr<HashFunction>(
new Whirlpool);
164 #if defined(BOTAN_HAS_MD5)
165 if(algo_spec ==
"MD5")
167 return std::unique_ptr<HashFunction>(
new MD5);
171 #if defined(BOTAN_HAS_MD4)
172 if(algo_spec ==
"MD4")
174 return std::unique_ptr<HashFunction>(
new MD4);
178 #if defined(BOTAN_HAS_GOST_34_11)
179 if(algo_spec ==
"GOST-R-34.11-94" || algo_spec ==
"GOST-34.11")
181 return std::unique_ptr<HashFunction>(
new GOST_34_11);
185 #if defined(BOTAN_HAS_ADLER32)
186 if(algo_spec ==
"Adler32")
188 return std::unique_ptr<HashFunction>(
new Adler32);
192 #if defined(BOTAN_HAS_CRC24)
193 if(algo_spec ==
"CRC24")
195 return std::unique_ptr<HashFunction>(
new CRC24);
199 #if defined(BOTAN_HAS_CRC32)
200 if(algo_spec ==
"CRC32")
202 return std::unique_ptr<HashFunction>(
new CRC32);
208 #if defined(BOTAN_HAS_TIGER)
211 return std::unique_ptr<HashFunction>(
217 #if defined(BOTAN_HAS_SKEIN_512)
220 return std::unique_ptr<HashFunction>(
225 #if defined(BOTAN_HAS_BLAKE2B)
228 return std::unique_ptr<HashFunction>(
233 #if defined(BOTAN_HAS_KECCAK)
236 return std::unique_ptr<HashFunction>(
241 #if defined(BOTAN_HAS_SHA3)
244 return std::unique_ptr<HashFunction>(
249 #if defined(BOTAN_HAS_SHAKE)
260 #if defined(BOTAN_HAS_WHIRLPOOL)
263 return std::unique_ptr<HashFunction>(
new Whirlpool);
267 #if defined(BOTAN_HAS_PARALLEL_HASH)
270 std::vector<std::unique_ptr<HashFunction>> hashes;
272 for(
size_t i = 0; i != req.
arg_count(); ++i)
279 hashes.push_back(std::move(h));
282 return std::unique_ptr<HashFunction>(
new Parallel(hashes));
286 #if defined(BOTAN_HAS_COMB4P)
293 return std::unique_ptr<HashFunction>(
new Comb4P(h1.release(), h2.release()));
302 std::unique_ptr<HashFunction>
304 const std::string& provider)
315 return probe_providers_of<HashFunction>(algo_spec, {
"base",
"openssl"});
std::string arg(size_t i) const
static std::unique_ptr< HashFunction > create_or_throw(const std::string &algo_spec, const std::string &provider="")
std::unique_ptr< HashFunction > make_openssl_hash(const std::string &name)
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
size_t arg_as_integer(size_t i, size_t def_value) const
static std::vector< std::string > providers(const std::string &algo_spec)
const std::string & algo_name() const