xdrbg.h File Reference

XDRBG pseudorandom number generator. More...

#include "core/crypto.h"
#include "xof/xof_algorithms.h"

Go to the source code of this file.

Data Structures

struct  XdrbgContext
 XDRBG PRNG context. More...
 

Macros

#define XDRBG_MAX_ALPHA_LEN   84
 
#define XDRBG_MAX_V_SIZE   64
 
#define XDRBG_PRNG_ALGO   (&xdrbgPrngAlgo)
 
#define XDRBG_ENCODE(alphaLen, n)   ((n * 85) + alphaLen)
 

Functions

error_t xdrbgInit (XdrbgContext *context, const XofAlgo *xofAlgo)
 Initialize PRNG context. More...
 
error_t xdrbgSeed (XdrbgContext *context, const uint8_t *seed, size_t length)
 Seed the PRNG state. More...
 
error_t xdrbgSeedEx (XdrbgContext *context, const uint8_t *seed, size_t seedLen, const uint8_t *alpha, size_t alphaLen)
 Seed the PRNG state (with nonce and personalization string) More...
 
error_t xdrbgReseed (XdrbgContext *context, const uint8_t *seed, size_t length)
 Reseed the PRNG state. More...
 
error_t xdrbgReseedEx (XdrbgContext *context, const uint8_t *seed, size_t seedLen, const uint8_t *alpha, size_t alphaLen)
 Reseed the PRNG state (with additional input) More...
 
error_t xdrbgGenerate (XdrbgContext *context, uint8_t *output, size_t length)
 Generate pseudorandom data. More...
 
error_t xdrbgGenerateEx (XdrbgContext *context, const uint8_t *alpha, size_t alphaLen, uint8_t *output, size_t outputLen)
 Generate pseudorandom data (with additional input) More...
 
void xdrbgDeinit (XdrbgContext *context)
 Release PRNG context. More...
 

Variables

const PrngAlgo xdrbgPrngAlgo
 

Detailed Description

XDRBG 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 xdrbg.h.

Macro Definition Documentation

◆ XDRBG_ENCODE

#define XDRBG_ENCODE (   alphaLen,
  n 
)    ((n * 85) + alphaLen)

Definition at line 47 of file xdrbg.h.

◆ XDRBG_MAX_ALPHA_LEN

#define XDRBG_MAX_ALPHA_LEN   84

Definition at line 39 of file xdrbg.h.

◆ XDRBG_MAX_V_SIZE

#define XDRBG_MAX_V_SIZE   64

Definition at line 41 of file xdrbg.h.

◆ XDRBG_PRNG_ALGO

#define XDRBG_PRNG_ALGO   (&xdrbgPrngAlgo)

Definition at line 44 of file xdrbg.h.

Function Documentation

◆ xdrbgDeinit()

void xdrbgDeinit ( XdrbgContext context)

Release PRNG context.

Parameters
[in]contextPointer to the XDRBG context

Definition at line 393 of file xdrbg.c.

◆ xdrbgGenerate()

error_t xdrbgGenerate ( XdrbgContext context,
uint8_t *  output,
size_t  length 
)

Generate pseudorandom data.

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

Definition at line 299 of file xdrbg.c.

◆ xdrbgGenerateEx()

error_t xdrbgGenerateEx ( XdrbgContext context,
const uint8_t *  alpha,
size_t  alphaLen,
uint8_t *  output,
size_t  outputLen 
)

Generate pseudorandom data (with additional input)

Parameters
[in]contextPointer to the XDRBG context
[in]alphaOptional data
[in]alphaLenLength of the additional data, in bytes
[out]outputBuffer where to store the pseudorandom bytes
[in]outputLenRequested number of bytes
Returns
Error code

Definition at line 316 of file xdrbg.c.

◆ xdrbgInit()

error_t xdrbgInit ( XdrbgContext context,
const XofAlgo xofAlgo 
)

Initialize PRNG context.

Parameters
[in]contextPointer to the XDRBG context to initialize
[in]xofAlgoXOF algorithm
Returns
Error code

Definition at line 62 of file xdrbg.c.

◆ xdrbgReseed()

error_t xdrbgReseed ( XdrbgContext context,
const uint8_t *  seed,
size_t  length 
)

Reseed the PRNG state.

Parameters
[in]contextPointer to the XDRBG context
[in]seedSeed material
[in]seedLenLength of the seed material, in bytes
Returns
Error code

Definition at line 212 of file xdrbg.c.

◆ xdrbgReseedEx()

error_t xdrbgReseedEx ( XdrbgContext context,
const uint8_t *  seed,
size_t  seedLen,
const uint8_t *  alpha,
size_t  alphaLen 
)

Reseed the PRNG state (with additional input)

Parameters
[in]contextPointer to the XDRBG context
[in]seedSeed material
[in]seedLenLength of the seed material, in bytes
[in]alphaOptional data
[in]alphaLenLength of the additional data, in bytes
Returns
Error code

Definition at line 229 of file xdrbg.c.

◆ xdrbgSeed()

error_t xdrbgSeed ( XdrbgContext context,
const uint8_t *  seed,
size_t  length 
)

Seed the PRNG state.

Parameters
[in]contextPointer to the XDRBG context
[in]seedSeed material
[in]seedLenLength of the seed material, in bytes
Returns
Error code

Definition at line 130 of file xdrbg.c.

◆ xdrbgSeedEx()

error_t xdrbgSeedEx ( XdrbgContext context,
const uint8_t *  seed,
size_t  seedLen,
const uint8_t *  alpha,
size_t  alphaLen 
)

Seed the PRNG state (with nonce and personalization string)

Parameters
[in]contextPointer to the XDRBG context
[in]seedSeed material
[in]seedLenLength of the seed material, in bytes
[in]alphaOptional data
[in]alphaLenLength of the additional data, in bytes
Returns
Error code

Definition at line 147 of file xdrbg.c.

Variable Documentation

◆ xdrbgPrngAlgo

const PrngAlgo xdrbgPrngAlgo
extern

Definition at line 43 of file xdrbg.c.