Revert ccd59710 (Issue 292)
parent
1dd3fae316
commit
c298dfdbb0
65
keccak.h
65
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
|
||||
{
|
||||
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
|
||||
};
|
||||
|
||||
//! \class Keccak_224
|
||||
//! \brief Keccak-224 message digest
|
||||
//! \since Crypto++ 5.6.4
|
||||
typedef Keccak_Final<28> Keccak_224;
|
||||
class Keccak_224 : public Keccak
|
||||
{
|
||||
public:
|
||||
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_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
|
||||
|
||||
|
|
|
|||
64
sha3.h
64
sha3.h
|
|
@ -42,7 +42,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;}
|
||||
|
||||
|
|
@ -50,42 +49,57 @@ protected:
|
|||
unsigned int m_digestSize, m_counter;
|
||||
};
|
||||
|
||||
//! \class SHA3_Final
|
||||
//! \tparam DigestSize controls the digest size as a template parameter instead of a per-class constant
|
||||
//! \brief SHA3-X message digest, template for more fine-grained typedefs
|
||||
//! \since Crypto++ 5.6.5
|
||||
template<unsigned int digestSize>
|
||||
class SHA3_Final : public SHA3
|
||||
{
|
||||
public:
|
||||
CRYPTOPP_CONSTANT(DIGESTSIZE = digestSize)
|
||||
CRYPTOPP_CONSTANT(BLOCKSIZE = 200 - 2 * DIGESTSIZE)
|
||||
|
||||
//! \brief Construct a SHA3-X message digest
|
||||
SHA3_Final() : SHA3(DIGESTSIZE) {}
|
||||
CRYPTOPP_CONSTEXPR static std::string StaticAlgorithmName() { return "SHA3-" + 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
|
||||
};
|
||||
|
||||
//! \class SHA3_224
|
||||
//! \brief SHA3-224 message digest
|
||||
//! \since Crypto++ 5.6.2
|
||||
typedef SHA3_Final<28> SHA3_224;
|
||||
class SHA3_224 : public SHA3
|
||||
{
|
||||
public:
|
||||
CRYPTOPP_CONSTANT(DIGESTSIZE = 28)
|
||||
|
||||
//! \brief Construct a SHA3-224 message digest
|
||||
SHA3_224() : SHA3(DIGESTSIZE) {}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA3-224";}
|
||||
};
|
||||
|
||||
//! \class SHA3_256
|
||||
//! \brief SHA3-256 message digest
|
||||
//! \since Crypto++ 5.6.2
|
||||
typedef SHA3_Final<32> SHA3_256;
|
||||
class SHA3_256 : public SHA3
|
||||
{
|
||||
public:
|
||||
CRYPTOPP_CONSTANT(DIGESTSIZE = 32)
|
||||
|
||||
//! \brief Construct a SHA3-256 message digest
|
||||
SHA3_256() : SHA3(DIGESTSIZE) {}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA3-256";}
|
||||
};
|
||||
|
||||
//! \class SHA3_384
|
||||
//! \brief SHA3-384 message digest
|
||||
//! \since Crypto++ 5.6.2
|
||||
typedef SHA3_Final<48> SHA3_384;
|
||||
class SHA3_384 : public SHA3
|
||||
{
|
||||
public:
|
||||
CRYPTOPP_CONSTANT(DIGESTSIZE = 48)
|
||||
|
||||
//! \brief Construct a SHA3-384 message digest
|
||||
SHA3_384() : SHA3(DIGESTSIZE) {}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA3-384";}
|
||||
};
|
||||
|
||||
//! \class SHA3_512
|
||||
//! \brief SHA3-512 message digest
|
||||
//! \since Crypto++ 5.6.2
|
||||
typedef SHA3_Final<64> SHA3_512;
|
||||
class SHA3_512 : public SHA3
|
||||
{
|
||||
public:
|
||||
CRYPTOPP_CONSTANT(DIGESTSIZE = 64)
|
||||
|
||||
//! \brief Construct a SHA3-512 message digest
|
||||
SHA3_512() : SHA3(DIGESTSIZE) {}
|
||||
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA3-512";}
|
||||
};
|
||||
|
||||
NAMESPACE_END
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue