18 #ifndef CRYPTOPP_BLAKE2_H
19 #define CRYPTOPP_BLAKE2_H
31 template <
bool T_64bit>
39 CRYPTOPP_CONSTANT(BLOCKSIZE = (T_64bit ? 128 : 64))
40 CRYPTOPP_CONSTANT(DIGESTSIZE = (T_64bit ? 64 : 32))
41 CRYPTOPP_CONSTANT(SALTSIZE = (T_64bit ? 16 : 8))
42 CRYPTOPP_CONSTANT(PERSONALIZATIONSIZE = (T_64bit ? 16 : 8))
44 CRYPTOPP_CONSTEXPR
static const char *StaticAlgorithmName() {
return (T_64bit ?
"BLAKE2b" :
"BLAKE2s");}
53 template <
bool T_64bit>
68 memset(
this, 0x00,
sizeof(*
this));
69 digestLength = DIGESTSIZE;
76 memset(
this, 0x00,
sizeof(*
this));
77 digestLength = (byte)digestSize;
82 const byte* personalization,
size_t personalizationLength);
85 byte keyLength, fanout, depth;
88 byte nodeDepth, innerLength, rfu[14];
90 byte personalization[PERSONALIZATIONSIZE];
103 memset(
this, 0x00,
sizeof(*
this));
104 digestLength = DIGESTSIZE;
111 memset(
this, 0x00,
sizeof(*
this));
112 digestLength = (byte)digestSize;
117 const byte* personalization,
size_t personalizationLength);
120 byte keyLength, fanout, depth;
123 byte nodeDepth, innerLength;
125 byte personalization[PERSONALIZATIONSIZE];
135 template <
class W,
bool T_64bit>
143 h[0]=h[1]=h[2]=h[3]=h[4]=h[5]=h[6]=h[7] = 0;
144 t[0]=t[1]=f[0]=f[1] = 0;
150 byte buffer[BLOCKSIZE];
161 template <
class W,
bool T_64bit>
195 void Update(
const byte *input,
size_t length);
221 BLAKE2_Base(
bool treeMode,
unsigned int digestSize);
222 BLAKE2_Base(
const byte *key,
size_t keyLength,
const byte* salt,
size_t saltLength,
223 const byte* personalization,
size_t personalizationLength,
224 bool treeMode,
unsigned int digestSize);
227 void Compress(
const byte *input);
228 inline void IncrementCounter(
size_t count=BLOCKSIZE);
230 void UncheckedSetKey(
const byte* key,
unsigned int length,
const CryptoPP::NameValuePairs& params);
233 AlignedState m_state;
234 AlignedParameterBlock m_block;
259 BLAKE2b(
bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE) :
ThisBase(treeMode, digestSize) {}
270 BLAKE2b(
const byte *key,
size_t keyLength,
const byte* salt = NULL,
size_t saltLength = 0,
271 const byte* personalization = NULL,
size_t personalizationLength = 0,
272 bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE)
273 :
ThisBase(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {}
295 BLAKE2s(
bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE) :
ThisBase(treeMode, digestSize) {}
306 BLAKE2s(
const byte *key,
size_t keyLength,
const byte* salt = NULL,
size_t saltLength = 0,
307 const byte* personalization = NULL,
size_t personalizationLength = 0,
308 bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE)
309 :
ThisBase(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {}