libdecaf
Loading...
Searching...
No Matches
Classes | Typedefs | Functions
spongerng.h File Reference

Sponge-based RNGs. More...

Go to the source code of this file.

Classes

struct  decaf_keccak_prng_s
 Keccak CSPRNG structure as struct. More...
 

Typedefs

typedef decaf_keccak_prng_s decaf_keccak_prng_t[1]
 Keccak CSPRNG structure as one-element array.
 

Functions

void DECAF_API_VIS decaf_spongerng_init_from_buffer (decaf_keccak_prng_t prng, const uint8_t *__restrict__ in, size_t len, int deterministic) DECAF_NONNULL
 Initialize a sponge-based CSPRNG from a buffer.
 
decaf_error_t DECAF_API_VIS decaf_spongerng_init_from_file (decaf_keccak_prng_t prng, const char *file, size_t len, int deterministic) DECAF_NONNULL DECAF_WARN_UNUSED
 Initialize a sponge-based CSPRNG from a file.
 
decaf_error_t DECAF_API_VIS decaf_spongerng_init_from_dev_urandom (decaf_keccak_prng_t prng) DECAF_WARN_UNUSED
 Initialize a nondeterministic sponge-based CSPRNG from /dev/urandom.
 
void DECAF_API_VIS decaf_spongerng_next (decaf_keccak_prng_t prng, uint8_t *__restrict__ out, size_t len)
 Output bytes from a sponge-based CSPRNG.
 
void DECAF_API_VIS decaf_spongerng_stir (decaf_keccak_prng_t prng, const uint8_t *__restrict__ in, size_t len) DECAF_NONNULL
 Stir entropy data into a sponge-based CSPRNG from a buffer.
 

Detailed Description

Sponge-based RNGs.

Author
Mike Hamburg
Warning
This construction isn't final. In particular, the outputs of deterministic RNGs from this mechanism might change in future versions.

Function Documentation

◆ decaf_spongerng_init_from_buffer()

void DECAF_API_VIS decaf_spongerng_init_from_buffer ( decaf_keccak_prng_t  prng,
const uint8_t *__restrict__  in,
size_t  len,
int  deterministic 
)

Initialize a sponge-based CSPRNG from a buffer.

Parameters
[out]prngThe PRNG object.
[in]inThe initialization data.
[in]lenThe length of the initialization data.
[in]deterministicIf zero, allow RNG to stir in nondeterministic data from RDRAND or RDTSC.

◆ decaf_spongerng_init_from_dev_urandom()

decaf_error_t DECAF_API_VIS decaf_spongerng_init_from_dev_urandom ( decaf_keccak_prng_t  prng)

Initialize a nondeterministic sponge-based CSPRNG from /dev/urandom.

Return values
DECAF_SUCCESSsuccess.
DECAF_FAILUREfailure.
Note
On failure, errno can be used to determine the cause.
Parameters
[out]prngsponge The sponge object.

◆ decaf_spongerng_init_from_file()

decaf_error_t DECAF_API_VIS decaf_spongerng_init_from_file ( decaf_keccak_prng_t  prng,
const char *  file,
size_t  len,
int  deterministic 
)

Initialize a sponge-based CSPRNG from a file.

Return values
DECAF_SUCCESSsuccess.
DECAF_FAILUREfailure.
Note
On failure, errno can be used to determine the cause.
Parameters
[out]prngThe PRNG object.
[in]fileA name of a file containing initial data.
[in]lenThe length of the initial data. Must be positive.
[in]deterministicIf zero, allow RNG to stir in nondeterministic data from RDRAND or RDTSC.

◆ decaf_spongerng_next()

void DECAF_API_VIS decaf_spongerng_next ( decaf_keccak_prng_t  prng,
uint8_t *__restrict__  out,
size_t  len 
)

Output bytes from a sponge-based CSPRNG.

Parameters
[in,out]prngThe PRNG object.
[out]outOutput buffer.
[in]lenNumber of bytes to output.

◆ decaf_spongerng_stir()

void DECAF_API_VIS decaf_spongerng_stir ( decaf_keccak_prng_t  prng,
const uint8_t *__restrict__  in,
size_t  len 
)

Stir entropy data into a sponge-based CSPRNG from a buffer.


Parameters
[out]prngThe PRNG object.
[in]inThe entropy data.
[in]lenThe length of the initial data.