Botan  1.10.9
comb4p.h
Go to the documentation of this file.
1 /*
2 * Comb4P hash combiner
3 * (C) 2010 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_COMB4P_H__
9 #define BOTAN_COMB4P_H__
10 
11 #include <botan/hash.h>
12 
13 namespace Botan {
14 
15 /**
16 * Combines two hash functions using a Feistel scheme. Described in
17 * "On the Security of Hash Function Combiners", Anja Lehmann
18 */
19 class BOTAN_DLL Comb4P : public HashFunction
20  {
21  public:
22  /**
23  * @param h1 the first hash
24  * @param h2 the second hash
25  */
27 
28  ~Comb4P() { delete hash1; delete hash2; }
29 
30  size_t hash_block_size() const;
31 
32  size_t output_length() const
33  {
34  return hash1->output_length() + hash2->output_length();
35  }
36 
38  {
39  return new Comb4P(hash1->clone(), hash2->clone());
40  }
41 
42  std::string name() const
43  {
44  return "Comb4P(" + hash1->name() + "," + hash2->name() + ")";
45  }
46 
47  void clear();
48  private:
49  void add_data(const byte input[], size_t length);
50  void final_result(byte out[]);
51 
52  HashFunction* hash1;
53  HashFunction* hash2;
54  };
55 
56 }
57 
58 #endif
HashFunction * clone() const
Definition: comb4p.h:37
size_t output_length() const
Definition: comb4p.h:32
std::string name() const
Definition: comb4p.h:42
unsigned char byte
Definition: types.h:22