yarrow.h File Reference

TRNG (True Random Number Generator) More...

#include "core/crypto.h"
#include "cipher/aes.h"
#include "hash/sha256.h"

Go to the source code of this file.

Data Structures

struct  YarrowContext
 Yarrow PRNG context. More...
 

Macros

#define YARROW_PRNG_ALGO   (&yarrowPrngAlgo)
 
#define YARROW_FAST_POOL_ID   0
 
#define YARROW_SLOW_POOL_ID   1
 
#define YARROW_N   3
 
#define YARROW_K   2
 
#define YARROW_PG   10
 
#define YARROW_FAST_THRESHOLD   100
 
#define YARROW_SLOW_THRESHOLD   160
 

Functions

error_t yarrowInit (YarrowContext *context)
 Initialize PRNG context. More...
 
error_t yarrowSeed (YarrowContext *context, const uint8_t *input, size_t length)
 Seed the PRNG state. More...
 
error_t yarrowAddEntropy (YarrowContext *context, uint_t source, const uint8_t *input, size_t length, size_t entropy)
 Add entropy to the PRNG state. More...
 
error_t yarrowRead (YarrowContext *context, uint8_t *output, size_t length)
 Read random data. More...
 
void yarrowGenerateBlock (YarrowContext *context, uint8_t *output)
 Generate a random block of data. More...
 
void yarrowFastReseed (YarrowContext *context)
 Reseed from the fast pool. More...
 
void yarrowSlowReseed (YarrowContext *context)
 Reseed from the slow pool. More...
 
void yarrowDeinit (YarrowContext *context)
 Release PRNG context. More...
 

Variables

const PrngAlgo yarrowPrngAlgo
 

Detailed Description

TRNG (True Random Number Generator)

Yarrow PRNG.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 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.4.4

Definition in file yarrow.h.

Macro Definition Documentation

◆ YARROW_FAST_POOL_ID

#define YARROW_FAST_POOL_ID   0

Definition at line 43 of file yarrow.h.

◆ YARROW_FAST_THRESHOLD

#define YARROW_FAST_THRESHOLD   100

Definition at line 50 of file yarrow.h.

◆ YARROW_K

#define YARROW_K   2

Definition at line 48 of file yarrow.h.

◆ YARROW_N

#define YARROW_N   3

Definition at line 47 of file yarrow.h.

◆ YARROW_PG

#define YARROW_PG   10

Definition at line 49 of file yarrow.h.

◆ YARROW_PRNG_ALGO

#define YARROW_PRNG_ALGO   (&yarrowPrngAlgo)

Definition at line 40 of file yarrow.h.

◆ YARROW_SLOW_POOL_ID

#define YARROW_SLOW_POOL_ID   1

Definition at line 44 of file yarrow.h.

◆ YARROW_SLOW_THRESHOLD

#define YARROW_SLOW_THRESHOLD   160

Definition at line 51 of file yarrow.h.

Function Documentation

◆ yarrowAddEntropy()

error_t yarrowAddEntropy ( YarrowContext context,
uint_t  source,
const uint8_t *  input,
size_t  length,
size_t  entropy 
)

Add entropy to the PRNG state.

Parameters
[in]contextPointer to the PRNG context
[in]sourceEntropy source identifier
[in]inputPointer to the input data
[in]lengthLength of the input data
[in]entropyActual number of bits of entropy
Returns
Error code

Definition at line 119 of file yarrow.c.

◆ yarrowDeinit()

void yarrowDeinit ( YarrowContext context)

Release PRNG context.

Parameters
[in]contextPointer to the PRNG context

Definition at line 370 of file yarrow.c.

◆ yarrowFastReseed()

void yarrowFastReseed ( YarrowContext context)

Reseed from the fast pool.

Parameters
[in]contextPointer to the PRNG context

Definition at line 282 of file yarrow.c.

◆ yarrowGenerateBlock()

void yarrowGenerateBlock ( YarrowContext context,
uint8_t *  output 
)

Generate a random block of data.

Parameters
[in]contextPointer to the PRNG context
[out]outputBuffer where to store the output block

Definition at line 258 of file yarrow.c.

◆ yarrowInit()

error_t yarrowInit ( YarrowContext context)

Initialize PRNG context.

Parameters
[in]contextPointer to the PRNG context to initialize
Returns
Error code

Definition at line 61 of file yarrow.c.

◆ yarrowRead()

error_t yarrowRead ( YarrowContext context,
uint8_t *  output,
size_t  length 
)

Read random data.

Parameters
[in]contextPointer to the PRNG context
[out]outputBuffer where to store the output data
[in]lengthDesired length in bytes
Returns
Error code

Definition at line 199 of file yarrow.c.

◆ yarrowSeed()

error_t yarrowSeed ( YarrowContext context,
const uint8_t *  input,
size_t  length 
)

Seed the PRNG state.

Parameters
[in]contextPointer to the PRNG context
[in]inputPointer to the input data
[in]lengthLength of the input data
Returns
Error code

Definition at line 93 of file yarrow.c.

◆ yarrowSlowReseed()

void yarrowSlowReseed ( YarrowContext context)

Reseed from the slow pool.

Parameters
[in]contextPointer to the PRNG context

Definition at line 323 of file yarrow.c.

Variable Documentation

◆ yarrowPrngAlgo

const PrngAlgo yarrowPrngAlgo
extern

Definition at line 43 of file yarrow.c.