8 #include <botan/mdx_hash.h>
9 #include <botan/exceptn.h>
10 #include <botan/loadstor.h>
22 BIG_BYTE_ENDIAN(byte_end),
23 BIG_BIT_ENDIAN(bit_end),
47 buffer.
copy(position, input, length);
49 if(position + length >= buffer.
size())
52 input += (buffer.
size() - position);
53 length -= (buffer.
size() - position);
58 const size_t full_blocks = length / buffer.
size();
59 const size_t remaining = length % buffer.
size();
64 buffer.
copy(position, input + full_blocks * buffer.
size(), remaining);
65 position += remaining;
73 buffer[position] = (BIG_BIT_ENDIAN ? 0x80 : 0x01);
74 for(
size_t i = position+1; i != buffer.
size(); ++i)
77 if(position >= buffer.
size() - COUNT_SIZE)
96 throw Invalid_State(
"MDx_HashFunction::write_count: COUNT_SIZE < 8");
100 const u64bit bit_count = count * 8;
103 store_be(bit_count, out + COUNT_SIZE - 8);
105 store_le(bit_count, out + COUNT_SIZE - 8);
void add_data(const byte input[], size_t length)
size_t hash_block_size() const
virtual void compress_n(const byte blocks[], size_t block_n)=0
void store_le(u16bit in, byte out[2])
void final_result(byte output[])
std::invalid_argument Invalid_Argument
virtual void write_count(byte out[])
void copy(const T in[], size_t n)
unsigned long long u64bit
void store_be(u16bit in, byte out[2])
void zeroise(MemoryRegion< T > &vec)
virtual size_t output_length() const =0
MDx_HashFunction(size_t block_length, bool big_byte_endian, bool big_bit_endian, size_t counter_size=8)
virtual void copy_out(byte buffer[])=0