From 1b661bb68809eb87149d8ec43123e814ac7debb5 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 18 Apr 2016 00:46:59 -0400 Subject: Add constants for MIN_KEYLENGTH, MAX_KEYLENGTH, DEFAULT_KEYLENGTH. Fix keyed hash calculation. Fix tree mode variable initialization. Cleanup whitespace in BLAKE2_SSE2_Compress64 --- blake2.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'blake2.h') diff --git a/blake2.h b/blake2.h index a6583d32..12b4efb4 100644 --- a/blake2.h +++ b/blake2.h @@ -37,6 +37,11 @@ NAMESPACE_BEGIN(CryptoPP) template struct CRYPTOPP_NO_VTABLE BLAKE2_Info : public VariableKeyLength<0,0,(T_64bit ? 64 : 32),1,SimpleKeyingInterface::NOT_RESYNCHRONIZABLE> { + typedef VariableKeyLength<0,0,(T_64bit ? 64 : 32),1,SimpleKeyingInterface::NOT_RESYNCHRONIZABLE> KeyBase; + CRYPTOPP_CONSTANT(MIN_KEYLENGTH = KeyBase::MIN_KEYLENGTH); + CRYPTOPP_CONSTANT(MAX_KEYLENGTH = KeyBase::MAX_KEYLENGTH); + CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH = KeyBase::DEFAULT_KEYLENGTH); + CRYPTOPP_CONSTANT(BLOCKSIZE = (T_64bit ? 128 : 64)) CRYPTOPP_CONSTANT(DIGESTSIZE = (T_64bit ? 64 : 32)) CRYPTOPP_CONSTANT(SALTSIZE = (T_64bit ? 16 : 8)) @@ -175,6 +180,10 @@ template class BLAKE2_Base : public SimpleKeyingInterfaceImpl > { public: + CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH = BLAKE2_Info::DEFAULT_KEYLENGTH); + CRYPTOPP_CONSTANT(MIN_KEYLENGTH = BLAKE2_Info::MIN_KEYLENGTH); + CRYPTOPP_CONSTANT(MAX_KEYLENGTH = BLAKE2_Info::MAX_KEYLENGTH); + CRYPTOPP_CONSTANT(DIGESTSIZE = BLAKE2_Info::DIGESTSIZE); CRYPTOPP_CONSTANT(BLOCKSIZE = BLAKE2_Info::BLOCKSIZE); CRYPTOPP_CONSTANT(ALIGNSIZE = BLAKE2_Info::ALIGNSIZE); @@ -254,14 +263,13 @@ private: class BLAKE2b : public BLAKE2_Base { public: - CRYPTOPP_CONSTANT(DIGESTSIZE = BLAKE2_Info::DIGESTSIZE); - typedef BLAKE2_Base BaseClass; // Early Visual Studio workaround + typedef BLAKE2_Base ThisBase; // Early Visual Studio workaround typedef BLAKE2_ParameterBlock ParameterBlock; CRYPTOPP_COMPILE_ASSERT(sizeof(ParameterBlock) == 64); //! \brief Construct a BLAKE2b hash //! \param digestSize the digest size, in bytes - BLAKE2b(bool treeMode=false, unsigned int digestSize = DIGESTSIZE) : BaseClass(treeMode, digestSize) {} + BLAKE2b(bool treeMode=false, unsigned int digestSize = DIGESTSIZE) : ThisBase(treeMode, digestSize) {} //! \brief Construct a BLAKE2b hash //! \param key a byte array used to key the cipher @@ -275,7 +283,7 @@ public: BLAKE2b(const byte *key, size_t keyLength, const byte* salt = NULL, size_t saltLength = 0, const byte* personalization = NULL, size_t personalizationLength = 0, bool treeMode=false, unsigned int digestSize = DIGESTSIZE) - : BaseClass(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {} + : ThisBase(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {} }; //! \brief The BLAKE2s cryptographic hash function @@ -289,14 +297,13 @@ public: class BLAKE2s : public BLAKE2_Base { public: - CRYPTOPP_CONSTANT(DIGESTSIZE = BLAKE2_Info::DIGESTSIZE); - typedef BLAKE2_Base BaseClass; // Early Visual Studio workaround + typedef BLAKE2_Base ThisBase; // Early Visual Studio workaround typedef BLAKE2_ParameterBlock ParameterBlock; CRYPTOPP_COMPILE_ASSERT(sizeof(ParameterBlock) == 32); //! \brief Construct a BLAKE2b hash //! \param digestSize the digest size, in bytes - BLAKE2s(bool treeMode=false, unsigned int digestSize = DIGESTSIZE) : BaseClass(treeMode, digestSize) {} + BLAKE2s(bool treeMode=false, unsigned int digestSize = DIGESTSIZE) : ThisBase(treeMode, digestSize) {} //! \brief Construct a BLAKE2b hash //! \param key a byte array used to key the cipher @@ -310,7 +317,7 @@ public: BLAKE2s(const byte *key, size_t keyLength, const byte* salt = NULL, size_t saltLength = 0, const byte* personalization = NULL, size_t personalizationLength = 0, bool treeMode=false, unsigned int digestSize = DIGESTSIZE) - : BaseClass(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {} + : ThisBase(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {} }; NAMESPACE_END -- cgit v1.2.1