Botan 3.3.0
Crypto and TLS for C&
comb4p.h
Go to the documentation of this file.
1/*
2* Comb4P hash combiner
3* (C) 2010 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_COMB4P_H_
9#define BOTAN_COMB4P_H_
10
11#include <botan/hash.h>
12
13namespace 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*/
19class Comb4P final : public HashFunction {
20 public:
21 /**
22 * @param h1 the first hash
23 * @param h2 the second hash
24 */
25 Comb4P(std::unique_ptr<HashFunction> h1, std::unique_ptr<HashFunction> h2);
26
27 size_t hash_block_size() const override;
28
29 size_t output_length() const override { return m_hash1->output_length() + m_hash2->output_length(); }
30
31 std::unique_ptr<HashFunction> new_object() const override;
32
33 std::unique_ptr<HashFunction> copy_state() const override;
34
35 std::string name() const override;
36
37 void clear() override;
38
39 private:
40 Comb4P() = default;
41
42 void add_data(std::span<const uint8_t> input) override;
43 void final_result(std::span<uint8_t> out) override;
44
45 std::unique_ptr<HashFunction> m_hash1, m_hash2;
46};
47
48} // namespace Botan
49
50#endif
void clear() override
Definition comb4p.cpp:71
std::unique_ptr< HashFunction > new_object() const override
Definition comb4p.cpp:55
size_t output_length() const override
Definition comb4p.h:29
std::unique_ptr< HashFunction > copy_state() const override
Definition comb4p.cpp:80
std::string name() const override
Definition comb4p.cpp:51
size_t hash_block_size() const override
Definition comb4p.cpp:59
int(* final)(unsigned char *, CTX *)