Skip to content
Permalink
Browse files

Add missing BLAKE2 constructors

BLAKE2b and BLAKE2s are both missing a constructor that takes only the digest size. Also see https://groups.google.com/d/msg/cryptopp-users/QCFGYw8q3Yo/vpBCqz-vBgAJ
  • Loading branch information...
noloader committed Feb 24, 2019
1 parent 758939a commit 31839703005edcd23f4fa4e15563b84e1201f0f4
Showing with 36 additions and 0 deletions.
  1. +20 −0 blake2.cpp
  2. +16 −0 blake2.h
@@ -343,6 +343,26 @@ BLAKE2b::BLAKE2b(bool treeMode, unsigned int digestSize)
(Name::TreeMode(), treeMode));
}

BLAKE2s::BLAKE2s(unsigned int digestSize)
: m_digestSize(digestSize), m_keyLength(0), m_treeMode(false)
{
CRYPTOPP_ASSERT(digestSize <= DIGESTSIZE);

UncheckedSetKey(NULLPTR, 0, MakeParameters
(Name::DigestSize(), (int)digestSize)
(Name::TreeMode(), false));
}

BLAKE2b::BLAKE2b(unsigned int digestSize)
: m_digestSize(digestSize), m_keyLength(0), m_treeMode(false)
{
CRYPTOPP_ASSERT(digestSize <= DIGESTSIZE);

UncheckedSetKey(NULLPTR, 0, MakeParameters
(Name::DigestSize(), (int)digestSize)
(Name::TreeMode(), false));
}

BLAKE2s::BLAKE2s(const byte *key, size_t keyLength, const byte* salt, size_t saltLength,
const byte* personalization, size_t personalizationLength, bool treeMode, unsigned int digestSize)
: m_digestSize(digestSize), m_keyLength(static_cast<unsigned int>(keyLength)), m_treeMode(treeMode)
@@ -256,8 +256,15 @@ class BLAKE2s : public SimpleKeyingInterfaceImpl<MessageAuthenticationCode, BLAK
/// \brief Construct a BLAKE2s hash
/// \param digestSize the digest size, in bytes
/// \param treeMode flag indicating tree mode
/// \since Crypto++ 5.6.4
BLAKE2s(bool treeMode=false, unsigned int digestSize = DIGESTSIZE);

/// \brief Construct a BLAKE2s hash
/// \param digestSize the digest size, in bytes
/// \details treeMode flag is set to false
/// \since Crypto++ 8.2
BLAKE2s(unsigned int digestSize);

/// \brief Construct a BLAKE2s hash
/// \param key a byte array used to key the cipher
/// \param keyLength the size of the byte array
@@ -267,6 +274,7 @@ class BLAKE2s : public SimpleKeyingInterfaceImpl<MessageAuthenticationCode, BLAK
/// \param personalizationLength the size of the byte array
/// \param treeMode flag indicating tree mode
/// \param digestSize the digest size, in bytes
/// \since Crypto++ 5.6.4
BLAKE2s(const byte *key, size_t keyLength, const byte* salt = NULLPTR, size_t saltLength = 0,
const byte* personalization = NULLPTR, size_t personalizationLength = 0,
bool treeMode=false, unsigned int digestSize = DIGESTSIZE);
@@ -355,8 +363,15 @@ class BLAKE2b : public SimpleKeyingInterfaceImpl<MessageAuthenticationCode, BLAK
/// \brief Construct a BLAKE2b hash
/// \param digestSize the digest size, in bytes
/// \param treeMode flag indicating tree mode
/// \since Crypto++ 5.6.4
BLAKE2b(bool treeMode=false, unsigned int digestSize = DIGESTSIZE);

/// \brief Construct a BLAKE2s hash
/// \param digestSize the digest size, in bytes
/// \details treeMode flag is set to false
/// \since Crypto++ 8.2
BLAKE2b(unsigned int digestSize);

/// \brief Construct a BLAKE2b hash
/// \param key a byte array used to key the cipher
/// \param keyLength the size of the byte array
@@ -366,6 +381,7 @@ class BLAKE2b : public SimpleKeyingInterfaceImpl<MessageAuthenticationCode, BLAK
/// \param personalizationLength the size of the byte array
/// \param treeMode flag indicating tree mode
/// \param digestSize the digest size, in bytes
/// \since Crypto++ 5.6.4
BLAKE2b(const byte *key, size_t keyLength, const byte* salt = NULLPTR, size_t saltLength = 0,
const byte* personalization = NULLPTR, size_t personalizationLength = 0,
bool treeMode=false, unsigned int digestSize = DIGESTSIZE);

0 comments on commit 3183970

Please sign in to comment.
You can’t perform that action at this time.