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-2026 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.6.6
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  DataFrag inputFrags[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  inputFrags[0].buffer = entropyInput;
185  inputFrags[0].length = entropyInputLen;
186  inputFrags[1].buffer = nonce;
187  inputFrags[1].length = nonceLen;
188  inputFrags[2].buffer = personalizationString;
189  inputFrags[2].length = personalizationStringLen;
190 
191  //Compute V = Hash_df(seed_material, seedlen)
192  hashDf(context, inputFrags, 3, context->v, context->seedLen);
193 
194  //Constant byte 0x00
195  k = 0;
196 
197  //Precede V with a byte of zeros
198  inputFrags[0].buffer = &k;
199  inputFrags[0].length = sizeof(k);
200  inputFrags[1].buffer = context->v;
201  inputFrags[1].length = context->seedLen;
202 
203  //Compute C = Hash_df((0x00 || V), seedlen)
204  hashDf(context, inputFrags, 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  DataFrag inputFrags[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  inputFrags[0].buffer = &k;
283  inputFrags[0].length = sizeof(k);
284  inputFrags[1].buffer = context->v;
285  inputFrags[1].length = context->seedLen;
286  inputFrags[2].buffer = entropyInput;
287  inputFrags[2].length = entropyInputLen;
288  inputFrags[3].buffer = additionalInput;
289  inputFrags[3].length = additionalInputLen;
290 
291  //Compute seed = Hash_df(seed_material, seedlen)
292  hashDf(context, inputFrags, 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  inputFrags[0].buffer = &k;
301  inputFrags[0].length = sizeof(k);
302  inputFrags[1].buffer = context->v;
303  inputFrags[1].length = context->seedLen;
304 
305  //Compute C = Hash_df((0x00 || V), seedlen)
306  hashDf(context, inputFrags, 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] inputFrags Array of fragments representing the string to be hashed
458  * @param[in] inputNumFrags Number of fragments representing the input string
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 DataFrag *inputFrags,
464  uint_t inputNumFrags, 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 < inputNumFrags; i++)
494  {
495  hashAlgo->update(hashContext, inputFrags[i].buffer,
496  inputFrags[i].length);
497  }
498 
499  hashAlgo->final(hashContext, digest);
500 
501  //Copy data to the output buffer
502  osMemcpy(output, digest, n);
503 
504  //Next output block
505  output += n;
506  outputLen -= n;
507  }
508 }
509 
510 
511 /**
512  * @brief Hash generation sub function
513  * @param[in] context Pointer to the Hash_DRBG context
514  * @param[out] output Buffer where to store the output value
515  * @param[out] outputLen The number of bytes to be returned
516  **/
517 
518 void hashGen(HashDrbgContext *context, uint8_t *output, size_t outputLen)
519 {
520  size_t n;
521  uint8_t data[HASH_DRBG_MAX_SEED_LEN];
522  uint8_t w[MAX_HASH_DIGEST_SIZE];
523  const HashAlgo *hashAlgo;
524  HashContext *hashContext;
525 
526  //The Hash_DRBG requires the use of a hash function
527  hashAlgo = context->hashAlgo;
528  //Point to the hash context
529  hashContext = &context->hashContext;
530 
531  //Let data = V
532  osMemcpy(data, context->v, context->seedLen);
533 
534  //Generate the requested number of bytes
535  while(outputLen > 0)
536  {
537  //Number of bytes to generate at a time
538  n = MIN(outputLen, hashAlgo->digestSize);
539 
540  //Compute w = Hash(data)
541  hashAlgo->init(hashContext);
542  hashAlgo->update(hashContext, data, context->seedLen);
543  hashAlgo->final(hashContext, w);
544 
545  //Copy data to the output buffer
546  osMemcpy(output, w, n);
547 
548  //Compute data = (data + 1) mod 2^seedlen
549  hashDrbgInc(data, context->seedLen);
550 
551  //Next output block
552  output += n;
553  outputLen -= n;
554  }
555 }
556 
557 
558 /**
559  * @brief Add blocks
560  * @param[in,out] a Pointer to the first block
561  * @param[in] aLen Length of the first block, in bytes
562  * @param[in] b Pointer to the second block
563  * @param[in] bLen Length of the second block, in bytes
564  **/
565 
566 void hashDrbgAdd(uint8_t *a, size_t aLen, const uint8_t *b, size_t bLen)
567 {
568  size_t i;
569  uint16_t temp;
570 
571  //Compute A = A + B
572  for(temp = 0, i = 1; i <= aLen; i++)
573  {
574  //Add the current bytes and propagate the carry
575  temp += a[aLen - i];
576  temp += (i <= bLen) ? b[bLen - i] : 0;
577  a[aLen - i] = temp & 0xFF;
578  temp >>= 8;
579  }
580 }
581 
582 
583 /**
584  * @brief Increment block
585  * @param[in] a Pointer to the block to be incremented
586  * @param[in] aLen Length of the block, in bytes
587  **/
588 
589 void hashDrbgInc(uint8_t *a, size_t aLen)
590 {
591  size_t i;
592  uint16_t temp;
593 
594  //Compute A = A + 1
595  for(temp = 1, i = 1; i <= aLen; i++)
596  {
597  //Increment the current byte and propagate the carry
598  temp += a[aLen - i];
599  a[aLen - i] = temp & 0xFF;
600  temp >>= 8;
601  }
602 }
603 
604 #endif
const void * buffer
Definition: crypto.h:1165
HashAlgoInit init
Definition: crypto.h:1253
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:1140
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:1249
uint64_t reseedCounter
Reseed counter.
Definition: hash_drbg.h:65
@ ERROR_OUT_OF_RESOURCES
Definition: error.h:64
HashAlgoUpdate update
Definition: crypto.h:1254
error_t(* PrngAlgoSeed)(void *context, const uint8_t *seed, size_t length)
Definition: crypto.h:1226
void hashDrbgAdd(uint8_t *a, size_t aLen, const uint8_t *b, size_t bLen)
Add blocks.
Definition: hash_drbg.c:566
error_t(* PrngAlgoReseed)(void *context, const uint8_t *seed, size_t length)
Definition: crypto.h:1229
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:147
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
Data fragment descriptor.
Definition: crypto.h:1164
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
size_t length
Definition: crypto.h:1166
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:1255
void hashGen(HashDrbgContext *context, uint8_t *output, size_t outputLen)
Hash generation sub function.
Definition: hash_drbg.c:518
void(* PrngAlgoDeinit)(void *context)
Definition: crypto.h:1235
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:1232
void hashDf(HashDrbgContext *context, const DataFrag *inputFrags, uint_t inputNumFrags, uint8_t *output, size_t outputLen)
Hash derivation function.
Definition: hash_drbg.c:463
void hashDrbgInc(uint8_t *a, size_t aLen)
Increment block.
Definition: hash_drbg.c:589
Hash_DRBG PRNG context.
Definition: hash_drbg.h:57
Common interface for hash algorithms.
Definition: crypto.h:1243
unsigned int uint_t
Definition: compiler_port.h:57
#define osMemset(p, value, length)
Definition: os_port.h:141
error_t(* PrngAlgoInit)(void *context)
Definition: crypto.h:1224
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.