CTR_DRBG pseudorandom number generator. More...
Go to the source code of this file.
Data Structures | |
struct | CtrDrbgContext |
CTR_DRBG PRNG context. More... | |
Macros | |
#define | CTR_DRBG_MAX_KEY_LEN 32 |
#define | CTR_DRBG_MAX_SEED_LEN 48 |
#define | CTR_DRBG_MAX_RESEED_INTERVAL 281474976710656ULL |
#define | CTR_DRBG_PRNG_ALGO (&ctrDrbgPrngAlgo) |
Functions | |
error_t | ctrDrbgInit (CtrDrbgContext *context, const CipherAlgo *cipherAlgo, size_t keyLen, bool_t df) |
Initialize PRNG context. More... | |
error_t | ctrDrbgSeed (CtrDrbgContext *context, const uint8_t *seed, size_t length) |
Seed the PRNG state. More... | |
error_t | ctrDrbgSeedEx (CtrDrbgContext *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 | ctrDrbgReseed (CtrDrbgContext *context, const uint8_t *seed, size_t length) |
Reseed the PRNG state. More... | |
error_t | ctrDrbgReseedEx (CtrDrbgContext *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 | ctrDrbgGenerate (CtrDrbgContext *context, uint8_t *output, size_t length) |
Generate pseudorandom data. More... | |
error_t | ctrDrbgGenerateEx (CtrDrbgContext *context, const uint8_t *additionalInput, size_t additionalInputLen, uint8_t *output, size_t outputLen) |
Generate pseudorandom data (with additional input) More... | |
void | ctrDrbgDeinit (CtrDrbgContext *context) |
Release PRNG context. More... | |
error_t | blockCipherDf (CtrDrbgContext *context, const DataChunk *input, uint_t inputLen, uint8_t *output, size_t outputLen) |
Block cipher derivation function. More... | |
error_t | ctrDrbgBcc (CtrDrbgContext *context, const uint8_t *key, const DataChunk *data, uint_t dataLen, uint8_t *output) |
BCC function. More... | |
error_t | ctrDrbgUpdate (CtrDrbgContext *context, const uint8_t *providedData, size_t providedDataLen) |
Update internal state. More... | |
error_t | ctrDrbgLoadKey (CtrDrbgContext *context, const uint8_t *key) |
Load encryption key. More... | |
void | ctrDrbgIncBlock (uint8_t *ctr, size_t blockLen, size_t ctrLen) |
Increment counter block. More... | |
void | ctrDrbgXorBlock (uint8_t *x, const uint8_t *a, const uint8_t *b, size_t n) |
XOR operation. More... | |
Variables | |
const PrngAlgo | ctrDrbgPrngAlgo |
Detailed Description
CTR_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 ctr_drbg.h.
Macro Definition Documentation
◆ CTR_DRBG_MAX_KEY_LEN
#define CTR_DRBG_MAX_KEY_LEN 32 |
Definition at line 39 of file ctr_drbg.h.
◆ CTR_DRBG_MAX_RESEED_INTERVAL
#define CTR_DRBG_MAX_RESEED_INTERVAL 281474976710656ULL |
Definition at line 43 of file ctr_drbg.h.
◆ CTR_DRBG_MAX_SEED_LEN
#define CTR_DRBG_MAX_SEED_LEN 48 |
Definition at line 41 of file ctr_drbg.h.
◆ CTR_DRBG_PRNG_ALGO
#define CTR_DRBG_PRNG_ALGO (&ctrDrbgPrngAlgo) |
Definition at line 46 of file ctr_drbg.h.
Function Documentation
◆ blockCipherDf()
error_t blockCipherDf | ( | CtrDrbgContext * | context, |
const DataChunk * | input, | ||
uint_t | inputLen, | ||
uint8_t * | output, | ||
size_t | outputLen | ||
) |
Block cipher derivation function.
- Parameters
-
[in] context Pointer to the CTR_DRBG context [in] input The string to be operated on [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
- Returns
- Error code
Definition at line 594 of file ctr_drbg.c.
◆ ctrDrbgBcc()
error_t ctrDrbgBcc | ( | CtrDrbgContext * | context, |
const uint8_t * | key, | ||
const DataChunk * | data, | ||
uint_t | dataLen, | ||
uint8_t * | output | ||
) |
BCC function.
- Parameters
-
[in] context Pointer to the CTR_DRBG context [in] key The key to be used for the block cipher operation [in] data The data to be operated on [in] dataLen Number of data chunks representing the data [out] output The result to be returned from the BCC operation
- Returns
- Error code
Definition at line 754 of file ctr_drbg.c.
◆ ctrDrbgDeinit()
void ctrDrbgDeinit | ( | CtrDrbgContext * | context | ) |
Release PRNG context.
- Parameters
-
[in] context Pointer to the CTR_DRBG context
Definition at line 570 of file ctr_drbg.c.
◆ ctrDrbgGenerate()
error_t ctrDrbgGenerate | ( | CtrDrbgContext * | context, |
uint8_t * | output, | ||
size_t | length | ||
) |
Generate pseudorandom data.
- Parameters
-
[in] context Pointer to the CTR_DRBG context [out] output Buffer where to store the pseudorandom bytes [in] length Requested number of bytes
- Returns
- Error code
Definition at line 404 of file ctr_drbg.c.
◆ ctrDrbgGenerateEx()
error_t ctrDrbgGenerateEx | ( | CtrDrbgContext * | 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 CTR_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 423 of file ctr_drbg.c.
◆ ctrDrbgIncBlock()
void ctrDrbgIncBlock | ( | uint8_t * | ctr, |
size_t | blockLen, | ||
size_t | ctrLen | ||
) |
Increment counter block.
- Parameters
-
[in,out] ctr Pointer to the counter block [in] blockLen Length of the block, in bytes [in] ctrLen Size of the specific part of the block to be incremented
Definition at line 946 of file ctr_drbg.c.
◆ ctrDrbgInit()
error_t ctrDrbgInit | ( | CtrDrbgContext * | context, |
const CipherAlgo * | cipherAlgo, | ||
size_t | keyLen, | ||
bool_t | df | ||
) |
Initialize PRNG context.
- Parameters
-
[in] context Pointer to the CTR_DRBG context to initialize [in] cipherAlgo Approved block cipher algorithm [in] keyLen Key length, in bits [in] df Use key derivation function
- Returns
- Error code
Definition at line 67 of file ctr_drbg.c.
◆ ctrDrbgLoadKey()
error_t ctrDrbgLoadKey | ( | CtrDrbgContext * | context, |
const uint8_t * | key | ||
) |
Load encryption key.
- Parameters
-
[in] context Pointer to the CTR_DRBG context [in] key Pointer to the Encryption key to load
- Returns
- Error code
Definition at line 905 of file ctr_drbg.c.
◆ ctrDrbgReseed()
error_t ctrDrbgReseed | ( | CtrDrbgContext * | context, |
const uint8_t * | seed, | ||
size_t | length | ||
) |
Reseed the PRNG state.
- Parameters
-
[in] context Pointer to the CTR_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 279 of file ctr_drbg.c.
◆ ctrDrbgReseedEx()
error_t ctrDrbgReseedEx | ( | CtrDrbgContext * | 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 CTR_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 298 of file ctr_drbg.c.
◆ ctrDrbgSeed()
error_t ctrDrbgSeed | ( | CtrDrbgContext * | context, |
const uint8_t * | seed, | ||
size_t | length | ||
) |
Seed the PRNG state.
- Parameters
-
[in] context Pointer to the CTR_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 138 of file ctr_drbg.c.
◆ ctrDrbgSeedEx()
error_t ctrDrbgSeedEx | ( | CtrDrbgContext * | 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 CTR_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 160 of file ctr_drbg.c.
◆ ctrDrbgUpdate()
error_t ctrDrbgUpdate | ( | CtrDrbgContext * | context, |
const uint8_t * | providedData, | ||
size_t | providedDataLen | ||
) |
Update internal state.
- Parameters
-
[in] context Pointer to the CTR_DRBG context [in] providedData The data to be used [in] providedDataLen Length of the data, in bytes
- Returns
- Error code
Definition at line 839 of file ctr_drbg.c.
◆ ctrDrbgXorBlock()
void ctrDrbgXorBlock | ( | uint8_t * | x, |
const uint8_t * | a, | ||
const uint8_t * | b, | ||
size_t | n | ||
) |
XOR operation.
- Parameters
-
[out] x Block resulting from the XOR operation [in] a First input block [in] b Second input block [in] n Length of the block, in bytes
Definition at line 971 of file ctr_drbg.c.
Variable Documentation
◆ ctrDrbgPrngAlgo
|
extern |
Definition at line 46 of file ctr_drbg.c.