16#ifndef CRYPTOPP_BLAKE2_H
17#define CRYPTOPP_BLAKE2_H
30 CRYPTOPP_CONSTANT(MIN_KEYLENGTH = KeyBase::MIN_KEYLENGTH);
31 CRYPTOPP_CONSTANT(MAX_KEYLENGTH = KeyBase::MAX_KEYLENGTH);
32 CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH = KeyBase::DEFAULT_KEYLENGTH);
34 CRYPTOPP_CONSTANT(BLOCKSIZE = 64);
35 CRYPTOPP_CONSTANT(DIGESTSIZE = 32);
36 CRYPTOPP_CONSTANT(SALTSIZE = 8);
37 CRYPTOPP_CONSTANT(PERSONALIZATIONSIZE = 8);
39 CRYPTOPP_STATIC_CONSTEXPR
const char* StaticAlgorithmName() {
return "BLAKE2s";}
51 CRYPTOPP_CONSTANT(BLOCKSIZE = 128);
52 CRYPTOPP_CONSTANT(DIGESTSIZE = 64);
53 CRYPTOPP_CONSTANT(SALTSIZE = 16);
54 CRYPTOPP_CONSTANT(PERSONALIZATIONSIZE = 16);
56 CRYPTOPP_STATIC_CONSTEXPR
const char* StaticAlgorithmName() {
return "BLAKE2b";}
62 CRYPTOPP_CONSTANT(SALTSIZE = BLAKE2s_Info::SALTSIZE);
63 CRYPTOPP_CONSTANT(DIGESTSIZE = BLAKE2s_Info::DIGESTSIZE);
64 CRYPTOPP_CONSTANT(PERSONALIZATIONSIZE = BLAKE2s_Info::PERSONALIZATIONSIZE);
77 const byte* personalization,
size_t personalizationLength);
79 void Reset(
size_t digestLength=DIGESTSIZE,
size_t keyLength=0);
85 const byte* data()
const {
94 return m_data + SaltOff;
97 byte* personalization() {
98 return m_data + PersonalizationOff;
103 DigestOff = 0, KeyOff = 1, FanoutOff = 2, DepthOff = 3, LeafOff = 4, NodeOff = 8,
104 NodeDepthOff = 14, InnerOff = 15, SaltOff = 16, PersonalizationOff = 24
113 CRYPTOPP_CONSTANT(SALTSIZE = BLAKE2b_Info::SALTSIZE);
114 CRYPTOPP_CONSTANT(DIGESTSIZE = BLAKE2b_Info::DIGESTSIZE);
115 CRYPTOPP_CONSTANT(PERSONALIZATIONSIZE = BLAKE2b_Info::PERSONALIZATIONSIZE);
128 const byte* personalization,
size_t personalizationLength);
130 void Reset(
size_t digestLength=DIGESTSIZE,
size_t keyLength=0);
133 return m_data.data();
136 const byte* data()
const {
137 return m_data.data();
140 size_t size()
const {
141 return m_data.size();
145 return m_data + SaltOff;
148 byte* personalization() {
149 return m_data + PersonalizationOff;
154 DigestOff = 0, KeyOff = 1, FanoutOff = 2, DepthOff = 3, LeafOff = 4, NodeOff = 8,
155 NodeDepthOff = 16, InnerOff = 17, RfuOff = 18, SaltOff = 32, PersonalizationOff = 48
176 return m_hft.data() + 8;
180 return m_hft.data() + 10;
183 inline byte* data() {
188 CRYPTOPP_CONSTANT(BLOCKSIZE = BLAKE2s_Info::BLOCKSIZE);
209 return m_hft.data() + 8;
213 return m_hft.data() + 10;
216 inline byte* data() {
221 CRYPTOPP_CONSTANT(BLOCKSIZE = BLAKE2b_Info::BLOCKSIZE);
240 CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH = BLAKE2s_Info::DEFAULT_KEYLENGTH);
241 CRYPTOPP_CONSTANT(MIN_KEYLENGTH = BLAKE2s_Info::MIN_KEYLENGTH);
242 CRYPTOPP_CONSTANT(MAX_KEYLENGTH = BLAKE2s_Info::MAX_KEYLENGTH);
244 CRYPTOPP_CONSTANT(DIGESTSIZE = BLAKE2s_Info::DIGESTSIZE);
245 CRYPTOPP_CONSTANT(BLOCKSIZE = BLAKE2s_Info::BLOCKSIZE);
246 CRYPTOPP_CONSTANT(SALTSIZE = BLAKE2s_Info::SALTSIZE);
247 CRYPTOPP_CONSTANT(PERSONALIZATIONSIZE = BLAKE2s_Info::PERSONALIZATIONSIZE);
252 CRYPTOPP_STATIC_CONSTEXPR
const char* StaticAlgorithmName() {
return "BLAKE2s";}
260 BLAKE2s(
bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE);
266 BLAKE2s(
unsigned int digestSize);
278 BLAKE2s(
const byte *key,
size_t keyLength,
const byte* salt = NULLPTR,
size_t saltLength = 0,
279 const byte* personalization = NULLPTR,
size_t personalizationLength = 0,
280 bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE);
293 void Update(
const byte *input,
size_t length);
321 void Compress(
const byte *input);
322 inline void IncrementCounter(
size_t count=BLOCKSIZE);
324 void UncheckedSetKey(
const byte* key,
unsigned int length,
const CryptoPP::NameValuePairs& params);
328 ParameterBlock m_block;
330 word32 m_digestSize, m_keyLength;
347 CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH = BLAKE2b_Info::DEFAULT_KEYLENGTH);
348 CRYPTOPP_CONSTANT(MIN_KEYLENGTH = BLAKE2b_Info::MIN_KEYLENGTH);
349 CRYPTOPP_CONSTANT(MAX_KEYLENGTH = BLAKE2b_Info::MAX_KEYLENGTH);
351 CRYPTOPP_CONSTANT(DIGESTSIZE = BLAKE2b_Info::DIGESTSIZE);
352 CRYPTOPP_CONSTANT(BLOCKSIZE = BLAKE2b_Info::BLOCKSIZE);
353 CRYPTOPP_CONSTANT(SALTSIZE = BLAKE2b_Info::SALTSIZE);
354 CRYPTOPP_CONSTANT(PERSONALIZATIONSIZE = BLAKE2b_Info::PERSONALIZATIONSIZE);
359 CRYPTOPP_STATIC_CONSTEXPR
const char* StaticAlgorithmName() {
return "BLAKE2b";}
367 BLAKE2b(
bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE);
373 BLAKE2b(
unsigned int digestSize);
385 BLAKE2b(
const byte *key,
size_t keyLength,
const byte* salt = NULLPTR,
size_t saltLength = 0,
386 const byte* personalization = NULLPTR,
size_t personalizationLength = 0,
387 bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE);
400 void Update(
const byte *input,
size_t length);
429 void Compress(
const byte *input);
430 inline void IncrementCounter(
size_t count=BLOCKSIZE);
432 void UncheckedSetKey(
const byte* key,
unsigned int length,
const CryptoPP::NameValuePairs& params);
436 ParameterBlock m_block;
438 word32 m_digestSize, m_keyLength;
SecBlock using AllocatorWithCleanup<byte, true> typedef.
The BLAKE2b cryptographic hash function.
bool GetTreeMode() const
Get tree mode.
std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
void SetTreeMode(bool mode)
Set tree mode.
void TruncatedFinal(byte *hash, size_t size)
Computes the hash of the current message.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
void Restart()
Restart the hash.
unsigned int BlockSize() const
Provides the block size of the compression function.
std::string AlgorithmName() const
Retrieve the object's name.
void Update(const byte *input, size_t length)
Updates a hash with additional input.
unsigned int DigestSize() const
Provides the digest size of the hash.
BLAKE2b(bool treeMode=false, unsigned int digestSize=DIGESTSIZE)
Construct a BLAKE2b hash.
The BLAKE2s cryptographic hash function.
std::string AlgorithmName() const
Retrieve the object's name.
void Update(const byte *input, size_t length)
Updates a hash with additional input.
void SetTreeMode(bool mode)
Set tree mode.
unsigned int DigestSize() const
Provides the digest size of the hash.
void Restart()
Restart the hash.
void TruncatedFinal(byte *hash, size_t size)
Computes the hash of the current message.
bool GetTreeMode() const
Get tree mode.
BLAKE2s(bool treeMode=false, unsigned int digestSize=DIGESTSIZE)
Construct a BLAKE2s hash.
std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
unsigned int BlockSize() const
Provides the block size of the compression function.
Interface for algorithms that take byte strings as keys.
Provides a base implementation of SimpleKeyingInterface.
Inherited by keyed algorithms with variable key length.
static const int MAX_KEYLENGTH
The maximum key length used by the algorithm provided as a constant.
static const int DEFAULT_KEYLENGTH
The default key length used by the algorithm provided as a constant.
static const int MIN_KEYLENGTH
The minimum key length used by the algorithm provided as a constant.
unsigned int word32
32-bit unsigned datatype
unsigned long long word64
64-bit unsigned datatype
Abstract base classes that provide a uniform interface to this library.
std::string IntToString(T value, unsigned int base=10)
Converts a value to a string.
Crypto++ library namespace.
Classes and functions for secure memory allocations.
Classes and functions for implementing secret key algorithms.
BLAKE2b hash information.
BLAKE2b state information.
BLAKE2s hash information.
BLAKE2s state information.