hmac_drbg.h File Reference

HMAC_DRBG pseudorandom number generator. More...

#include "core/crypto.h"
#include "mac/hmac.h"

Go to the source code of this file.

Data Structures

struct  HmacDrbgContext
 HMAC_DRBG PRNG context. More...
 

Macros

#define HMAC_DRBG_MAX_RESEED_INTERVAL   281474976710656ULL
 
#define HMAC_DRBG_PRNG_ALGO   (&hmacDrbgPrngAlgo)
 

Functions

error_t hmacDrbgInit (HmacDrbgContext *context, const HashAlgo *hashAlgo)
 Initialize PRNG context. More...
 
error_t hmacDrbgSeed (HmacDrbgContext *context, const uint8_t *seed, size_t length)
 Seed the PRNG state. More...
 
error_t hmacDrbgSeedEx (HmacDrbgContext *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 hmacDrbgReseed (HmacDrbgContext *context, const uint8_t *seed, size_t length)
 Reseed the PRNG state. More...
 
error_t hmacDrbgReseedEx (HmacDrbgContext *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 hmacDrbgGenerate (HmacDrbgContext *context, uint8_t *output, size_t length)
 Generate pseudorandom data. More...
 
error_t hmacDrbgGenerateEx (HmacDrbgContext *context, const uint8_t *additionalInput, size_t additionalInputLen, uint8_t *output, size_t outputLen)
 Generate pseudorandom data (with additional input) More...
 
void hmacDrbgDeinit (HmacDrbgContext *context)
 Release PRNG context. More...
 
void hmacDrbgUpdate (HmacDrbgContext *context, const DataChunk *providedData, uint_t providedDataLen)
 Update internal state. More...
 

Variables

const PrngAlgo hmacDrbgPrngAlgo
 

Detailed Description

HMAC_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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.5.4

Definition in file hmac_drbg.h.

Macro Definition Documentation

◆ HMAC_DRBG_MAX_RESEED_INTERVAL

#define HMAC_DRBG_MAX_RESEED_INTERVAL   281474976710656ULL

Definition at line 39 of file hmac_drbg.h.

◆ HMAC_DRBG_PRNG_ALGO

#define HMAC_DRBG_PRNG_ALGO   (&hmacDrbgPrngAlgo)

Definition at line 42 of file hmac_drbg.h.

Function Documentation

◆ hmacDrbgDeinit()

void hmacDrbgDeinit ( HmacDrbgContext context)

Release PRNG context.

Parameters
[in]contextPointer to the HMAC_DRBG context

Definition at line 401 of file hmac_drbg.c.

◆ hmacDrbgGenerate()

error_t hmacDrbgGenerate ( HmacDrbgContext context,
uint8_t *  output,
size_t  length 
)

Generate pseudorandom data.

Parameters
[in]contextPointer to the HMAC_DRBG context
[out]outputBuffer where to store the pseudorandom bytes
[in]lengthRequested number of bytes
Returns
Error code

Definition at line 287 of file hmac_drbg.c.

◆ hmacDrbgGenerateEx()

error_t hmacDrbgGenerateEx ( HmacDrbgContext context,
const uint8_t *  additionalInput,
size_t  additionalInputLen,
uint8_t *  output,
size_t  outputLen 
)

Generate pseudorandom data (with additional input)

Parameters
[in]contextPointer to the HMAC_DRBG context
[in]additionalInputAdditional input string received from the consuming application
[in]additionalInputLenLength of the additional input string, in bytes
[out]outputBuffer where to store the pseudorandom bytes
[in]outputLenRequested number of bytes
Returns
Error code

Definition at line 306 of file hmac_drbg.c.

◆ hmacDrbgInit()

error_t hmacDrbgInit ( HmacDrbgContext context,
const HashAlgo hashAlgo 
)

Initialize PRNG context.

Parameters
[in]contextPointer to the HMAC_DRBG context to initialize
[in]hashAlgoApproved hash function
Returns
Error code

Definition at line 62 of file hmac_drbg.c.

◆ hmacDrbgReseed()

error_t hmacDrbgReseed ( HmacDrbgContext context,
const uint8_t *  seed,
size_t  length 
)

Reseed the PRNG state.

Parameters
[in]contextPointer to the HMAC_DRBG context
[in]seedString of bits obtained from the randomness source
[in]lengthLength of the string, in bytes
Returns
Error code

Definition at line 209 of file hmac_drbg.c.

◆ hmacDrbgReseedEx()

error_t hmacDrbgReseedEx ( HmacDrbgContext context,
const uint8_t *  entropyInput,
size_t  entropyInputLen,
const uint8_t *  additionalInput,
size_t  additionalInputLen 
)

Reseed the PRNG state (with additional input)

Parameters
[in]contextPointer to the HMAC_DRBG context
[in]entropyInputString of bits obtained from the randomness source
[in]entropyInputLenLength of the string, in bytes
[in]additionalInputAdditional input string received from the consuming application
[in]additionalInputLenLength of the additional input string, in bytes
Returns
Error code

Definition at line 228 of file hmac_drbg.c.

◆ hmacDrbgSeed()

error_t hmacDrbgSeed ( HmacDrbgContext context,
const uint8_t *  seed,
size_t  length 
)

Seed the PRNG state.

Parameters
[in]contextPointer to the HMAC_DRBG context
[in]seedString of bits obtained from the randomness source
[in]lengthLength of the string, in bytes
Returns
Error code

Definition at line 109 of file hmac_drbg.c.

◆ hmacDrbgSeedEx()

error_t hmacDrbgSeedEx ( HmacDrbgContext 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]contextPointer to the HMAC_DRBG context
[in]entropyInputString of bits obtained from the randomness source
[in]entropyInputLenLength of the string, in bytes
[in]nonceNonce
[in]nonceLenLength of the nonce, in bytes
[in]personalizationStringPersonalization string received from the consuming application
[in]personalizationStringLenLength of the personalization string, in bytes
Returns
Error code

Definition at line 131 of file hmac_drbg.c.

◆ hmacDrbgUpdate()

void hmacDrbgUpdate ( HmacDrbgContext context,
const DataChunk providedData,
uint_t  providedDataLen 
)

Update internal state.

Parameters
[in]contextPointer to the HMAC_DRBG context
[in]providedDataThe data to be used
[in]providedDataLenNumber of data chunks representing the data

Definition at line 422 of file hmac_drbg.c.

Variable Documentation

◆ hmacDrbgPrngAlgo

const PrngAlgo hmacDrbgPrngAlgo
extern

Definition at line 43 of file hmac_drbg.c.