Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

hash.h
Go to the documentation of this file.
1 /*
2 * Hash Function Base Class
3 * (C) 1999-2008 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_HASH_FUNCTION_BASE_CLASS_H__
9 #define BOTAN_HASH_FUNCTION_BASE_CLASS_H__
10
11 #include <botan/buf_comp.h>
12 #include <string>
13
14 namespace Botan {
15
16 /**
17 * This class represents hash function (message digest) objects
18 */
19 class BOTAN_DLL HashFunction : public Buffered_Computation
20 {
21 public:
22 /**
23 * Create an instance based on a name, or return null if the
24 * algo/provider combination cannot be found. If provider is
25 * empty then best available is chosen.
26 */
27 static std::unique_ptr<HashFunction>
28 create(const std::string& algo_spec,
29 const std::string& provider = "");
30
31 /**
32 * Create an instance based on a name
33 * If provider is empty then best available is chosen.
34 * @param algo_spec algorithm name
35 * @param provider provider implementation to use
36 * Throws Lookup_Error if not not found.
37 */
38 static std::unique_ptr<HashFunction>
39 create_or_throw(const std::string& algo_spec,
40 const std::string& provider = "");
41
42 /**
43 * @return list of available providers for this algorithm, empty if not available
44 * @param algo_spec algorithm name
45 */
46 static std::vector<std::string> providers(const std::string& algo_spec);
47
48 /**
49 * @return new object representing the same algorithm as *this
50 */
51 virtual HashFunction* clone() const = 0;
52
53 /**
54 * @return provider information about this implementation. Default is "base",
55 * might also return "sse2", "avx2", "openssl", or some other arbitrary string.
56 */
57 virtual std::string provider() const { return "base"; }
58
59 virtual ~HashFunction() = default;
60
61 /**
62 * Reset the state.
63 */
64 virtual void clear() = 0;
65
66 /**
67 * @return the hash function name
68 */
69 virtual std::string name() const = 0;
70
71 /**
72 * @return hash block size as defined for this algorithm
73 */
74 virtual size_t hash_block_size() const { return 0; }
75 };
76
77 }
78
79 #endif
Botan::Buffered_Computation
Definition: buf_comp.h:21
Botan::HashFunction::provider
virtual std::string provider() const
Definition: hash.h:57
Botan
Definition: alg_id.cpp:13
Botan::HashFunction::hash_block_size
virtual size_t hash_block_size() const
Definition: hash.h:74
Botan::HashFunction
Definition: hash.h:19