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";}
259 BLAKE2s(
bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE);
270 BLAKE2s(
const byte *key,
size_t keyLength,
const byte* salt = NULLPTR,
size_t saltLength = 0,
271 const byte* personalization = NULLPTR,
size_t personalizationLength = 0,
272 bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE);
284 void Update(
const byte *input,
size_t length);
312 void Compress(
const byte *input);
313 inline void IncrementCounter(
size_t count=BLOCKSIZE);
315 void UncheckedSetKey(
const byte* key,
unsigned int length,
const CryptoPP::NameValuePairs& params);
319 ParameterBlock m_block;
321 word32 m_digestSize, m_keyLength;
338 CRYPTOPP_CONSTANT(DEFAULT_KEYLENGTH = BLAKE2b_Info::DEFAULT_KEYLENGTH)
339 CRYPTOPP_CONSTANT(MIN_KEYLENGTH = BLAKE2b_Info::MIN_KEYLENGTH)
340 CRYPTOPP_CONSTANT(MAX_KEYLENGTH = BLAKE2b_Info::MAX_KEYLENGTH)
342 CRYPTOPP_CONSTANT(DIGESTSIZE = BLAKE2b_Info::DIGESTSIZE)
343 CRYPTOPP_CONSTANT(BLOCKSIZE = BLAKE2b_Info::BLOCKSIZE)
344 CRYPTOPP_CONSTANT(SALTSIZE = BLAKE2b_Info::SALTSIZE)
345 CRYPTOPP_CONSTANT(PERSONALIZATIONSIZE = BLAKE2b_Info::PERSONALIZATIONSIZE)
350 CRYPTOPP_STATIC_CONSTEXPR
const char* StaticAlgorithmName() {
return "BLAKE2b";}
357 BLAKE2b(
bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE);
368 BLAKE2b(
const byte *key,
size_t keyLength,
const byte* salt = NULLPTR,
size_t saltLength = 0,
369 const byte* personalization = NULLPTR,
size_t personalizationLength = 0,
370 bool treeMode=
false,
unsigned int digestSize = DIGESTSIZE);
382 void Update(
const byte *input,
size_t length);
411 void Compress(
const byte *input);
412 inline void IncrementCounter(
size_t count=BLOCKSIZE);
414 void UncheckedSetKey(
const byte* key,
unsigned int length,
const CryptoPP::NameValuePairs& params);
418 ParameterBlock m_block;
420 word32 m_digestSize, m_keyLength;
void Update(const byte *input, size_t length)
Updates a hash with additional input.
std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
static const int MAX_KEYLENGTH
The maximum key length used by the algorithm provided as a constant.
Provides a base implementation of SimpleKeyingInterface.
std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
Abstract base classes that provide a uniform interface to this library.
void SetTreeMode(bool mode)
Set tree mode.
void TruncatedFinal(byte *hash, size_t size)
Computes the hash of the current message.
BLAKE2s(bool treeMode=false, unsigned int digestSize=DIGESTSIZE)
Construct a BLAKE2s hash.
The BLAKE2s cryptographic hash function.
Classes and functions for secure memory allocations.
unsigned int DigestSize() const
Provides the digest size of the hash.
Classes and functions for implementing secret key algorithms.
static const int DEFAULT_KEYLENGTH
The default key length used by the algorithm provided as a constant.
unsigned int DigestSize() const
Provides the digest size of the hash.
Interface for algorithms that take byte strings as keys.
std::string AlgorithmName() const
Retrieve the object's name.
BLAKE2s hash information.
SecBlock using AllocatorWithCleanup<byte, true> typedef.
void SetTreeMode(bool mode)
Set tree mode.
void Update(const byte *input, size_t length)
Updates a hash with additional input.
Inherited by keyed algorithms with variable key length.
bool GetTreeMode() const
Get tree mode.
void Restart()
Restart the hash.
static const int MIN_KEYLENGTH
The minimum key length used by the algorithm provided as a constant.
std::string AlgorithmName() const
Retrieve the object's name.
bool GetTreeMode() const
Get tree mode.
BLAKE2s state information.
BLAKE2b state information.
std::string IntToString(T value, unsigned int base=10)
Converts a value to a string.
void TruncatedFinal(byte *hash, size_t size)
Computes the hash of the current message.
BLAKE2b hash information.
Crypto++ library namespace.
BLAKE2b(bool treeMode=false, unsigned int digestSize=DIGESTSIZE)
Construct a BLAKE2b hash.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
The BLAKE2b cryptographic hash function.
void Restart()
Restart the hash.