8#include <botan/comb4p.h>
9#include <botan/internal/xor_buf.h>
25 h1->update(&in[0], in.size());
26 h2->update(&in[0], in.size());
29 xor_buf(&out[0], &h_buf[0], std::min(out.size(), h_buf.size()));
32 xor_buf(&out[0], &h_buf[0], std::min(out.size(), h_buf.size()));
40 if(hash1->name() == hash2->name())
41 throw std::invalid_argument(
"Comb4P: Must use two distinct hashes");
43 if(hash1->output_length() != hash2->output_length())
44 throw std::invalid_argument(
"Comb4P: Incompatible hashes " +
45 hash1->name() +
" and " +
53 if(hash1->hash_block_size() == hash2->hash_block_size())
54 return hash1->hash_block_size();
73void Comb4P::add_data(
const byte input[],
size_t length)
75 hash1->
update(input, length);
76 hash2->
update(input, length);
79void Comb4P::final_result(
byte out[])
81 SecureVector<byte> h1 = hash1->
final();
82 SecureVector<byte> h2 = hash2->
final();
85 xor_buf(&h1[0], &h2[0], std::min(h1.size(), h2.size()));
88 comb4p_round(h2, h1, 1, hash1, hash2);
91 comb4p_round(h1, h2, 2, hash1, hash2);
94 copy_mem(out + h1.size(), &h2[0], h2.size());
void update(const byte in[], size_t length)
size_t hash_block_size() const
Comb4P(HashFunction *h1, HashFunction *h2)
void xor_buf(byte out[], const byte in[], size_t length)
void copy_mem(T *out, const T *in, size_t n)