summaryrefslogtreecommitdiff
path: root/keccak.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2016-09-20 19:01:38 -0400
committerJeffrey Walton <noloader@gmail.com>2016-09-20 19:01:38 -0400
commitc298dfdbb017076de1e2f1b6bb8ccd00fe85fb95 (patch)
treeb03507815397d039c7259733cc043eb75242e8bc /keccak.h
parent1dd3fae316e3fd1797bc8a404de827663895c778 (diff)
downloadcryptopp-git-c298dfdbb017076de1e2f1b6bb8ccd00fe85fb95.tar.gz
Revert ccd59710 (Issue 292)
Diffstat (limited to 'keccak.h')
-rw-r--r--keccak.h63
1 files changed, 38 insertions, 25 deletions
diff --git a/keccak.h b/keccak.h
index 2fa0037c..d3580ec1 100644
--- a/keccak.h
+++ b/keccak.h
@@ -56,8 +56,6 @@ public:
void Restart();
void TruncatedFinal(byte *hash, size_t size);
- //unsigned int BlockSize() const { return r(); } // that's the idea behind it
-
protected:
inline unsigned int r() const {return 200 - 2 * m_digestSize;}
@@ -65,42 +63,57 @@ protected:
unsigned int m_digestSize, m_counter;
};
-//! \class Keccak_Final
-//! \tparam DigestSize controls the digest size as a template parameter instead of a per-class constant
-//! \brief Keccak-X message digest, template for more fine-grained typedefs
-//! \since Crypto++ 5.6.5
-template<unsigned int digestSize>
-class Keccak_Final : public Keccak
+//! \class Keccak_224
+//! \brief Keccak-224 message digest
+//! \since Crypto++ 5.6.4
+class Keccak_224 : public Keccak
{
public:
- CRYPTOPP_CONSTANT(DIGESTSIZE = digestSize)
- CRYPTOPP_CONSTANT(BLOCKSIZE = 200 - 2 * DIGESTSIZE)
-
- //! \brief Construct a Keccak-X message digest
- Keccak_Final() : Keccak(DIGESTSIZE) {}
- CRYPTOPP_CONSTEXPR static std::string StaticAlgorithmName() { return "Keccak-" + IntToString(DIGESTSIZE * 8); }
- CRYPTOPP_CONSTEXPR unsigned int BlockSize() const { return BLOCKSIZE; }
-private:
- CRYPTOPP_COMPILE_ASSERT(BLOCKSIZE < 200); // ensure there was no underflow in the math
- CRYPTOPP_COMPILE_ASSERT(BLOCKSIZE > DIGESTSIZE); // this is a general expectation by HMAC
+ CRYPTOPP_CONSTANT(DIGESTSIZE = 28)
+
+ //! \brief Construct a Keccak-224 message digest
+ Keccak_224() : Keccak(DIGESTSIZE) {}
+ CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Keccak-224";}
};
-//! \class Keccak_224
-//! \brief Keccak-224 message digest
-//! \since Crypto++ 5.6.4
-typedef Keccak_Final<28> Keccak_224;
//! \class Keccak_256
//! \brief Keccak-256 message digest
//! \since Crypto++ 5.6.4
-typedef Keccak_Final<32> Keccak_256;
+class Keccak_256 : public Keccak
+{
+public:
+ CRYPTOPP_CONSTANT(DIGESTSIZE = 32)
+
+ //! \brief Construct a Keccak-256 message digest
+ Keccak_256() : Keccak(DIGESTSIZE) {}
+ CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Keccak-256";}
+};
+
//! \class Keccak_384
//! \brief Keccak-384 message digest
//! \since Crypto++ 5.6.4
-typedef Keccak_Final<48> Keccak_384;
+class Keccak_384 : public Keccak
+{
+public:
+ CRYPTOPP_CONSTANT(DIGESTSIZE = 48)
+
+ //! \brief Construct a Keccak-384 message digest
+ Keccak_384() : Keccak(DIGESTSIZE) {}
+ CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Keccak-384";}
+};
+
//! \class Keccak_512
//! \brief Keccak-512 message digest
//! \since Crypto++ 5.6.4
-typedef Keccak_Final<64> Keccak_512;
+class Keccak_512 : public Keccak
+{
+public:
+ CRYPTOPP_CONSTANT(DIGESTSIZE = 64)
+
+ //! \brief Construct a Keccak-512 message digest
+ Keccak_512() : Keccak(DIGESTSIZE) {}
+ CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Keccak-512";}
+};
NAMESPACE_END