Anklang-0.3.0.dev956+gd75ac925 anklang-0.3.0.dev956+gd75ac925
ASE — Anklang Sound Engine (C++)

« « « Anklang Documentation
Loading...
Searching...
No Matches
randomhash.hh
Go to the documentation of this file.
1 // This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
2// Author: 2014, Tim Janik, see http://testbit.eu/
3#pragma once
4
5#include <ase/cxxaux.hh>
6
7namespace Ase {
8
17template<size_t SIZE>
18struct alignas (16) AlignedPOD {
19 alignas (16) unsigned char mem[SIZE];
20 /* malloc() aligns to 2 * sizeof (size_t), i.e. 16 on 64bit, max_align_t is
21 * usually aligned to long double, i.e. 16, and most SIMD code also needs at
22 * least 16 byte alignment.
23 */
24};
25
26// == Random Numbers ==
29int64_t random_irange (int64_t begin, int64_t end);
30double random_float ();
31double random_frange (double begin, double end);
32void random_secret (uint64_t *secret_var);
33
34// == FastRNG ==
36class Mwc256 {
37 // Based on https://prng.di.unimi.it/MWC256.c
38 uint64_t state alignas (64) [4];
39public:
40 static constexpr uint64_t MWC_A3 = 0xff377e26f82da74a;
41 Mwc256 clone192 ();
42 Mwc256 clone128 ();
43 uint64_t next ();
44 void seed ();
45 void seed (uint64_t x, uint64_t y = 0, uint64_t z = 0, uint64_t c = 1);
46 explicit Mwc256 (uint64_t x, uint64_t y = 0, uint64_t z = 0, uint64_t c = 1);
47 explicit Mwc256 ();
48 /*copy*/ Mwc256 (const Mwc256&) = default;
49 Mwc256& operator= (const Mwc256&) = default;
50};
51
52inline uint64_t
53Mwc256::next()
54{
55 const __uint128_t t = MWC_A3 * __uint128_t (state[0]) + state[3];
56 state[0] = state[1];
57 state[1] = state[2];
58 state[3] = t >> 64;
59 return state[2] = t;
60}
61
62using FastRng = Mwc256;
63
64// == Hashing ==
68struct SHA3_224 {
69 /*dtor*/ ~SHA3_224 ();
70 /*ctor*/ SHA3_224 ();
71 void reset ();
72 void update (const uint8_t *data, size_t length);
73 void digest (uint8_t hashvalue[28]);
74 void update (const String &s) { update ((const uint8_t*) &s[0], s.size()); }
75private:
76 AlignedPOD<232> mem_;
77 struct State;
78 State *state_;
79};
81void sha3_224_hash (const void *data, size_t data_length, uint8_t hashvalue[28]);
82
86struct SHA3_256 {
87 /*dtor*/ ~SHA3_256 ();
88 /*ctor*/ SHA3_256 ();
89 void reset ();
90 void update (const uint8_t *data, size_t length);
91 void digest (uint8_t hashvalue[32]);
92 void update (const String &s) { update ((const uint8_t*) &s[0], s.size()); }
93private:
94 AlignedPOD<232> mem_;
95 struct State;
96 State *state_;
97};
99void sha3_256_hash (const void *data, size_t data_length, uint8_t hashvalue[32]);
100
104struct SHA3_384 {
105 /*dtor*/ ~SHA3_384 ();
106 /*ctor*/ SHA3_384 ();
107 void reset ();
108 void update (const uint8_t *data, size_t length);
109 void digest (uint8_t hashvalue[48]);
110 void update (const String &s) { update ((const uint8_t*) &s[0], s.size()); }
111private:
112 AlignedPOD<232> mem_;
113 struct State;
114 State *state_;
115};
117void sha3_384_hash (const void *data, size_t data_length, uint8_t hashvalue[48]);
118
122struct SHA3_512 {
123 /*dtor*/ ~SHA3_512 ();
124 /*ctor*/ SHA3_512 ();
125 void reset ();
126 void update (const uint8_t *data, size_t length);
127 void digest (uint8_t hashvalue[64]);
128 void update (const String &s) { update ((const uint8_t*) &s[0], s.size()); }
129private:
130 AlignedPOD<232> mem_;
131 struct State;
132 State *state_;
133};
135void sha3_512_hash (const void *data, size_t data_length, uint8_t hashvalue[64]);
136
140struct SHAKE128 {
141 /*dtor*/ ~SHAKE128 ();
142 /*ctor*/ SHAKE128 ();
143 void reset ();
144 void update (const uint8_t *data, size_t length);
145 void squeeze_digest (uint8_t *hashvalues, size_t n);
146 void update (const String &s) { update ((const uint8_t*) &s[0], s.size()); }
147private:
148 AlignedPOD<232> mem_;
149 struct State;
150 State *state_;
151};
153void shake128_hash (const void *data, size_t data_length, uint8_t *hashvalues, size_t n);
154
158struct SHAKE256 {
159 /*dtor*/ ~SHAKE256 ();
160 /*ctor*/ SHAKE256 ();
161 void reset ();
162 void update (const uint8_t *data, size_t length);
163 void squeeze_digest (uint8_t *hashvalues, size_t n);
164 void update (const String &s) { update ((const uint8_t*) &s[0], s.size()); }
165private:
166 AlignedPOD<232> mem_;
167 struct State;
168 State *state_;
169};
171void shake256_hash (const void *data, size_t data_length, uint8_t *hashvalues, size_t n);
172
173namespace Lib { // Namespace for implementation internals
174
176class KeccakF1600 {
177 union alignas (2 * sizeof (uint64_t))
178 {
179 uint64_t A[25];
180 uint8_t bytes[200];
181 // __MMX__: __m64 V[25];
182 };
183public:
184 explicit KeccakF1600 ();
185 void reset ();
186 uint64_t& operator[] (int index) { return A[index]; }
187 uint64_t operator[] (int index) const { return A[index]; }
188 void permute (uint32_t n_rounds);
189 inline uint8_t&
190 byte (size_t state_index)
191 {
192#if __BYTE_ORDER == __LITTLE_ENDIAN
193 return bytes[(state_index / 8) * 8 + (state_index % 8)]; // 8 == sizeof (uint64_t)
194#elif __BYTE_ORDER == __BIG_ENDIAN
195 return bytes[(state_index / 8) * 8 + (8 - 1 - (state_index % 8))]; // 8 == sizeof (uint64_t)
196#else
197# error "Unknown __BYTE_ORDER"
198#endif
199 }
200};
201
202} // Lib
203
206public:
208 static uint64 random () { return random_int64(); }
210 uint64 operator() () const { return this->random(); }
212 template<typename RandomAccessIterator> void
213 generate (RandomAccessIterator begin, RandomAccessIterator end)
214 {
216 while (begin != end)
217 {
218 const uint64_t rbits = operator()();
219 *begin++ = Value (rbits);
220 if (sizeof (Value) <= 4 && begin != end)
221 *begin++ = Value (rbits >> 32);
222 }
223 }
224};
225
233 const uint16_t bit_rate_, n_rounds_;
234 uint32_t opos_;
235 Lib::KeccakF1600 state_;
236 void permute1600();
237public:
238 /*copy*/ KeccakRng (const KeccakRng&) = default;
242 inline size_t n_nums() const { return bit_rate_ / 64; }
244 inline size_t bit_capacity() const { return 1600 - bit_rate_; }
245 /*dtor*/ ~KeccakRng ();
247 explicit
248 KeccakRng (uint16_t hidden_state_capacity, uint16_t n_rounds) :
249 bit_rate_ (1600 - hidden_state_capacity), n_rounds_ (n_rounds), opos_ (n_nums())
250 {
251 ASE_ASSERT_RETURN (hidden_state_capacity > 0 && hidden_state_capacity <= 1600 - 64);
252 ASE_ASSERT_RETURN (64 * (hidden_state_capacity / 64) == hidden_state_capacity); // capacity must be 64bit aligned
253 ASE_ASSERT_RETURN (n_rounds > 0 && n_rounds < 255); // see KECCAK_ROUND_CONSTANTS access
254 }
255 void forget ();
256 void discard (unsigned long long count);
257 void xor_seed (const uint64_t *seeds, size_t n_seeds);
259 void seed (uint64_t seed_value = 1) { seed (&seed_value, 1); }
261 void
262 seed (const uint64_t *seeds, size_t n_seeds)
263 {
264 state_.reset();
265 xor_seed (seeds, n_seeds);
266 }
268 template<class SeedSeq> void
269 seed (SeedSeq &seed_sequence)
270 {
271 uint32_t u32[50]; // fill 50 * 32 = 1600 state bits
272 seed_sequence.generate (&u32[0], &u32[50]);
273 uint64_t u64[25];
274 for (size_t i = 0; i < 25; i++) // Keccak bit order: 1) LSB 2) MSB
275 u64[i] = u32[i * 2] | (uint64_t (u32[i * 2 + 1]) << 32);
276 seed (u64, 25);
277 }
279 void auto_seed ();
284 {
285 if (opos_ >= n_nums())
286 permute1600();
287 return state_[opos_++];
288 }
292 template<typename RandomAccessIterator> void
293 generate (RandomAccessIterator begin, RandomAccessIterator end)
294 {
296 while (begin != end)
297 {
298 const uint64_t rbits = operator()();
299 *begin++ = Value (rbits);
300 if (sizeof (Value) <= 4 && begin != end)
301 *begin++ = Value (rbits >> 32);
302 }
303 }
305 friend bool
306 operator== (const KeccakRng &lhs, const KeccakRng &rhs)
307 {
308 for (size_t i = 0; i < 25; i++)
309 if (lhs.state_[i] != rhs.state_[i])
310 return false;
311 return lhs.opos_ == rhs.opos_ && lhs.bit_rate_ == rhs.bit_rate_;
312 }
314 friend bool
315 operator!= (const KeccakRng &lhs, const KeccakRng &rhs)
316 {
317 return !(lhs == rhs);
318 }
321 min() const
322 {
324 }
327 max() const
328 {
329 return std::numeric_limits<result_type>::max(); // 18446744073709551615
330 }
332 template<typename CharT, typename Traits>
335 {
337 const typename IOS::fmtflags saved_flags = os.flags();
338 os.flags (IOS::dec | IOS::fixed | IOS::left);
339 const CharT space = os.widen (' ');
340 const CharT saved_fill = os.fill();
341 os.fill (space);
342 os << self.opos_;
343 for (size_t i = 0; i < 25; i++)
344 os << space << self.state_[i];
345 os.flags (saved_flags);
346 os.fill (saved_fill);
347 return os;
348 }
350 template<typename CharT, typename Traits>
353 {
355 const typename IOS::fmtflags saved_flags = is.flags();
356 is.flags (IOS::dec | IOS::skipws);
357 is >> self.opos_;
358 self.opos_ = std::min (self.n_nums(), size_t (self.opos_));
359 for (size_t i = 0; i < 25; i++)
360 is >> self.state_[i];
361 is.flags (saved_flags);
362 return is;
363 }
364};
365
370public:
372 explicit KeccakCryptoRng () : KeccakRng (256, 24) { auto_seed(); }
374 template<class SeedSeq>
375 explicit KeccakCryptoRng (SeedSeq &seed_sequence) : KeccakRng (256, 24) { seed (seed_sequence); }
376};
377
384class KeccakGoodRng : public KeccakRng {
385public:
387 explicit KeccakGoodRng () : KeccakRng (192, 13) { auto_seed(); }
389 template<class SeedSeq>
390 explicit KeccakGoodRng (SeedSeq &seed_sequence) : KeccakRng (192, 13) { seed (seed_sequence); }
391};
392
399class KeccakFastRng : public KeccakRng {
400public:
402 explicit KeccakFastRng () : KeccakRng (128, 8) { auto_seed(); }
404 template<class SeedSeq>
405 explicit KeccakFastRng (SeedSeq &seed_sequence) : KeccakRng (128, 8) { seed (seed_sequence); }
406};
407
419class Pcg32Rng {
420 uint64_t increment_; // must be odd, allows for 2^63 distinct random sequences
421 uint64_t accu_; // can contain all 2^64 possible values
422 static constexpr const uint64_t A = 6364136223846793005ULL; // from C. E. Hayness, see TAOCP by D. E. Knuth, 3.3.4, table 1, line 26.
423 static inline constexpr uint32_t
424 ror32 (const uint32_t bits, const uint32_t offset)
425 {
426 // bitwise rotate-right pattern recognized by gcc & clang iff 32==sizeof (bits)
427 return (bits >> offset) | (bits << ((32 - offset) & 31));
428 }
429 static inline constexpr uint32_t
430 pcg_xsh_rr (const uint64_t input)
431 {
432 // Section 6.3.1. 32-bit Output, 64-bit State: PCG-XSH-RR
433 // http://www.pcg-random.org/pdf/toms-oneill-pcg-family-v1.02.pdf
434 return ror32 ((input ^ (input >> 18)) >> 27, input >> 59);
435 }
436public:
438 template<class SeedSeq>
439 explicit Pcg32Rng (SeedSeq &seed_sequence) : increment_ (0), accu_ (0) { seed (seed_sequence); }
441 explicit Pcg32Rng (uint64_t offset, uint64_t sequence);
443 explicit Pcg32Rng ();
445 void auto_seed ();
447 void seed (uint64_t offset, uint64_t sequence);
449 template<class SeedSeq> void
450 seed (SeedSeq &seed_sequence)
451 {
452 uint64_t seeds[2];
453 seed_sequence.generate (&seeds[0], &seeds[2]);
454 seed (seeds[0], seeds[1]);
455 }
459 {
460 const uint64_t lcgout = accu_; // using the *last* state as ouput helps with CPU pipelining
461 accu_ = A * accu_ + increment_;
462 return pcg_xsh_rr (lcgout); // PCG XOR-shift + random rotation
463 }
464};
465
466// == Hashing ==
473template<class Num> static inline constexpr uint64_t
474fnv1a_consthash64 (const Num *ztdata)
475{
476 static_assert (sizeof (Num) <= 1, "");
477 uint64_t hash = 0xcbf29ce484222325;
478 while (ASE_ISLIKELY (*ztdata != 0))
479 hash = 0x100000001b3 * (uint8_t (*ztdata++) ^ hash);
480 return hash;
481}
482
484template<class Num> static inline constexpr uint64_t
485fnv1a_consthash64 (const Num *const data, size_t length)
486{
487 static_assert (sizeof (Num) <= 1, "");
488 uint64_t hash = 0xcbf29ce484222325;
489 for (size_t j = 0; j < length; j++)
490 hash = 0x100000001b3 * (uint8_t (data[j]) ^ hash);
491 return hash;
492}
493
504template<class Num> static ASE_CONST inline uint32_t
505pcg_hash32 (const Num *data, size_t length, uint64_t seed)
506{
507 static_assert (sizeof (Num) <= 1, "");
508 uint64_t h = seed;
509 // Knuth LCG
510 h ^= 0x14057b7ef767814fULL;
511 for (size_t i = 0; ASE_ISLIKELY (i < length); i++)
512 {
513 h -= uint8_t (data[i]);
514 h *= 6364136223846793005ULL;
515 }
516 // based on pcg_detail::xsh_rr_mixin
517 const size_t rsh = h >> 59;
518 const uint32_t xsh = (h ^ (h >> 18)) >> 27;
519 const uint32_t rot = (xsh >> rsh) | (xsh << (32 - rsh));
520 return rot;
521}
522
533template<class Num> static ASE_CONST inline uint64_t
534pcg_hash64 (const Num *data, size_t length, uint64_t seed)
535{
536 static_assert (sizeof (Num) <= 1, "");
537 uint64_t h = seed;
538 // Knuth LCG
539 h ^= 0x14057b7ef767814fULL;
540 for (size_t i = 0; ASE_ISLIKELY (i < length); i++)
541 {
542 h -= uint8_t (data[i]);
543 h *= 6364136223846793005ULL;
544 }
545 // based on pcg_detail::rxs_m_xs_mixin
546 const size_t rsh = h >> 59;
547 const uint64_t rxs = h ^ (h >> (5 + rsh));
548 const uint64_t m = rxs * 12605985483714917081ULL;
549 const uint64_t xs = m ^ (m >> 43);
550 return xs;
551}
552
554static ASE_CONST inline uint64_t
555pcg_hash64 (const char *ztdata, uint64_t seed)
556{
557 uint64_t h = seed;
558 // Knuth LCG
559 h ^= 0x14057b7ef767814fULL;
560 for (size_t i = 0; ASE_ISLIKELY (ztdata[i] != 0); i++)
561 {
562 h -= uint8_t (ztdata[i]);
563 h *= 6364136223846793005ULL;
564 }
565 // based on pcg_detail::rxs_m_xs_mixin
566 const size_t rsh = h >> 59;
567 const uint64_t rxs = h ^ (h >> (5 + rsh));
568 const uint64_t m = rxs * 12605985483714917081ULL;
569 const uint64_t xs = m ^ (m >> 43);
570 return xs;
571}
572
574
576static ASE_PURE inline uint64_t
577hash_secret ()
578{
581 return cached_hash_secret;
582}
583
585template<class Num> static ASE_CONST inline uint64_t
586byte_hash64 (const Num *data, size_t length)
587{
588 static_assert (sizeof (Num) <= 1, "");
589 return pcg_hash64 (data, length, hash_secret());
590}
591
593static ASE_CONST inline uint64_t
594string_hash64 (const std::string &string)
595{
596 return pcg_hash64 (string.data(), string.size(), hash_secret());
597}
598
600static ASE_CONST inline uint64_t
601string_hash64 (const char *ztdata)
602{
603 return pcg_hash64 (ztdata, hash_secret());
604}
605
606} // Ase
607
AutoSeeder provides non-deterministic seeding entropy.
uint64 operator()() const
Generate non-deterministic 64bit random value.
void generate(RandomAccessIterator begin, RandomAccessIterator end)
Fill the range [begin, end) with random unsigned integer values.
static uint64 random()
Generate non-deterministic 64bit random value.
KeccakCryptoRng - A KeccakF1600 based cryptographic quality pseudo-random number generator.
KeccakCryptoRng(SeedSeq &seed_sequence)
Initialize and seed the generator from seed_sequence.
KeccakCryptoRng()
Initialize and seed the generator from a system specific nondeterministic random source.
KeccakFastRng - A KeccakF1600 based fast pseudo-random number generator.
KeccakFastRng()
Initialize and seed the generator from a system specific nondeterministic random source.
KeccakFastRng(SeedSeq &seed_sequence)
Initialize and seed the generator from seed_sequence.
KeccakGoodRng - A KeccakF1600 based good quality pseudo-random number generator.
KeccakGoodRng(SeedSeq &seed_sequence)
Initialize and seed the generator from seed_sequence.
KeccakGoodRng()
Initialize and seed the generator from a system specific nondeterministic random source.
KeccakRng - A KeccakF1600 based pseudo-random number generator.
void seed(const uint64_t *seeds, size_t n_seeds)
Reinitialize the generator state using a nuber of 64 bit seeds.
uint64_t result_type
Integral type of the KeccakRng generator results.
KeccakRng(uint16_t hidden_state_capacity, uint16_t n_rounds)
Create an unseeded Keccak PRNG with specific capacity and number of rounds, for experts only.
void generate(RandomAccessIterator begin, RandomAccessIterator end)
Fill the range [begin, end) with random unsigned integer values.
friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const KeccakRng &self)
Serialize generator state into an OStream.
result_type operator()()
Generate uniformly distributed 32 bit pseudo random number.
size_t bit_capacity() const
Amount of bits used to store hidden random number generator state.
uint64_t random()
Generate uniformly distributed 64 bit pseudo random number.
void forget()
Discard 2^256 bits of the current generator state.
void auto_seed()
Seed the generator from a system specific nondeterministic random source.
void discard(unsigned long long count)
Discard count consecutive random values.
void seed(uint64_t seed_value=1)
Reinitialize the generator state using a 64 bit seed_value.
friend bool operator!=(const KeccakRng &lhs, const KeccakRng &rhs)
Compare two generators for state inequality.
size_t n_nums() const
Amount of 64 bit random numbers per generated block.
result_type min() const
Minimum of the result type, for uint64_t that is 0.
void seed(SeedSeq &seed_sequence)
Seed the generator state from a seed_sequence.
void xor_seed(const uint64_t *seeds, size_t n_seeds)
Incorporate seed_values into the current generator state.
friend bool operator==(const KeccakRng &lhs, const KeccakRng &rhs)
Compare two generators for state equality.
~KeccakRng()
The destructor resets the generator state to avoid leaving memory trails.
result_type max() const
Maximum of the result type, for uint64_t that is 18446744073709551615.
friend std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &is, KeccakRng &self)
Deserialize generator state from an IStream.
Marsaglia multiply-with-carry generator, period ca 2^255.
Definition randomhash.hh:36
Pcg32Rng is a permutating linear congruential PRNG.
Pcg32Rng(SeedSeq &seed_sequence)
Initialize and seed from seed_sequence.
void auto_seed()
Seed the generator from a system specific nondeterministic random source.
uint32_t random()
Generate uniformly distributed 32 bit pseudo random number.
Pcg32Rng()
Initialize and seed the generator from a system specific nondeterministic random source.
void seed(SeedSeq &seed_sequence)
Seed the generator state from a seed_sequence.
void seed(uint64_t offset, uint64_t sequence)
Seed by seeking to position offset within stream sequence.
#define ASE_ASSERT_RETURN(expr,...)
Return from the current function if expr evaluates to false and issue an assertion warning.
Definition cxxaux.hh:81
#define ASE_UNLIKELY(expr)
Compiler hint to optimize for expr evaluating to false.
Definition cxxaux.hh:45
#define ASE_ISLIKELY(expr)
Compiler hint to optimize for expr evaluating to true.
Definition cxxaux.hh:44
T data(T... args)
T max(T... args)
T min(T... args)
The Anklang C++ API namespace.
Definition api.hh:8
void sha3_224_hash(const void *data, size_t data_length, uint8_t hashvalue[28])
Calculate 224 bit SHA3 digest from data, see also class SHA3_224.
uint64_t uint64
A 64-bit unsigned integer, use PRI*64 in format strings.
Definition cxxaux.hh:24
void shake256_hash(const void *data, size_t data_length, uint8_t *hashvalues, size_t n)
Calculate SHA3 extendable output digest for 256 bit security strength, see also class SHAKE256.
void sha3_384_hash(const void *data, size_t data_length, uint8_t hashvalue[48])
Calculate 384 bit SHA3 digest from data, see also class SHA3_384.
uint64_t cached_hash_secret
Use hash_secret() for access.
void sha3_256_hash(const void *data, size_t data_length, uint8_t hashvalue[32])
Calculate 256 bit SHA3 digest from data, see also class SHA3_256.
int64_t random_irange(int64_t begin, int64_t end)
Generate uniformly distributed pseudo-random integer within range.
void sha3_512_hash(const void *data, size_t data_length, uint8_t hashvalue[64])
Calculate 512 bit SHA3 digest from data, see also class SHA3_512.
uint64_t random_nonce()
Provide a unique 64 bit identifier that is not 0, see also random_int64().
void shake128_hash(const void *data, size_t data_length, uint8_t *hashvalues, size_t n)
Calculate SHA3 extendable output digest for 128 bit security strength, see also class SHAKE128.
double random_float()
Generate uniformly distributed pseudo-random floating point number.
double random_frange(double begin, double end)
Generate uniformly distributed pseudo-random floating point number within a range.
uint64_t random_int64()
Generate a non-deterministic, uniformly distributed 64 bit pseudo-random number.
void random_secret(uint64_t *secret_var)
Generate a secret non-zero nonce in secret_var, unless it has already been assigned.
Helper to provide memory for placement new AlignedPOD<SIZE> is aligned like max_align_t or like mallo...
Definition randomhash.hh:18
size_t hash(size_t seed, const T &v)
T size(T... args)
typedef uint64_t
SHA3_224 - 224 Bit digest generation.
Definition randomhash.hh:68
SHA3_224()
Create context to calculate a 224 bit SHA3 hash digest.
void update(const uint8_t *data, size_t length)
Feed data to be hashed.
void digest(uint8_t hashvalue[28])
Retrieve the resulting hash value.
void reset()
Reset state to feed and retrieve a new hash value.
SHA3_256 - 256 Bit digest generation.
Definition randomhash.hh:86
SHA3_256()
Create context to calculate a 256 bit SHA3 hash digest.
void update(const uint8_t *data, size_t length)
Feed data to be hashed.
void digest(uint8_t hashvalue[32])
Retrieve the resulting hash value.
void reset()
Reset state to feed and retrieve a new hash value.
SHA3_384 - 384 Bit digest generation.
void reset()
Reset state to feed and retrieve a new hash value.
SHA3_384()
Create context to calculate a 384 bit SHA3 hash digest.
void update(const uint8_t *data, size_t length)
Feed data to be hashed.
void digest(uint8_t hashvalue[48])
Retrieve the resulting hash value.
SHA3_512 - 512 Bit digest generation.
void digest(uint8_t hashvalue[64])
Retrieve the resulting hash value.
SHA3_512()
Create context to calculate a 512 bit SHA3 hash digest.
void update(const uint8_t *data, size_t length)
Feed data to be hashed.
void reset()
Reset state to feed and retrieve a new hash value.
SHAKE128 - 128 Bit extendable output digest generation.
SHAKE128()
Create context to calculate an unbounded SHAKE128 hash digest.
void update(const uint8_t *data, size_t length)
Feed data to be hashed.
void reset()
Reset state to feed and retrieve a new hash value.
void squeeze_digest(uint8_t *hashvalues, size_t n)
Retrieve an arbitrary number of hash value bytes.
SHAKE256 - 256 Bit extendable output digest generation.
void reset()
Reset state to feed and retrieve a new hash value.
SHAKE256()
Create context to calculate an unbounded SHAKE256 hash digest.
void update(const uint8_t *data, size_t length)
Feed data to be hashed.
void squeeze_digest(uint8_t *hashvalues, size_t n)
Retrieve an arbitrary number of hash value bytes.
Value type used to interface with various property types.
Definition value.hh:53
typedef size_t