17 #ifndef CRYPTOPP_BLAKE2_H 18 #define CRYPTOPP_BLAKE2_H 29 template <
bool T_64bit>
37 CRYPTOPP_CONSTANT(BLOCKSIZE = (T_64bit ? 128 : 64))
38 CRYPTOPP_CONSTANT(DIGESTSIZE = (T_64bit ? 64 : 32))
39 CRYPTOPP_CONSTANT(SALTSIZE = (T_64bit ? 16 : 8))
40 CRYPTOPP_CONSTANT(PERSONALIZATIONSIZE = (T_64bit ? 16 : 8))
42 CRYPTOPP_STATIC_CONSTEXPR
const char* StaticAlgorithmName() {
return (T_64bit ?
"BLAKE2b" :
"BLAKE2s");}
50 template <
bool T_64bit>
65 memset(
this, 0x00,
sizeof(*
this));
66 digestLength = DIGESTSIZE;
73 memset(
this, 0x00,
sizeof(*
this));
74 digestLength = (byte)digestSize;
79 const byte* personalization,
size_t personalizationLength);
82 byte keyLength, fanout, depth;
85 byte nodeDepth, innerLength, rfu[14];
87 byte personalization[PERSONALIZATIONSIZE];
100 memset(
this, 0x00,
sizeof(*
this));
101 digestLength = DIGESTSIZE;
108 memset(
this, 0x00,
sizeof(*
this));
109 digestLength = (byte)digestSize;
114 const byte* personalization,
size_t personalizationLength);
117 byte keyLength, fanout, depth;
120 byte nodeDepth, innerLength;
122 byte personalization[PERSONALIZATIONSIZE];
131 template <
class W,
bool T_64bit>
139 h[0]=h[1]=h[2]=h[3]=h[4]=h[5]=h[6]=h[7] = 0;
140 t[0]=t[1]=f[0]=f[1] = 0;
146 byte buffer[BLOCKSIZE];
156 template <
class W,
bool T_64bit>
190 void Update(
const byte *input,
size_t length);
216 BLAKE2_Base(
bool treeMode,
unsigned int digestSize);
217 BLAKE2_Base(
const byte *key,
size_t keyLength,
const byte* salt,
size_t saltLength,
218 const byte* personalization,
size_t personalizationLength,
219 bool treeMode,
unsigned int digestSize);
222 void Compress(
const byte *input);
223 inline void IncrementCounter(
size_t count=BLOCKSIZE);
225 void UncheckedSetKey(
const byte* key,
unsigned int length,
const CryptoPP::NameValuePairs& params);
228 AlignedState m_state;
229 AlignedParameterBlock m_block;
254 BLAKE2b(
bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE) :
ThisBase(treeMode, digestSize) {}
265 BLAKE2b(
const byte *key,
size_t keyLength,
const byte* salt = NULLPTR,
size_t saltLength = 0,
266 const byte* personalization = NULLPTR,
size_t personalizationLength = 0,
267 bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE)
268 :
ThisBase(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {}
290 BLAKE2s(
bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE) :
ThisBase(treeMode, digestSize) {}
301 BLAKE2s(
const byte *key,
size_t keyLength,
const byte* salt = NULLPTR,
size_t saltLength = 0,
302 const byte* personalization = NULLPTR,
size_t personalizationLength = 0,
303 bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE)
304 :
ThisBase(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {}
void Restart()
Restart the hash.
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)
Construct a BLAKE2b hash.
BLAKE2 hash implementation.
bool GetTreeMode() const
Get tree mode.
static const int MAX_KEYLENGTH
The maximum key length used by the algorithm provided as a constant.
Provides a base implementation of SimpleKeyingInterface.
void TruncatedFinal(byte *hash, size_t size)
Computes the hash of the current message.
Secure memory block with allocator and cleanup.
Abstract base classes that provide a uniform interface to this library.
The object does not use an IV.
BLAKE2s(bool treeMode=false, unsigned int digestSize=DIGESTSIZE)
Construct a BLAKE2s hash.
The BLAKE2s cryptographic hash function.
Classes and functions for secure memory allocations.
Classes and functions for implementing secret key algorithms.
#define CRYPTOPP_COMPILE_ASSERT(expr)
Compile time assertion.
std::string AlgorithmName() const
Retrieve the object's name.
static const int DEFAULT_KEYLENGTH
The default key length used by the algorithm provided as a constant.
SecBlock using AllocatorWithCleanup<byte, true> typedef.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
BLAKE2s parameter block specialization.
Inherited by keyed algorithms with variable key length.
BLAKE2 state information.
unsigned int DigestSize() const
Provides the digest size of the hash.
void SetTreeMode(bool mode)
Set tree mode.
static const int MIN_KEYLENGTH
The minimum key length used by the algorithm provided as a constant.
std::string IntToString(T value, unsigned int base=10)
Converts a value to a string.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
static const char * StaticAlgorithmName()
Retrieve the static algorithm name.
Crypto++ library namespace.
BLAKE2b(bool treeMode=false, unsigned int digestSize=DIGESTSIZE)
Construct a BLAKE2b hash.
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)
Construct a BLAKE2s hash.
The BLAKE2b cryptographic hash function.
BLAKE2b parameter block specialization.
void Update(const byte *input, size_t length)
Updates a hash with additional input.