Botan 2.19.2
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
14
15namespace Botan {
16
17/**
18* MDx Hash Function Base Class
19*/
21 {
22 public:
23 /**
24 * @param block_length is the number of bytes per block, which must
25 * be a power of 2 and at least 8.
26 * @param big_byte_endian specifies if the hash uses big-endian bytes
27 * @param big_bit_endian specifies if the hash uses big-endian bits
28 * @param counter_size specifies the size of the counter var in bytes
29 */
30 MDx_HashFunction(size_t block_length,
31 bool big_byte_endian,
32 bool big_bit_endian,
33 uint8_t counter_size = 8);
34
35 size_t hash_block_size() const override final { return m_buffer.size(); }
36 protected:
37 void add_data(const uint8_t input[], size_t length) override final;
38 void final_result(uint8_t output[]) override final;
39
40 /**
41 * Run the hash's compression function over a set of blocks
42 * @param blocks the input
43 * @param block_n the number of blocks
44 */
45 virtual void compress_n(const uint8_t blocks[], size_t block_n) = 0;
46
47 void clear() override;
48
49 /**
50 * Copy the output to the buffer
51 * @param buffer to put the output into
52 */
53 virtual void copy_out(uint8_t buffer[]) = 0;
54
55 /**
56 * Write the count, if used, to this spot
57 * @param out where to write the counter to
58 */
59 virtual void write_count(uint8_t out[]);
60 private:
61 const uint8_t m_pad_char;
62 const uint8_t m_counter_size;
63 const uint8_t m_block_bits;
64 const bool m_count_big_endian;
65
66 uint64_t m_count;
68 size_t m_position;
69 };
70
71}
72
73#endif
virtual void clear()=0
size_t hash_block_size() const override final
Definition: mdx_hash.h:35
virtual void compress_n(const uint8_t blocks[], size_t block_n)=0
virtual void copy_out(uint8_t buffer[])=0
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65