Skip to content

Commit 3183970

Browse files
committed
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
1 parent 758939a commit 3183970

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

blake2.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,26 @@ BLAKE2b::BLAKE2b(bool treeMode, unsigned int digestSize)
343343
(Name::TreeMode(), treeMode));
344344
}
345345

346+
BLAKE2s::BLAKE2s(unsigned int digestSize)
347+
: m_digestSize(digestSize), m_keyLength(0), m_treeMode(false)
348+
{
349+
CRYPTOPP_ASSERT(digestSize <= DIGESTSIZE);
350+
351+
UncheckedSetKey(NULLPTR, 0, MakeParameters
352+
(Name::DigestSize(), (int)digestSize)
353+
(Name::TreeMode(), false));
354+
}
355+
356+
BLAKE2b::BLAKE2b(unsigned int digestSize)
357+
: m_digestSize(digestSize), m_keyLength(0), m_treeMode(false)
358+
{
359+
CRYPTOPP_ASSERT(digestSize <= DIGESTSIZE);
360+
361+
UncheckedSetKey(NULLPTR, 0, MakeParameters
362+
(Name::DigestSize(), (int)digestSize)
363+
(Name::TreeMode(), false));
364+
}
365+
346366
BLAKE2s::BLAKE2s(const byte *key, size_t keyLength, const byte* salt, size_t saltLength,
347367
const byte* personalization, size_t personalizationLength, bool treeMode, unsigned int digestSize)
348368
: m_digestSize(digestSize), m_keyLength(static_cast<unsigned int>(keyLength)), m_treeMode(treeMode)

blake2.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,15 @@ class BLAKE2s : public SimpleKeyingInterfaceImpl<MessageAuthenticationCode, BLAK
256256
/// \brief Construct a BLAKE2s hash
257257
/// \param digestSize the digest size, in bytes
258258
/// \param treeMode flag indicating tree mode
259+
/// \since Crypto++ 5.6.4
259260
BLAKE2s(bool treeMode=false, unsigned int digestSize = DIGESTSIZE);
260261

262+
/// \brief Construct a BLAKE2s hash
263+
/// \param digestSize the digest size, in bytes
264+
/// \details treeMode flag is set to false
265+
/// \since Crypto++ 8.2
266+
BLAKE2s(unsigned int digestSize);
267+
261268
/// \brief Construct a BLAKE2s hash
262269
/// \param key a byte array used to key the cipher
263270
/// \param keyLength the size of the byte array
@@ -267,6 +274,7 @@ class BLAKE2s : public SimpleKeyingInterfaceImpl<MessageAuthenticationCode, BLAK
267274
/// \param personalizationLength the size of the byte array
268275
/// \param treeMode flag indicating tree mode
269276
/// \param digestSize the digest size, in bytes
277+
/// \since Crypto++ 5.6.4
270278
BLAKE2s(const byte *key, size_t keyLength, const byte* salt = NULLPTR, size_t saltLength = 0,
271279
const byte* personalization = NULLPTR, size_t personalizationLength = 0,
272280
bool treeMode=false, unsigned int digestSize = DIGESTSIZE);
@@ -355,8 +363,15 @@ class BLAKE2b : public SimpleKeyingInterfaceImpl<MessageAuthenticationCode, BLAK
355363
/// \brief Construct a BLAKE2b hash
356364
/// \param digestSize the digest size, in bytes
357365
/// \param treeMode flag indicating tree mode
366+
/// \since Crypto++ 5.6.4
358367
BLAKE2b(bool treeMode=false, unsigned int digestSize = DIGESTSIZE);
359368

369+
/// \brief Construct a BLAKE2s hash
370+
/// \param digestSize the digest size, in bytes
371+
/// \details treeMode flag is set to false
372+
/// \since Crypto++ 8.2
373+
BLAKE2b(unsigned int digestSize);
374+
360375
/// \brief Construct a BLAKE2b hash
361376
/// \param key a byte array used to key the cipher
362377
/// \param keyLength the size of the byte array
@@ -366,6 +381,7 @@ class BLAKE2b : public SimpleKeyingInterfaceImpl<MessageAuthenticationCode, BLAK
366381
/// \param personalizationLength the size of the byte array
367382
/// \param treeMode flag indicating tree mode
368383
/// \param digestSize the digest size, in bytes
384+
/// \since Crypto++ 5.6.4
369385
BLAKE2b(const byte *key, size_t keyLength, const byte* salt = NULLPTR, size_t saltLength = 0,
370386
const byte* personalization = NULLPTR, size_t personalizationLength = 0,
371387
bool treeMode=false, unsigned int digestSize = DIGESTSIZE);

0 commit comments

Comments
 (0)