Create an instance based on a name, or return null if the algo/provider combination cannot be found. If provider is empty then best available is chosen.
104 {
105
106#if defined(BOTAN_HAS_COMMONCRYPTO)
108 {
111
113 return nullptr;
114 }
115#endif
116
118 return nullptr;
119
120#if defined(BOTAN_HAS_SHA1)
121 if(algo_spec == "SHA-160" ||
122 algo_spec == "SHA-1" ||
123 algo_spec == "SHA1")
124 {
125 return std::unique_ptr<HashFunction>(new SHA_160);
126 }
127#endif
128
129#if defined(BOTAN_HAS_SHA2_32)
130 if(algo_spec == "SHA-224")
131 {
132 return std::unique_ptr<HashFunction>(new SHA_224);
133 }
134
135 if(algo_spec == "SHA-256")
136 {
137 return std::unique_ptr<HashFunction>(new SHA_256);
138 }
139#endif
140
141#if defined(BOTAN_HAS_SHA2_64)
142 if(algo_spec == "SHA-384")
143 {
144 return std::unique_ptr<HashFunction>(new SHA_384);
145 }
146
147 if(algo_spec == "SHA-512")
148 {
149 return std::unique_ptr<HashFunction>(new SHA_512);
150 }
151
152 if(algo_spec == "SHA-512-256")
153 {
154 return std::unique_ptr<HashFunction>(new SHA_512_256);
155 }
156#endif
157
158#if defined(BOTAN_HAS_RIPEMD_160)
159 if(algo_spec == "RIPEMD-160")
160 {
161 return std::unique_ptr<HashFunction>(new RIPEMD_160);
162 }
163#endif
164
165#if defined(BOTAN_HAS_WHIRLPOOL)
166 if(algo_spec == "Whirlpool")
167 {
168 return std::unique_ptr<HashFunction>(new Whirlpool);
169 }
170#endif
171
172#if defined(BOTAN_HAS_MD5)
173 if(algo_spec == "MD5")
174 {
175 return std::unique_ptr<HashFunction>(new MD5);
176 }
177#endif
178
179#if defined(BOTAN_HAS_MD4)
180 if(algo_spec == "MD4")
181 {
182 return std::unique_ptr<HashFunction>(new MD4);
183 }
184#endif
185
186#if defined(BOTAN_HAS_GOST_34_11)
187 if(algo_spec == "GOST-R-34.11-94" || algo_spec == "GOST-34.11")
188 {
189 return std::unique_ptr<HashFunction>(new GOST_34_11);
190 }
191#endif
192
193#if defined(BOTAN_HAS_ADLER32)
194 if(algo_spec == "Adler32")
195 {
196 return std::unique_ptr<HashFunction>(new Adler32);
197 }
198#endif
199
200#if defined(BOTAN_HAS_CRC24)
201 if(algo_spec == "CRC24")
202 {
203 return std::unique_ptr<HashFunction>(new CRC24);
204 }
205#endif
206
207#if defined(BOTAN_HAS_CRC32)
208 if(algo_spec == "CRC32")
209 {
210 return std::unique_ptr<HashFunction>(new CRC32);
211 }
212#endif
213
214 const SCAN_Name req(algo_spec);
215
216#if defined(BOTAN_HAS_TIGER)
217 if(req.algo_name() == "Tiger")
218 {
219 return std::unique_ptr<HashFunction>(
220 new Tiger(req.arg_as_integer(0, 24),
221 req.arg_as_integer(1, 3)));
222 }
223#endif
224
225#if defined(BOTAN_HAS_SKEIN_512)
226 if(req.algo_name() == "Skein-512")
227 {
228 return std::unique_ptr<HashFunction>(
229 new Skein_512(req.arg_as_integer(0, 512), req.arg(1, "")));
230 }
231#endif
232
233#if defined(BOTAN_HAS_BLAKE2B)
234 if(req.algo_name() == "Blake2b" || req.algo_name() == "BLAKE2b")
235 {
236 return std::unique_ptr<HashFunction>(
237 new Blake2b(req.arg_as_integer(0, 512)));
238 }
239#endif
240
241#if defined(BOTAN_HAS_KECCAK)
242 if(req.algo_name() == "Keccak-1600")
243 {
244 return std::unique_ptr<HashFunction>(
245 new Keccak_1600(req.arg_as_integer(0, 512)));
246 }
247#endif
248
249#if defined(BOTAN_HAS_SHA3)
250 if(req.algo_name() == "SHA-3")
251 {
252 return std::unique_ptr<HashFunction>(
253 new SHA_3(req.arg_as_integer(0, 512)));
254 }
255#endif
256
257#if defined(BOTAN_HAS_SHAKE)
258 if(req.algo_name() == "SHAKE-128")
259 {
260 return std::unique_ptr<HashFunction>(new SHAKE_128(req.arg_as_integer(0, 128)));
261 }
262 if(req.algo_name() == "SHAKE-256")
263 {
264 return std::unique_ptr<HashFunction>(new SHAKE_256(req.arg_as_integer(0, 256)));
265 }
266#endif
267
268#if defined(BOTAN_HAS_STREEBOG)
269 if(algo_spec == "Streebog-256")
270 {
271 return std::unique_ptr<HashFunction>(new Streebog_256);
272 }
273 if(algo_spec == "Streebog-512")
274 {
275 return std::unique_ptr<HashFunction>(new Streebog_512);
276 }
277#endif
278
279#if defined(BOTAN_HAS_SM3)
280 if(algo_spec == "SM3")
281 {
282 return std::unique_ptr<HashFunction>(new SM3);
283 }
284#endif
285
286#if defined(BOTAN_HAS_WHIRLPOOL)
287 if(req.algo_name() == "Whirlpool")
288 {
289 return std::unique_ptr<HashFunction>(new Whirlpool);
290 }
291#endif
292
293#if defined(BOTAN_HAS_PARALLEL_HASH)
294 if(req.algo_name() == "Parallel")
295 {
296 std::vector<std::unique_ptr<HashFunction>> hashes;
297
298 for(size_t i = 0; i != req.arg_count(); ++i)
299 {
301 if(!h)
302 {
303 return nullptr;
304 }
305 hashes.push_back(std::move(h));
306 }
307
308 return std::unique_ptr<HashFunction>(new Parallel(hashes));
309 }
310#endif
311
312#if defined(BOTAN_HAS_COMB4P)
313 if(req.algo_name() == "Comb4P" && req.arg_count() == 2)
314 {
317
318 if(h1 && h2)
319 return std::unique_ptr<HashFunction>(new Comb4P(h1.release(), h2.release()));
320 }
321#endif
322
323
324 return nullptr;
325 }
virtual std::string provider() const
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
std::unique_ptr< HashFunction > make_commoncrypto_hash(const std::string &name)