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),
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_insert(buffer, 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);