hash_drbg.c
Go to the documentation of this file.
1 /**
2  * @file hash_drbg.c
3  * @brief Hash_DRBG pseudorandom number generator
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.5.4
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
33 
34 //Dependencies
35 #include "core/crypto.h"
36 #include "rng/hash_drbg.h"
37 #include "debug.h"
38 
39 //Check crypto library configuration
40 #if (HASH_DRBG_SUPPORT == ENABLED)
41 
42 //Common interface for PRNG algorithms
44 {
45  "Hash_DRBG",
46  sizeof(HashDrbgContext),
47  (PrngAlgoInit) NULL,
52 };
53 
54 
55 /**
56  * @brief Initialize PRNG context
57  * @param[in] context Pointer to the Hash_DRBG context to initialize
58  * @param[in] hashAlgo Approved hash function
59  * @return Error code
60  **/
61 
62 error_t hashDrbgInit(HashDrbgContext *context, const HashAlgo *hashAlgo)
63 {
64  //Check parameters
65  if(context == NULL || hashAlgo == NULL)
67 
68  //Clear the internal state
69  osMemset(context, 0, sizeof(HashDrbgContext));
70 
71  //Create a mutex to prevent simultaneous access to the PRNG state
72  if(!osCreateMutex(&context->mutex))
73  {
74  //Failed to create mutex
76  }
77 
78  //The Hash_DRBG requires the use of a hash function during the instantiate,
79  //reseed and generate functions. The same hash function shall be used
80  //throughout a Hash_DRBG instantiation
81  context->hashAlgo = hashAlgo;
82 
83  //Determine the security strength (refer to SP 800-57, section 5.6.1.2)
84  if(hashAlgo->digestSize <= 20)
85  {
86  context->securityStrength = 16;
87  }
88  else if(hashAlgo->digestSize <= 28)
89  {
90  context->securityStrength = 24;
91  }
92  else
93  {
94  context->securityStrength = 32;
95  }
96 
97  //Determine the seed length (refer to SP 800-90A, section 10.1)
98  if(hashAlgo->digestSize <= 32)
99  {
100  context->seedLen = 55;
101  }
102  else
103  {
104  context->seedLen = 111;
105  }
106 
107  //Successful initialization
108  return NO_ERROR;
109 }
110 
111 
112 /**
113  * @brief Seed the PRNG state
114  * @param[in] context Pointer to the Hash_DRBG context
115  * @param[in] seed String of bits obtained from the randomness source
116  * @param[in] length Length of the string, in bytes
117  * @return Error code
118  **/
119 
120 error_t hashDrbgSeed(HashDrbgContext *context, const uint8_t *seed,
121  size_t length)
122 {
123  //Seeding process
124  return hashDrbgSeedEx(context, seed, length, NULL, 0, NULL, 0);
125 }
126 
127 
128 /**
129  * @brief Seed the PRNG state (with nonce and personalization string)
130  * @param[in] context Pointer to the Hash_DRBG context
131  * @param[in] entropyInput String of bits obtained from the randomness source
132  * @param[in] entropyInputLen Length of the string, in bytes
133  * @param[in] nonce Nonce
134  * @param[in] nonceLen Length of the nonce, in bytes
135  * @param[in] personalizationString Personalization string received from the
136  * consuming application
137  * @param[in] personalizationStringLen Length of the personalization string,
138  * in bytes
139  * @return Error code
140  **/
141 
142 error_t hashDrbgSeedEx(HashDrbgContext *context, const uint8_t *entropyInput,
143  size_t entropyInputLen, const uint8_t *nonce, size_t nonceLen,
144  const uint8_t *personalizationString, size_t personalizationStringLen)
145 {
146  uint8_t k;
147  DataChunk input[3];
148 
149  //Check parameters
150  if(context == NULL || entropyInput == NULL)
152 
153  //The nonce parameter is optional
154  if(nonce == NULL && nonceLen != 0)
156 
157  //The personalization_string parameter is optional
158  if(personalizationString == NULL && personalizationStringLen != 0)
160 
161  //The Hash_DRBG requires the use of a hash function during the instantiate,
162  //reseed and generate functions. The same hash function shall be used
163  //throughout a Hash_DRBG instantiation
164  if(context->hashAlgo == NULL)
165  return ERROR_PRNG_NOT_READY;
166 
167  //The entropy input shall have entropy that is equal to or greater than the
168  //security strength of the instantiation
169  if(entropyInputLen < context->securityStrength)
171 
172  //If an implementation utilizes a nonce in the construction of a seed during
173  //instantiation, the length of the nonce shall be at least half the maximum
174  //security strength supported. Per allowances in SP 800-90A, the length of a
175  //nonce may be less than 1/2 the maximum security strength supported as long
176  //as the entropy input length + the nonce length >= 3/2 security strength
177  if((entropyInputLen + nonceLen) < (3 * context->securityStrength / 2))
179 
180  //Acquire exclusive access to the PRNG state
181  osAcquireMutex(&context->mutex);
182 
183  //Let seed_material = entropy_input || nonce || personalization_string
184  input[0].buffer = entropyInput;
185  input[0].length = entropyInputLen;
186  input[1].buffer = nonce;
187  input[1].length = nonceLen;
188  input[2].buffer = personalizationString;
189  input[2].length = personalizationStringLen;
190 
191  //Compute V = Hash_df(seed_material, seedlen)
192  hashDf(context, input, 3, context->v, context->seedLen);
193 
194  //Constant byte 0x00
195  k = 0;
196 
197  //Precede V with a byte of zeros
198  input[0].buffer = &k;
199  input[0].length = sizeof(k);
200  input[1].buffer = context->v;
201  input[1].length = context->seedLen;
202 
203  //Compute C = Hash_df((0x00 || V), seedlen)
204  hashDf(context, input, 2, context->c, context->seedLen);
205 
206  //Reset reseed_counter
207  context->reseedCounter = 1;
208 
209  //Release exclusive access to the PRNG state
210  osReleaseMutex(&context->mutex);
211 
212  //Successful processing
213  return NO_ERROR;
214 }
215 
216 
217 /**
218  * @brief Reseed the PRNG state
219  * @param[in] context Pointer to the Hash_DRBG context
220  * @param[in] seed String of bits obtained from the randomness source
221  * @param[in] length Length of the string, in bytes
222  * @return Error code
223  **/
224 
225 error_t hashDrbgReseed(HashDrbgContext *context, const uint8_t *seed,
226  size_t length)
227 {
228  //Reseeding process
229  return hashDrbgReseedEx(context, seed, length, NULL, 0);
230 }
231 
232 
233 /**
234  * @brief Reseed the PRNG state (with additional input)
235  * @param[in] context Pointer to the Hash_DRBG context
236  * @param[in] entropyInput String of bits obtained from the randomness source
237  * @param[in] entropyInputLen Length of the string, in bytes
238  * @param[in] additionalInput Additional input string received from the
239  * consuming application
240  * @param[in] additionalInputLen Length of the additional input string, in bytes
241  * @return Error code
242  **/
243 
244 error_t hashDrbgReseedEx(HashDrbgContext *context, const uint8_t *entropyInput,
245  size_t entropyInputLen, const uint8_t *additionalInput,
246  size_t additionalInputLen)
247 {
248  uint8_t k;
249  DataChunk input[4];
250  uint8_t seed[HASH_DRBG_MAX_SEED_LEN];
251 
252  //Check parameters
253  if(context == NULL || entropyInput == NULL)
255 
256  //The additional_input parameter is optional
257  if(additionalInput == NULL && additionalInputLen != 0)
259 
260  //The Hash_DRBG requires the use of a hash function during the instantiate,
261  //reseed and generate functions. The same hash function shall be used
262  //throughout a Hash_DRBG instantiation
263  if(context->hashAlgo == NULL)
264  return ERROR_PRNG_NOT_READY;
265 
266  //Check whether the DRBG has been properly instantiated
267  if(context->reseedCounter == 0)
268  return ERROR_PRNG_NOT_READY;
269 
270  //The entropy input shall have entropy that is equal to or greater than the
271  //security strength of the instantiation
272  if(entropyInputLen < context->securityStrength)
274 
275  //Acquire exclusive access to the PRNG state
276  osAcquireMutex(&context->mutex);
277 
278  //Constant byte 0x01
279  k = 1;
280 
281  //Let seed_material = 0x01 || V || entropy_input || additional_input
282  input[0].buffer = &k;
283  input[0].length = sizeof(k);
284  input[1].buffer = context->v;
285  input[1].length = context->seedLen;
286  input[2].buffer = entropyInput;
287  input[2].length = entropyInputLen;
288  input[3].buffer = additionalInput;
289  input[3].length = additionalInputLen;
290 
291  //Compute seed = Hash_df(seed_material, seedlen)
292  hashDf(context, input, 4, seed, context->seedLen);
293  //Set V = seed
294  osMemcpy(context->v, seed, context->seedLen);
295 
296  //Constant byte 0x00
297  k = 0;
298 
299  //Precede V with a byte of zeros
300  input[0].buffer = &k;
301  input[0].length = sizeof(k);
302  input[1].buffer = context->v;
303  input[1].length = context->seedLen;
304 
305  //Compute C = Hash_df((0x00 || V), seedlen)
306  hashDf(context, input, 2, context->c, context->seedLen);
307 
308  //Reset reseed_counter
309  context->reseedCounter = 1;
310 
311  //Release exclusive access to the PRNG state
312  osReleaseMutex(&context->mutex);
313 
314  //Successful processing
315  return NO_ERROR;
316 }
317 
318 
319 /**
320  * @brief Generate pseudorandom data
321  * @param[in] context Pointer to the Hash_DRBG context
322  * @param[out] output Buffer where to store the pseudorandom bytes
323  * @param[in] length Requested number of bytes
324  * @return Error code
325  **/
326 
327 error_t hashDrbgGenerate(HashDrbgContext *context, uint8_t *output,
328  size_t length)
329 {
330  //Generation process
331  return hashDrbgGenerateEx(context, NULL, 0, output, length);
332 }
333 
334 
335 /**
336  * @brief Generate pseudorandom data (with additional input)
337  * @param[in] context Pointer to the Hash_DRBG context
338  * @param[in] additionalInput Additional input string received from the
339  * consuming application
340  * @param[in] additionalInputLen Length of the additional input string, in bytes
341  * @param[out] output Buffer where to store the pseudorandom bytes
342  * @param[in] outputLen Requested number of bytes
343  * @return Error code
344  **/
345 
347  const uint8_t *additionalInput, size_t additionalInputLen, uint8_t *output,
348  size_t outputLen)
349 {
350  uint8_t k;
351  uint8_t buffer[8];
352  uint8_t t[HASH_DRBG_MAX_SEED_LEN];
353  const HashAlgo *hashAlgo;
354  HashContext *hashContext;
355 
356  //Check parameters
357  if(context == NULL)
359 
360  //The additional_input parameter is optional
361  if(additionalInput == NULL && additionalInputLen != 0)
363 
364  //The Hash_DRBG requires the use of a hash function during the instantiate,
365  //reseed and generate functions. The same hash function shall be used
366  //throughout a Hash_DRBG instantiation
367  if(context->hashAlgo == NULL)
368  return ERROR_PRNG_NOT_READY;
369 
370  //A DRBG shall be instantiated prior to the generation of pseudorandom bits
371  if(context->reseedCounter == 0)
372  return ERROR_PRNG_NOT_READY;
373 
374  //If reseed_counter > reseed_interval, then return an indication that a
375  //reseed is required
377  return ERROR_RESEED_REQUIRED;
378 
379  //Acquire exclusive access to the PRNG state
380  osAcquireMutex(&context->mutex);
381 
382  //The Hash_DRBG requires the use of a hash function
383  hashAlgo = context->hashAlgo;
384  //Point to the hash context
385  hashContext = &context->hashContext;
386 
387  //The length of the additional input string may be zero
388  if(additionalInputLen > 0)
389  {
390  //Constant byte 0x02
391  k = 2;
392 
393  //Compute w = Hash(0x02 || V || additional_input)
394  hashAlgo->init(hashContext);
395  hashAlgo->update(hashContext, &k, sizeof(k));
396  hashAlgo->update(hashContext, context->v, context->seedLen);
397  hashAlgo->update(hashContext, additionalInput, additionalInputLen);
398  hashAlgo->final(hashContext, t);
399 
400  //Compute V = (V + w) mod 2^seedlen
401  hashDrbgAdd(context->v, context->seedLen, t, hashAlgo->digestSize);
402  }
403 
404  //Compute Hashgen(requested_number_of_bits, V)
405  hashGen(context, output, outputLen);
406 
407  //Constant byte 0x03
408  k = 3;
409 
410  //Compute H = Hash(0x03 || V)
411  hashAlgo->init(hashContext);
412  hashAlgo->update(hashContext, &k, sizeof(k));
413  hashAlgo->update(hashContext, context->v, context->seedLen);
414  hashAlgo->final(hashContext, t);
415 
416  //Format reseed_counter as a 64-bit string
417  STORE64BE(context->reseedCounter, buffer);
418 
419  //Compute V = (V + H + C + reseed_counter) mod 2^seedlen
420  hashDrbgAdd(context->v, context->seedLen, t, hashAlgo->digestSize);
421  hashDrbgAdd(context->v, context->seedLen, context->c, context->seedLen);
422  hashDrbgAdd(context->v, context->seedLen, buffer, sizeof(buffer));
423 
424  //Increment reseed_counter
425  context->reseedCounter++;
426 
427  //Release exclusive access to the PRNG state
428  osReleaseMutex(&context->mutex);
429 
430  //Successful processing
431  return NO_ERROR;
432 }
433 
434 
435 /**
436  * @brief Release PRNG context
437  * @param[in] context Pointer to the Hash_DRBG context
438  **/
439 
441 {
442  //Valid Hash_DRBG context?
443  if(context != NULL)
444  {
445  //Free previously allocated resources
446  osDeleteMutex(&context->mutex);
447 
448  //Erase the contents of the internal state
449  osMemset(context, 0, sizeof(HashDrbgContext));
450  }
451 }
452 
453 
454 /**
455  * @brief Hash derivation function
456  * @param[in] context Pointer to the Hash_DRBG context
457  * @param[in] input The string to be hashed
458  * @param[in] inputLen Number of data chunks representing the input
459  * @param[out] output Buffer where to store the output value
460  * @param[out] outputLen The number of bytes to be returned
461  **/
462 
463 void hashDf(HashDrbgContext *context, const DataChunk *input, uint_t inputLen,
464  uint8_t *output, size_t outputLen)
465 {
466  size_t i;
467  size_t n;
468  uint8_t counter;
469  uint8_t buffer[4];
470  uint8_t digest[MAX_HASH_DIGEST_SIZE];
471  const HashAlgo *hashAlgo;
472  HashContext *hashContext;
473 
474  //The Hash_DRBG requires the use of a hash function
475  hashAlgo = context->hashAlgo;
476  //Point to the hash context
477  hashContext = &context->hashContext;
478 
479  //Format no_of_bits_to_return as a 32-bit string
480  STORE32BE(outputLen * 8, buffer);
481 
482  //Generate the requested number of bytes
483  for(counter = 1; outputLen > 0; counter++)
484  {
485  //Number of bytes to generate at a time
486  n = MIN(outputLen, hashAlgo->digestSize);
487 
488  //Compute Hash (counter || no_of_bits_to_return || input_string)
489  hashAlgo->init(hashContext);
490  hashAlgo->update(hashContext, &counter, sizeof(counter));
491  hashAlgo->update(hashContext, buffer, sizeof(buffer));
492 
493  for(i = 0; i < inputLen; i++)
494  {
495  hashAlgo->update(hashContext, input[i].buffer, input[i].length);
496  }
497 
498  hashAlgo->final(hashContext, digest);
499 
500  //Copy data to the output buffer
501  osMemcpy(output, digest, n);
502 
503  //Next output block
504  output += n;
505  outputLen -= n;
506  }
507 }
508 
509 
510 /**
511  * @brief Hash generation sub function
512  * @param[in] context Pointer to the Hash_DRBG context
513  * @param[out] output Buffer where to store the output value
514  * @param[out] outputLen The number of bytes to be returned
515  **/
516 
517 void hashGen(HashDrbgContext *context, uint8_t *output, size_t outputLen)
518 {
519  size_t n;
520  uint8_t data[HASH_DRBG_MAX_SEED_LEN];
521  uint8_t w[MAX_HASH_DIGEST_SIZE];
522  const HashAlgo *hashAlgo;
523  HashContext *hashContext;
524 
525  //The Hash_DRBG requires the use of a hash function
526  hashAlgo = context->hashAlgo;
527  //Point to the hash context
528  hashContext = &context->hashContext;
529 
530  //Let data = V
531  osMemcpy(data, context->v, context->seedLen);
532 
533  //Generate the requested number of bytes
534  while(outputLen > 0)
535  {
536  //Number of bytes to generate at a time
537  n = MIN(outputLen, hashAlgo->digestSize);
538 
539  //Compute w = Hash(data)
540  hashAlgo->init(hashContext);
541  hashAlgo->update(hashContext, data, context->seedLen);
542  hashAlgo->final(hashContext, w);
543 
544  //Copy data to the output buffer
545  osMemcpy(output, w, n);
546 
547  //Compute data = (data + 1) mod 2^seedlen
548  hashDrbgInc(data, context->seedLen);
549 
550  //Next output block
551  output += n;
552  outputLen -= n;
553  }
554 }
555 
556 
557 /**
558  * @brief Add blocks
559  * @param[in,out] a Pointer to the first block
560  * @param[in] aLen Length of the first block, in bytes
561  * @param[in] b Pointer to the second block
562  * @param[in] bLen Length of the second block, in bytes
563  **/
564 
565 void hashDrbgAdd(uint8_t *a, size_t aLen, const uint8_t *b, size_t bLen)
566 {
567  size_t i;
568  uint16_t temp;
569 
570  //Compute A = A + B
571  for(temp = 0, i = 1; i <= aLen; i++)
572  {
573  //Add the current bytes and propagate the carry
574  temp += a[aLen - i];
575  temp += (i <= bLen) ? b[bLen - i] : 0;
576  a[aLen - i] = temp & 0xFF;
577  temp >>= 8;
578  }
579 }
580 
581 
582 /**
583  * @brief Increment block
584  * @param[in] a Pointer to the block to be incremented
585  * @param[in] aLen Length of the block, in bytes
586  **/
587 
588 void hashDrbgInc(uint8_t *a, size_t aLen)
589 {
590  size_t i;
591  uint16_t temp;
592 
593  //Compute A = A + 1
594  for(temp = 1, i = 1; i <= aLen; i++)
595  {
596  //Increment the current byte and propagate the carry
597  temp += a[aLen - i];
598  a[aLen - i] = temp & 0xFF;
599  temp >>= 8;
600  }
601 }
602 
603 #endif
HashAlgoInit init
Definition: crypto.h:1134
Generic hash algorithm context.
error_t hashDrbgSeed(HashDrbgContext *context, const uint8_t *seed, size_t length)
Seed the PRNG state.
Definition: hash_drbg.c:120
uint8_t b
Definition: nbns_common.h:122
bool_t osCreateMutex(OsMutex *mutex)
Create a mutex object.
HashContext hashContext
Hash context.
Definition: hash_drbg.h:60
uint8_t a
Definition: ndp.h:411
error_t hashDrbgReseedEx(HashDrbgContext *context, const uint8_t *entropyInput, size_t entropyInputLen, const uint8_t *additionalInput, size_t additionalInputLen)
Reseed the PRNG state (with additional input)
Definition: hash_drbg.c:244
#define PrngAlgo
Definition: crypto.h:1008
error_t hashDrbgGenerateEx(HashDrbgContext *context, const uint8_t *additionalInput, size_t additionalInputLen, uint8_t *output, size_t outputLen)
Generate pseudorandom data (with additional input)
Definition: hash_drbg.c:346
uint8_t t
Definition: lldp_ext_med.h:212
uint8_t data[]
Definition: ethernet.h:224
size_t digestSize
Definition: crypto.h:1130
const void * buffer
Definition: crypto.h:1053
uint64_t reseedCounter
Reseed counter.
Definition: hash_drbg.h:65
@ ERROR_OUT_OF_RESOURCES
Definition: error.h:64
HashAlgoUpdate update
Definition: crypto.h:1135
error_t(* PrngAlgoSeed)(void *context, const uint8_t *seed, size_t length)
Definition: crypto.h:1107
void hashDf(HashDrbgContext *context, const DataChunk *input, uint_t inputLen, uint8_t *output, size_t outputLen)
Hash derivation function.
Definition: hash_drbg.c:463
void hashDrbgAdd(uint8_t *a, size_t aLen, const uint8_t *b, size_t bLen)
Add blocks.
Definition: hash_drbg.c:565
error_t(* PrngAlgoReseed)(void *context, const uint8_t *seed, size_t length)
Definition: crypto.h:1110
uint8_t c[HASH_DRBG_MAX_SEED_LEN]
Constant C.
Definition: hash_drbg.h:64
@ ERROR_PRNG_NOT_READY
Definition: error.h:252
OsMutex mutex
Mutex preventing simultaneous access to the PRNG state.
Definition: hash_drbg.h:58
const PrngAlgo hashDrbgPrngAlgo
Definition: hash_drbg.c:43
#define MAX_HASH_DIGEST_SIZE
@ ERROR_INVALID_PARAMETER
Invalid parameter.
Definition: error.h:47
#define osMemcpy(dest, src, length)
Definition: os_port.h:144
Hash_DRBG pseudorandom number generator.
error_t
Error codes.
Definition: error.h:43
const HashAlgo * hashAlgo
Hash function.
Definition: hash_drbg.h:59
@ ERROR_RESEED_REQUIRED
Definition: error.h:312
General definitions for cryptographic algorithms.
#define HASH_DRBG_MAX_SEED_LEN
Definition: hash_drbg.h:39
void hashDrbgDeinit(HashDrbgContext *context)
Release PRNG context.
Definition: hash_drbg.c:440
uint8_t length
Definition: tcp.h:375
#define MIN(a, b)
Definition: os_port.h:63
size_t seedLen
Seed length.
Definition: hash_drbg.h:62
size_t securityStrength
Security strength.
Definition: hash_drbg.h:61
error_t hashDrbgInit(HashDrbgContext *context, const HashAlgo *hashAlgo)
Initialize PRNG context.
Definition: hash_drbg.c:62
HashAlgoFinal final
Definition: crypto.h:1136
Data chunk descriptor.
Definition: crypto.h:1052
void hashGen(HashDrbgContext *context, uint8_t *output, size_t outputLen)
Hash generation sub function.
Definition: hash_drbg.c:517
void(* PrngAlgoDeinit)(void *context)
Definition: crypto.h:1116
error_t hashDrbgGenerate(HashDrbgContext *context, uint8_t *output, size_t length)
Generate pseudorandom data.
Definition: hash_drbg.c:327
#define STORE64BE(a, p)
Definition: cpu_endian.h:322
error_t hashDrbgSeedEx(HashDrbgContext *context, const uint8_t *entropyInput, size_t entropyInputLen, const uint8_t *nonce, size_t nonceLen, const uint8_t *personalizationString, size_t personalizationStringLen)
Seed the PRNG state (with nonce and personalization string)
Definition: hash_drbg.c:142
void osDeleteMutex(OsMutex *mutex)
Delete a mutex object.
uint8_t v[HASH_DRBG_MAX_SEED_LEN]
Value V.
Definition: hash_drbg.h:63
uint8_t n
#define HASH_DRBG_MAX_RESEED_INTERVAL
Definition: hash_drbg.h:41
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
error_t(* PrngAlgoGenerate)(void *context, uint8_t *output, size_t length)
Definition: crypto.h:1113
size_t length
Definition: crypto.h:1054
void hashDrbgInc(uint8_t *a, size_t aLen)
Increment block.
Definition: hash_drbg.c:588
Hash_DRBG PRNG context.
Definition: hash_drbg.h:57
Common interface for hash algorithms.
Definition: crypto.h:1124
unsigned int uint_t
Definition: compiler_port.h:57
#define osMemset(p, value, length)
Definition: os_port.h:138
error_t(* PrngAlgoInit)(void *context)
Definition: crypto.h:1105
error_t hashDrbgReseed(HashDrbgContext *context, const uint8_t *seed, size_t length)
Reseed the PRNG state.
Definition: hash_drbg.c:225
#define STORE32BE(a, p)
Definition: cpu_endian.h:286
uint8_t nonce[]
Definition: ntp_common.h:239
@ NO_ERROR
Success.
Definition: error.h:44
Debugging facilities.