Pseudorandom number generator (PRNG) built around Xoodoo.
More...
#include <stddef.h>
Go to the source code of this file.
Pseudorandom number generator (PRNG) built around Xoodoo.
This PRNG implementation uses the SpongePRNG construction with Xoodoo as the sponge permutation.
Reference: "Sponge-based pseudo-random number generators", Guido Bertoni et al, https://keccak.team/files/SpongePRNG.pdf
void xoodyak_prng_add_ident |
( |
const unsigned char * |
data, |
|
|
size_t |
size |
|
) |
| |
Adds unique identification information for this device to the global pool.
- Parameters
-
data | Points to the identification information. |
size | Number of bytes of identification information. |
The application should use this function at startup to add serial numbers and other unique identification information to the global pool for the PRNG. This data does not need to be secret but can help make the generated output unique for each device.
- Note
- This function is not thread-safe so it should be called at startup before threads start using the PRNG to generate random data.
Feeds data into a Xoodoo-based PRNG state to seed it from other sources besides the system TRNG.
- Parameters
-
state | PRNG state to be feed new seed data. |
data | Points to the data to be fed into the PRNG state. |
size | Number of bytes of data to be fed into the PRNG state. |
Fetches data from a Xoodoo-based PRNG state.
- Parameters
-
state | PRNG state to fetch data from. |
data | Points to a buffer to receive the generated random data. |
size | Number of bytes of random data to be generated. |
- Returns
- Zero if the PRNG was re-seeded from the system TRNG during the fetch but there is no system TRNG or it has failed.
Frees a Xoodoo-based PRNG and destroys all sensitive information.
- Parameters
-
state | PRNG state to be freed. |
int xoodyak_prng_generate |
( |
unsigned char * |
data, |
|
|
size_t |
size |
|
) |
| |
Fetches random data using a Xoodoo-based PRNG.
- Parameters
-
data | Points to a buffer to receive the generated random data. |
size | Number of bytes of random data to be generated. |
- Returns
- Non-zero if the PRNG was initialized from system TRNG data, or zero if there is no system TRNG or it has failed.
This function will create a temporary PRNG state object, seed it from the system TRNG, and then generate size bytes of random data. It is intended for quick one-off generation of random material.
Initializes a Xoodoo-based PRNG.
- Parameters
-
state | PRNG state to be initialized. |
- Returns
- Non-zero if the PRNG was initialized from system TRNG data, or zero if there is no system TRNG or it has failed.
This function will fetch fresh data from the system TRNG to prepare the PRNG state to generate random data.
Forces a Xoodoo-based PRNG to re-seed from the system TRNG.
- Parameters
-
state | PRNG state to be re-seeded. |
- Returns
- Non-zero if the PRNG was re-seeded from system TRNG data, or zero if there is no system TRNG or it has failed.