Botan: src/hash/mdx_hash/mdx_hash.h Source File

Botan 1.10.16

mdx_hash.h
Go to the documentation of this file.
1 /*
2 * MDx Hash Function
3 * (C) 1999-2008 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
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 BOTAN_DLL MDx_HashFunction : public HashFunction
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 { return buffer.size(); }
33 protected:
34 void add_data(const byte input[], size_t length);
35 void final_result(byte output[]);
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 byte blocks[], size_t block_n) = 0;
43
44 void clear();
45
46 /**
47 * Copy the output to the buffer
48 * @param buffer to put the output into
49 */
50 virtual void copy_out(byte 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(byte out[]);
57 private:
58 SecureVector<byte> buffer;
59 u64bit count;
60 size_t position;
61
62 const bool BIG_BYTE_ENDIAN, BIG_BIT_ENDIAN;
63 const size_t COUNT_SIZE;
64 };
65
66 }
67
68 #endif
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::u64bit
unsigned long long u64bit
Definition: types.h:49
Botan::MDx_HashFunction
Definition: mdx_hash.h:18
Botan
Definition: algo_base.h:14
Botan::HashFunction
Definition: hash.h:20
Botan::MDx_HashFunction::hash_block_size
size_t hash_block_size() const
Definition: mdx_hash.h:32
Botan::SecureVector< byte >