Botan  2.7.0
Crypto and TLS for C++11
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 
13 namespace 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
23  * @param big_byte_endian specifies if the hash uses big-endian bytes
24  * @param big_bit_endian specifies if the hash uses big-endian bits
25  * @param counter_size specifies the size of the counter var in bytes
26  */
27  MDx_HashFunction(size_t block_length,
28  bool big_byte_endian,
29  bool big_bit_endian,
30  size_t counter_size = 8);
31 
32  size_t hash_block_size() const override final { return m_buffer.size(); }
33  protected:
34  void add_data(const uint8_t input[], size_t length) override final;
35  void final_result(uint8_t output[]) override final;
36 
37  /**
38  * Run the hash's compression function over a set of blocks
39  * @param blocks the input
40  * @param block_n the number of blocks
41  */
42  virtual void compress_n(const uint8_t blocks[], size_t block_n) = 0;
43 
44  void clear() override;
45 
46  /**
47  * Copy the output to the buffer
48  * @param buffer to put the output into
49  */
50  virtual void copy_out(uint8_t buffer[]) = 0;
51 
52  /**
53  * Write the count, if used, to this spot
54  * @param out where to write the counter to
55  */
56  virtual void write_count(uint8_t out[]);
57  private:
58  secure_vector<uint8_t> m_buffer;
59  uint64_t m_count;
60  size_t m_position;
61 
62  const bool BIG_BYTE_ENDIAN, BIG_BIT_ENDIAN;
63  const size_t COUNT_SIZE;
64  };
65 
66 }
67 
68 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
size_t hash_block_size() const override final
Definition: mdx_hash.h:32
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88