Hash_DRBG pseudorandom number generator. More...
Go to the source code of this file.
Data Structures | |
struct | HashDrbgContext |
Hash_DRBG PRNG context. More... | |
Macros | |
#define | HASH_DRBG_MAX_SEED_LEN 111 |
#define | HASH_DRBG_MAX_RESEED_INTERVAL 281474976710656ULL |
#define | HASH_DRBG_PRNG_ALGO (&hashDrbgPrngAlgo) |
Functions | |
error_t | hashDrbgInit (HashDrbgContext *context, const HashAlgo *hashAlgo) |
Initialize PRNG context. More... | |
error_t | hashDrbgSeed (HashDrbgContext *context, const uint8_t *seed, size_t length) |
Seed the PRNG state. More... | |
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) More... | |
error_t | hashDrbgReseed (HashDrbgContext *context, const uint8_t *seed, size_t length) |
Reseed the PRNG state. More... | |
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) More... | |
error_t | hashDrbgGenerate (HashDrbgContext *context, uint8_t *output, size_t length) |
Generate pseudorandom data. More... | |
error_t | hashDrbgGenerateEx (HashDrbgContext *context, const uint8_t *additionalInput, size_t additionalInputLen, uint8_t *output, size_t outputLen) |
Generate pseudorandom data (with additional input) More... | |
void | hashDrbgDeinit (HashDrbgContext *context) |
Release PRNG context. More... | |
void | hashDf (HashDrbgContext *context, const DataChunk *input, uint_t inputLen, uint8_t *output, size_t outputLen) |
Hash derivation function. More... | |
void | hashGen (HashDrbgContext *context, uint8_t *output, size_t outputLen) |
Hash generation sub function. More... | |
void | hashDrbgAdd (uint8_t *a, size_t aLen, const uint8_t *b, size_t bLen) |
Add blocks. More... | |
void | hashDrbgInc (uint8_t *a, size_t aLen) |
Increment block. More... | |
Variables | |
const PrngAlgo | hashDrbgPrngAlgo |
Detailed Description
Hash_DRBG pseudorandom number generator.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneCRYPTO Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.5.4
Definition in file hash_drbg.h.
Macro Definition Documentation
◆ HASH_DRBG_MAX_RESEED_INTERVAL
#define HASH_DRBG_MAX_RESEED_INTERVAL 281474976710656ULL |
Definition at line 41 of file hash_drbg.h.
◆ HASH_DRBG_MAX_SEED_LEN
#define HASH_DRBG_MAX_SEED_LEN 111 |
Definition at line 39 of file hash_drbg.h.
◆ HASH_DRBG_PRNG_ALGO
#define HASH_DRBG_PRNG_ALGO (&hashDrbgPrngAlgo) |
Definition at line 44 of file hash_drbg.h.
Function Documentation
◆ hashDf()
void hashDf | ( | HashDrbgContext * | context, |
const DataChunk * | input, | ||
uint_t | inputLen, | ||
uint8_t * | output, | ||
size_t | outputLen | ||
) |
Hash derivation function.
- Parameters
-
[in] context Pointer to the Hash_DRBG context [in] input The string to be hashed [in] inputLen Number of data chunks representing the input [out] output Buffer where to store the output value [out] outputLen The number of bytes to be returned
Definition at line 463 of file hash_drbg.c.
◆ hashDrbgAdd()
void hashDrbgAdd | ( | uint8_t * | a, |
size_t | aLen, | ||
const uint8_t * | b, | ||
size_t | bLen | ||
) |
Add blocks.
- Parameters
-
[in,out] a Pointer to the first block [in] aLen Length of the first block, in bytes [in] b Pointer to the second block [in] bLen Length of the second block, in bytes
Definition at line 565 of file hash_drbg.c.
◆ hashDrbgDeinit()
void hashDrbgDeinit | ( | HashDrbgContext * | context | ) |
Release PRNG context.
- Parameters
-
[in] context Pointer to the Hash_DRBG context
Definition at line 440 of file hash_drbg.c.
◆ hashDrbgGenerate()
error_t hashDrbgGenerate | ( | HashDrbgContext * | context, |
uint8_t * | output, | ||
size_t | length | ||
) |
Generate pseudorandom data.
- Parameters
-
[in] context Pointer to the Hash_DRBG context [out] output Buffer where to store the pseudorandom bytes [in] length Requested number of bytes
- Returns
- Error code
Definition at line 327 of file hash_drbg.c.
◆ hashDrbgGenerateEx()
error_t hashDrbgGenerateEx | ( | HashDrbgContext * | context, |
const uint8_t * | additionalInput, | ||
size_t | additionalInputLen, | ||
uint8_t * | output, | ||
size_t | outputLen | ||
) |
Generate pseudorandom data (with additional input)
- Parameters
-
[in] context Pointer to the Hash_DRBG context [in] additionalInput Additional input string received from the consuming application [in] additionalInputLen Length of the additional input string, in bytes [out] output Buffer where to store the pseudorandom bytes [in] outputLen Requested number of bytes
- Returns
- Error code
Definition at line 346 of file hash_drbg.c.
◆ hashDrbgInc()
void hashDrbgInc | ( | uint8_t * | a, |
size_t | aLen | ||
) |
Increment block.
- Parameters
-
[in] a Pointer to the block to be incremented [in] aLen Length of the block, in bytes
Definition at line 588 of file hash_drbg.c.
◆ hashDrbgInit()
error_t hashDrbgInit | ( | HashDrbgContext * | context, |
const HashAlgo * | hashAlgo | ||
) |
Initialize PRNG context.
- Parameters
-
[in] context Pointer to the Hash_DRBG context to initialize [in] hashAlgo Approved hash function
- Returns
- Error code
Definition at line 62 of file hash_drbg.c.
◆ hashDrbgReseed()
error_t hashDrbgReseed | ( | HashDrbgContext * | context, |
const uint8_t * | seed, | ||
size_t | length | ||
) |
Reseed the PRNG state.
- Parameters
-
[in] context Pointer to the Hash_DRBG context [in] seed String of bits obtained from the randomness source [in] length Length of the string, in bytes
- Returns
- Error code
Definition at line 225 of file hash_drbg.c.
◆ hashDrbgReseedEx()
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)
- Parameters
-
[in] context Pointer to the Hash_DRBG context [in] entropyInput String of bits obtained from the randomness source [in] entropyInputLen Length of the string, in bytes [in] additionalInput Additional input string received from the consuming application [in] additionalInputLen Length of the additional input string, in bytes
- Returns
- Error code
Definition at line 244 of file hash_drbg.c.
◆ hashDrbgSeed()
error_t hashDrbgSeed | ( | HashDrbgContext * | context, |
const uint8_t * | seed, | ||
size_t | length | ||
) |
Seed the PRNG state.
- Parameters
-
[in] context Pointer to the Hash_DRBG context [in] seed String of bits obtained from the randomness source [in] length Length of the string, in bytes
- Returns
- Error code
Definition at line 120 of file hash_drbg.c.
◆ hashDrbgSeedEx()
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)
- Parameters
-
[in] context Pointer to the Hash_DRBG context [in] entropyInput String of bits obtained from the randomness source [in] entropyInputLen Length of the string, in bytes [in] nonce Nonce [in] nonceLen Length of the nonce, in bytes [in] personalizationString Personalization string received from the consuming application [in] personalizationStringLen Length of the personalization string, in bytes
- Returns
- Error code
Definition at line 142 of file hash_drbg.c.
◆ hashGen()
void hashGen | ( | HashDrbgContext * | context, |
uint8_t * | output, | ||
size_t | outputLen | ||
) |
Hash generation sub function.
- Parameters
-
[in] context Pointer to the Hash_DRBG context [out] output Buffer where to store the output value [out] outputLen The number of bytes to be returned
Definition at line 517 of file hash_drbg.c.
Variable Documentation
◆ hashDrbgPrngAlgo
|
extern |
Definition at line 43 of file hash_drbg.c.