summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2015-10-12 22:35:46 +0000
committerbrian m. carlson <sandals@crustytoothpaste.net>2015-10-12 22:35:46 +0000
commitf645df29b1a5b6c70f52a922eddb2646cc6f6988 (patch)
treee37e3848c8793696b61acefb30022318718df7d0
parent47b6d712a3e023fdcbcaae46ee4d1949fe00c307 (diff)
hash: move buffer size handling into classes.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
-rw-r--r--impl/hash/grøstl/grøstl.hh4
-rw-r--r--impl/hash/hash-plugin.hh9
-rw-r--r--impl/hash/hash.hh8
3 files changed, 20 insertions, 1 deletions
diff --git a/impl/hash/grøstl/grøstl.hh b/impl/hash/grøstl/grøstl.hh
index 491a986..0b3523b 100644
--- a/impl/hash/grøstl/grøstl.hh
+++ b/impl/hash/grøstl/grøstl.hh
@@ -226,6 +226,10 @@ class Gr\u00f8stlHash
{
drew::Gr\u00f8stl512::Transform(state, data);
}
+ static bool HasVariableBufferSize()
+ {
+ return true;
+ }
protected:
private:
Gr\u00f8stlImplementation *m_impl;
diff --git a/impl/hash/hash-plugin.hh b/impl/hash/hash-plugin.hh
index c15e7dd..77975c0 100644
--- a/impl/hash/hash-plugin.hh
+++ b/impl/hash/hash-plugin.hh
@@ -48,7 +48,14 @@ static int prefix ## info(int op, void *p) \
case DREW_HASH_BLKSIZE: \
return hname::block_size; \
case DREW_HASH_BUFSIZE: \
- return hname::buffer_size; \
+ if (ctx && ctx->ctx) { \
+ const hname *s = (const hname *)ctx->ctx; \
+ return s->GetBufferSize(); \
+ } \
+ else if (hname::HasVariableBufferSize()) \
+ return -DREW_ERR_MORE_INFO; \
+ else \
+ return hname::GetBufferSize(); \
case DREW_HASH_INTSIZE: \
return sizeof(hname); \
case DREW_HASH_ENDIAN: \
diff --git a/impl/hash/hash.hh b/impl/hash/hash.hh
index 97129c3..687349d 100644
--- a/impl/hash/hash.hh
+++ b/impl/hash/hash.hh
@@ -129,6 +129,14 @@ class Hash
{
return Size;
}
+ static bool HasVariableBufferSize()
+ {
+ return false;
+ }
+ static size_t GetBufferSize()
+ {
+ return BufSize;
+ }
static inline void Transform(T *, const uint8_t *data);
protected:
virtual void Transform(const uint8_t *data) = 0;