aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/hash/mdx_hash/mdx_hash.h
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-12-08 06:58:34 -0500
committerJack Lloyd <[email protected]>2018-12-08 07:01:11 -0500
commit2d2488701e197b04f1ffc0275c13c672b550991f (patch)
treec0eb9e037acf33e322dd8cc0e692db92a7ca0842 /src/lib/hash/mdx_hash/mdx_hash.h
parent0c2da7d179bd029a6abaafb6f9b54bf5b079df52 (diff)
Require MDx_HashFunction block size to be a power of 2
Allows replacing div/mod by a variable with a shift/mask. Allows storing just the bit count, which saves a few bytes.
Diffstat (limited to 'src/lib/hash/mdx_hash/mdx_hash.h')
-rw-r--r--src/lib/hash/mdx_hash/mdx_hash.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/hash/mdx_hash/mdx_hash.h b/src/lib/hash/mdx_hash/mdx_hash.h
index bd2752bef..b18c2e270 100644
--- a/src/lib/hash/mdx_hash/mdx_hash.h
+++ b/src/lib/hash/mdx_hash/mdx_hash.h
@@ -19,7 +19,8 @@ class BOTAN_PUBLIC_API(2,0) MDx_HashFunction : public HashFunction
{
public:
/**
- * @param block_length is the number of bytes per block
+ * @param block_length is the number of bytes per block, which must
+ * be a power of 2 and at least 8.
* @param big_byte_endian specifies if the hash uses big-endian bytes
* @param big_bit_endian specifies if the hash uses big-endian bits
* @param counter_size specifies the size of the counter var in bytes
@@ -57,8 +58,8 @@ class BOTAN_PUBLIC_API(2,0) MDx_HashFunction : public HashFunction
private:
const uint8_t m_pad_char;
const uint8_t m_counter_size;
+ const uint8_t m_block_bits;
const bool m_count_big_endian;
- const size_t m_block_len;
uint64_t m_count;
secure_vector<uint8_t> m_buffer;