Coverage Report

Created: 2023-06-07 07:00

/src/botan/build/include/botan/internal/mdx_hash.h
Line
Count
Source
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
*/
18
class MDx_HashFunction : public HashFunction {
19
   public:
20
      /**
21
      * @param block_length is the number of bytes per block, which must
22
      *        be a power of 2 and at least 8.
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, bool big_byte_endian, bool big_bit_endian, uint8_t counter_size = 8);
28
29
1
      size_t hash_block_size() const override final { return m_buffer.size(); }
30
31
   protected:
32
      void add_data(const uint8_t input[], size_t length) override final;
33
      void final_result(uint8_t output[]) override final;
34
35
      /**
36
      * Run the hash's compression function over a set of blocks
37
      * @param blocks the input
38
      * @param block_n the number of blocks
39
      */
40
      virtual void compress_n(const uint8_t blocks[], size_t block_n) = 0;
41
42
      void clear() override;
43
44
      /**
45
      * Copy the output to the buffer
46
      * @param buffer to put the output into
47
      */
48
      virtual void copy_out(uint8_t buffer[]) = 0;
49
50
   private:
51
      const uint8_t m_pad_char;
52
      const uint8_t m_counter_size;
53
      const uint8_t m_block_bits;
54
      const bool m_count_big_endian;
55
56
      uint64_t m_count;
57
      secure_vector<uint8_t> m_buffer;
58
      size_t m_position;
59
};
60
61
}  // namespace Botan
62
63
#endif