Botan
1.11.15
|
00001 /* 00002 * Comb4P hash combiner 00003 * (C) 2010 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #ifndef BOTAN_COMB4P_H__ 00009 #define BOTAN_COMB4P_H__ 00010 00011 #include <botan/hash.h> 00012 00013 namespace Botan { 00014 00015 /** 00016 * Combines two hash functions using a Feistel scheme. Described in 00017 * "On the Security of Hash Function Combiners", Anja Lehmann 00018 */ 00019 class BOTAN_DLL Comb4P : public HashFunction 00020 { 00021 public: 00022 /** 00023 * @param h1 the first hash 00024 * @param h2 the second hash 00025 */ 00026 Comb4P(HashFunction* h1, HashFunction* h2); 00027 00028 size_t hash_block_size() const; 00029 00030 size_t output_length() const 00031 { 00032 return m_hash1->output_length() + m_hash2->output_length(); 00033 } 00034 00035 static Comb4P* make(const Spec& spec); 00036 00037 HashFunction* clone() const 00038 { 00039 return new Comb4P(m_hash1->clone(), m_hash2->clone()); 00040 } 00041 00042 std::string name() const 00043 { 00044 return "Comb4P(" + m_hash1->name() + "," + m_hash2->name() + ")"; 00045 } 00046 00047 void clear(); 00048 private: 00049 void add_data(const byte input[], size_t length); 00050 void final_result(byte out[]); 00051 00052 std::unique_ptr<HashFunction> m_hash1, m_hash2; 00053 }; 00054 00055 } 00056 00057 #endif