summaryrefslogtreecommitdiff
path: root/iterhash.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2016-09-13 20:44:14 -0400
committerJeffrey Walton <noloader@gmail.com>2016-09-13 20:44:14 -0400
commitff67abdec52b6412842c05dded4c3e2ba203d817 (patch)
treec20ef57ef1e1932f87d636aa68561aee560fbb01 /iterhash.h
parentdf7e07e75e302f34d8968f65ab8126333b006ae5 (diff)
downloadcryptopp-git-ff67abdec52b6412842c05dded4c3e2ba203d817.tar.gz
Add virtual dtor for IteratedHash and ClonableImpl due to non-trivial data members
Solaris is showing unusual signs with SunCC 5.13 and 5.14. One user is experiencing a SIGBUS in SHA512::Transform due to data alignment of 'data', which was only 2-byte aligned. The project experienced an exception "Coneable not implemented" during the hashing test after building with Cmake. Its not clear how much Cmake influenced the project's results.
Diffstat (limited to 'iterhash.h')
-rw-r--r--iterhash.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/iterhash.h b/iterhash.h
index 0757687f..43d58d90 100644
--- a/iterhash.h
+++ b/iterhash.h
@@ -21,7 +21,7 @@ public:
//! \brief Iterated hash base class
//! \tparam T Hash word type
//! \tparam BASE HashTransformation derived class
-//! \details BASE should be derived from HashTransformation, MessageAuthenticationCode, or similar class.
+//! \details IteratedHashBase provides an interface for block-based iterated hashes
//! \sa HashTransformation, MessageAuthenticationCode
template <class T, class BASE>
class CRYPTOPP_NO_VTABLE IteratedHashBase : public BASE
@@ -49,7 +49,7 @@ public:
//! \param length the size of the buffer, in bytes
void Update(const byte *input, size_t length);
- //! \brief Request space which can be written into by the caller
+ //! \brief Requests space which can be written into by the caller
//! \param size the requested size of the buffer
//! \details The purpose of this method is to help avoid extra memory allocations.
//! \details size is an \a IN and \a OUT parameter and used as a hint. When the call is made,
@@ -95,7 +95,7 @@ private:
//! \tparam T_Endianness Endianness type of hash
//! \tparam T_BlockSize Block size of the hash
//! \tparam T_Base HashTransformation derived class
-//! \details T_Base should be derived from HashTransformation, MessageAuthenticationCode, or similar class.
+//! \details IteratedHash provides a default implementation for block-based iterated hashes
//! \sa HashTransformation, MessageAuthenticationCode
template <class T_HashWordType, class T_Endianness, unsigned int T_BlockSize, class T_Base = HashTransformation>
class CRYPTOPP_NO_VTABLE IteratedHash : public IteratedHashBase<T_HashWordType, T_Base>
@@ -104,6 +104,10 @@ public:
typedef T_Endianness ByteOrderClass;
typedef T_HashWordType HashWordType;
+#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
+ virtual ~IteratedHash() { }
+#endif
+
CRYPTOPP_CONSTANT(BLOCKSIZE = T_BlockSize)
// BCB2006 workaround: can't use BLOCKSIZE here
CRYPTOPP_COMPILE_ASSERT((T_BlockSize & (T_BlockSize - 1)) == 0); // blockSize is a power of 2
@@ -111,13 +115,13 @@ public:
//! \brief Provides the block size of the hash
//! \return the block size of the hash, in bytes
//! \details BlockSize() returns <tt>T_BlockSize</tt>.
- CRYPTOPP_CONSTEXPR unsigned int BlockSize() const {return T_BlockSize;}
+ unsigned int BlockSize() const {return T_BlockSize;}
//! \brief Provides the byte order of the hash
//! \returns the byte order of the hash as an enumeration
//! \details GetByteOrder() returns <tt>T_Endianness::ToEnum()</tt>.
//! \sa ByteOrder()
- CRYPTOPP_CONSTEXPR ByteOrder GetByteOrder() const {return T_Endianness::ToEnum();}
+ ByteOrder GetByteOrder() const {return T_Endianness::ToEnum();}
//! \brief Adjusts the byte ordering of the hash
//! \param out the output buffer
@@ -135,26 +139,30 @@ protected:
};
//! \class IteratedHashWithStaticTransform
-//! \brief Iterated hash with a static transformation function base class
+//! \brief Iterated hash with a static transformation function
//! \tparam T_HashWordType Hash word type
//! \tparam T_Endianness Endianness type of hash
//! \tparam T_BlockSize Block size of the hash
//! \tparam T_StateSize Internal state size of the hash
-//! \tparam T_Transform Static transformation class
+//! \tparam T_Transform HashTransformation derived class
//! \tparam T_DigestSize Digest size of the hash
//! \tparam T_StateAligned Flag indicating if state is 16-byte aligned
-//! \details T_Transform should be derived from HashTransformation, MessageAuthenticationCode, or similar class.
//! \sa HashTransformation, MessageAuthenticationCode
template <class T_HashWordType, class T_Endianness, unsigned int T_BlockSize, unsigned int T_StateSize, class T_Transform, unsigned int T_DigestSize = 0, bool T_StateAligned = false>
class CRYPTOPP_NO_VTABLE IteratedHashWithStaticTransform
: public ClonableImpl<T_Transform, AlgorithmImpl<IteratedHash<T_HashWordType, T_Endianness, T_BlockSize>, T_Transform> >
{
public:
+
+#ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
+ virtual ~IteratedHashWithStaticTransform() { }
+#endif
+
CRYPTOPP_CONSTANT(DIGESTSIZE = T_DigestSize ? T_DigestSize : T_StateSize)
- //! Provides the digest size of the hash
- //! \return the digest size of the hash.
- //! details DigestSize() returns <tt>DIGESTSIZE</tt>.
+ //! \brief Provides the digest size of the hash
+ //! \return the digest size of the hash, in bytes
+ //! \details DigestSize() returns <tt>DIGESTSIZE</tt>.
unsigned int DigestSize() const {return DIGESTSIZE;};
protected: