diff options
author | Jeffrey Walton <noloader@gmail.com> | 2021-04-16 04:56:47 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2021-04-16 04:56:47 -0400 |
commit | 54e2eae4f8a6193c8d4cf776ca3044a7314aff79 (patch) | |
tree | 5ff89422cd95ff8dc62af1a3e0c7978f7b0a1a5e /lsh.h | |
parent | 11eee26d76f4c6e8c7f0639187eb68e66bd7d8d4 (diff) | |
download | cryptopp-git-54e2eae4f8a6193c8d4cf776ca3044a7314aff79.tar.gz |
Use BLOCKSIZE constant in LSH base classes
Diffstat (limited to 'lsh.h')
-rw-r--r-- | lsh.h | 64 |
1 files changed, 46 insertions, 18 deletions
@@ -23,9 +23,13 @@ NAMESPACE_BEGIN(CryptoPP) class LSH256_Base : public HashTransformation
{
public:
+ /// \brief Block size, in bytes
+ /// \details LSH_256 uses LSH256_MSG_BLK_BYTE_LEN for block size, which is 128
+ CRYPTOPP_CONSTANT(BLOCKSIZE = 128);
+
virtual ~LSH256_Base() {}
- unsigned int BlockSize() const { return m_blockSize; }
+ unsigned int BlockSize() const { return BLOCKSIZE; }
unsigned int DigestSize() const { return m_digestSize; }
unsigned int OptimalDataAlignment() const { return GetAlignmentOf<word32>(); }
@@ -36,8 +40,8 @@ public: std::string AlgorithmProvider() const;
protected:
- LSH256_Base(unsigned int algType, unsigned int digestSize, unsigned int blockSize)
- : m_algType(algType), m_digestSize(digestSize), m_blockSize(blockSize) {}
+ LSH256_Base(unsigned int algType, unsigned int digestSize)
+ : m_algType(algType), m_digestSize(digestSize) {}
protected:
// Working state is:
@@ -50,7 +54,7 @@ protected: // * last_block = 32 32-bit words (128 bytes)
FixedSizeSecBlock<word32, 80> m_state;
word32 m_algType, m_remainingBitLength;
- word32 m_digestSize, m_blockSize;
+ word32 m_digestSize;
};
/// \brief LSH-224 hash function
@@ -60,14 +64,18 @@ protected: class LSH224 : public LSH256_Base
{
public:
+ /// \brief Digest size, in bytes
+ /// \details LSH_256 uses LSH_GET_HASHBYTE(algType) for digest size, which is 28
CRYPTOPP_CONSTANT(DIGESTSIZE = 28);
- CRYPTOPP_CONSTANT(BLOCKSIZE = 64);
+ /// \brief Block size, in bytes
+ /// \details LSH_256 uses LSH256_MSG_BLK_BYTE_LEN for block size, which is 128
+ CRYPTOPP_CONSTANT(BLOCKSIZE = LSH256_Base::BLOCKSIZE);
static std::string StaticAlgorithmName() { return "LSH-224"; }
/// \brief Construct a LSH-224
/// \details LSH_TYPE_224 is the magic value 0x000001C defined in lsh.cpp.
- LSH224() : LSH256_Base(0x000001C, DIGESTSIZE, BLOCKSIZE) { Restart(); }
+ LSH224() : LSH256_Base(0x000001C, DIGESTSIZE) { Restart(); }
std::string AlgorithmName() const { return StaticAlgorithmName(); }
};
@@ -79,14 +87,18 @@ public: class LSH256 : public LSH256_Base
{
public:
+ /// \brief Digest size, in bytes
+ /// \details LSH_256 uses LSH_GET_HASHBYTE(algType) for digest size, which is 32
CRYPTOPP_CONSTANT(DIGESTSIZE = 32);
- CRYPTOPP_CONSTANT(BLOCKSIZE = 64);
+ /// \brief Block size, in bytes
+ /// \details LSH_256 uses LSH256_MSG_BLK_BYTE_LEN for block size, which is 128
+ CRYPTOPP_CONSTANT(BLOCKSIZE = LSH256_Base::BLOCKSIZE);
static std::string StaticAlgorithmName() { return "LSH-256"; }
/// \brief Construct a LSH-256
/// \details LSH_TYPE_256 is the magic value 0x0000020 defined in lsh.cpp.
- LSH256() : LSH256_Base(0x0000020, DIGESTSIZE, BLOCKSIZE) { Restart(); }
+ LSH256() : LSH256_Base(0x0000020, DIGESTSIZE) { Restart(); }
std::string AlgorithmName() const { return StaticAlgorithmName(); }
};
@@ -97,9 +109,13 @@ public: class LSH512_Base : public HashTransformation
{
public:
+ /// \brief Block size, in bytes
+ //// \details LSH_512 uses LSH512_MSG_BLK_BYTE_LEN for block size, which is 256
+ CRYPTOPP_CONSTANT(BLOCKSIZE = 256);
+
virtual ~LSH512_Base() {}
- unsigned int BlockSize() const { return m_blockSize; }
+ unsigned int BlockSize() const { return BLOCKSIZE; }
unsigned int DigestSize() const { return m_digestSize; }
unsigned int OptimalDataAlignment() const { return GetAlignmentOf<word64>(); }
@@ -110,8 +126,8 @@ public: std::string AlgorithmProvider() const;
protected:
- LSH512_Base(unsigned int algType, unsigned int digestSize, unsigned int blockSize)
- : m_algType(algType), m_digestSize(digestSize), m_blockSize(blockSize) {}
+ LSH512_Base(unsigned int algType, unsigned int digestSize)
+ : m_algType(algType), m_digestSize(digestSize) {}
protected:
// Working state is:
@@ -124,7 +140,7 @@ protected: // * last_block = 32 64-bit words (256 bytes)
FixedSizeSecBlock<word64, 80> m_state;
word32 m_algType, m_remainingBitLength;
- word32 m_digestSize, m_blockSize;
+ word32 m_digestSize;
};
/// \brief LSH-384 hash function
@@ -134,14 +150,18 @@ protected: class LSH384 : public LSH512_Base
{
public:
+ /// \brief Digest size, in bytes
+ /// \details LSH_512 uses LSH_GET_HASHBYTE(algType) for digest size, which is 48
CRYPTOPP_CONSTANT(DIGESTSIZE = 48);
- CRYPTOPP_CONSTANT(BLOCKSIZE = 128);
+ /// \brief Block size, in bytes
+ /// \details LSH_512 uses LSH512_MSG_BLK_BYTE_LEN for block size, which is 256
+ CRYPTOPP_CONSTANT(BLOCKSIZE = LSH512_Base::BLOCKSIZE);
static std::string StaticAlgorithmName() { return "LSH-384"; }
/// \brief Construct a LSH-384
/// \details LSH_TYPE_384 is the magic value 0x0010030 defined in lsh.cpp.
- LSH384() : LSH512_Base(0x0010030, DIGESTSIZE, BLOCKSIZE) { Restart(); }
+ LSH384() : LSH512_Base(0x0010030, DIGESTSIZE) { Restart(); }
std::string AlgorithmName() const { return StaticAlgorithmName(); }
};
@@ -153,14 +173,18 @@ public: class LSH512 : public LSH512_Base
{
public:
+ /// \brief Digest size, in bytes
+ /// \details LSH_512 uses LSH_GET_HASHBYTE(algType) for digest size, which is 64
CRYPTOPP_CONSTANT(DIGESTSIZE = 64);
- CRYPTOPP_CONSTANT(BLOCKSIZE = 128);
+ /// \brief Block size, in bytes
+ /// \details LSH_512 uses LSH512_MSG_BLK_BYTE_LEN for block size, which is 256
+ CRYPTOPP_CONSTANT(BLOCKSIZE = LSH512_Base::BLOCKSIZE);
static std::string StaticAlgorithmName() { return "LSH-512"; }
/// \brief Construct a LSH-512
/// \details LSH_TYPE_512 is the magic value 0x0010040 defined in lsh.cpp.
- LSH512() : LSH512_Base(0x0010040, DIGESTSIZE, BLOCKSIZE) { Restart(); }
+ LSH512() : LSH512_Base(0x0010040, DIGESTSIZE) { Restart(); }
std::string AlgorithmName() const { return StaticAlgorithmName(); }
};
@@ -172,14 +196,18 @@ public: class LSH512_256 : public LSH512_Base
{
public:
+ /// \brief Digest size, in bytes
+ /// \details LSH_512 uses LSH_GET_HASHBYTE(algType) for digest size, which is 32
CRYPTOPP_CONSTANT(DIGESTSIZE = 32);
- CRYPTOPP_CONSTANT(BLOCKSIZE = 128);
+ /// \brief Block size, in bytes
+ /// \details LSH_512 uses LSH512_MSG_BLK_BYTE_LEN for block size, which is 256
+ CRYPTOPP_CONSTANT(BLOCKSIZE = LSH512_Base::BLOCKSIZE);
static std::string StaticAlgorithmName() { return "LSH-512-256"; }
/// \brief Construct a LSH-512-256
/// \details LSH_TYPE_512_256 is the magic value 0x0010020 defined in lsh.cpp.
- LSH512_256() : LSH512_Base(0x0010020, DIGESTSIZE, BLOCKSIZE) { Restart(); }
+ LSH512_256() : LSH512_Base(0x0010020, DIGESTSIZE) { Restart(); }
std::string AlgorithmName() const { return StaticAlgorithmName(); }
};
|