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