Botan 3.0.0-alpha0
Crypto and TLS for C&
mdx_hash.h
Go to the documentation of this file.
1/*
2* MDx Hash Function
3* (C) 1999-2008 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_MDX_BASE_H_
9#define BOTAN_MDX_BASE_H_
10
11#include <botan/hash.h>
12
13namespace Botan {
14
15/**
16* MDx Hash Function Base Class
17*/
19 {
20 public:
21 /**
22 * @param block_length is the number of bytes per block, which must
23 * be a power of 2 and at least 8.
24 * @param big_byte_endian specifies if the hash uses big-endian bytes
25 * @param big_bit_endian specifies if the hash uses big-endian bits
26 * @param counter_size specifies the size of the counter var in bytes
27 */
28 MDx_HashFunction(size_t block_length,
29 bool big_byte_endian,
30 bool big_bit_endian,
31 uint8_t counter_size = 8);
32
33 size_t hash_block_size() const override final { return m_buffer.size(); }
34 protected:
35 void add_data(const uint8_t input[], size_t length) override final;
36 void final_result(uint8_t output[]) override final;
37
38 /**
39 * Run the hash's compression function over a set of blocks
40 * @param blocks the input
41 * @param block_n the number of blocks
42 */
43 virtual void compress_n(const uint8_t blocks[], size_t block_n) = 0;
44
45 void clear() override;
46
47 /**
48 * Copy the output to the buffer
49 * @param buffer to put the output into
50 */
51 virtual void copy_out(uint8_t buffer[]) = 0;
52 private:
53 const uint8_t m_pad_char;
54 const uint8_t m_counter_size;
55 const uint8_t m_block_bits;
56 const bool m_count_big_endian;
57
58 uint64_t m_count;
60 size_t m_position;
61 };
62
63}
64
65#endif
secure_vector< uint8_t > final()
Definition: buf_comp.h:90
void final_result(uint8_t output[]) override final
Definition: mdx_hash.cpp:85
size_t hash_block_size() const override final
Definition: mdx_hash.h:33
void clear() override
Definition: mdx_hash.cpp:41
virtual void compress_n(const uint8_t blocks[], size_t block_n)=0
MDx_HashFunction(size_t block_length, bool big_byte_endian, bool big_bit_endian, uint8_t counter_size=8)
Definition: mdx_hash.cpp:18
void add_data(const uint8_t input[], size_t length) override final
Definition: mdx_hash.cpp:50
virtual void copy_out(uint8_t buffer[])=0
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65