Lightweight Cryptography Primitives
|
Pseudorandom number generator (PRNG) for TinyJAMBU. More...
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
union | tinyjambu_prng_state_t |
State information for a TinyJAMBU-based PRNG. More... | |
Functions | |
void | tinyjambu_prng_add_ident (const unsigned char *data, size_t size) |
Adds unique identification information for this device to the global pool. More... | |
int | tinyjambu_prng_init (tinyjambu_prng_state_t *state) |
Initializes a TinyJAMBU-based PRNG. More... | |
void | tinyjambu_prng_free (tinyjambu_prng_state_t *state) |
Frees a TinyJAMBU-based PRNG and destroys all sensitive information. More... | |
int | tinyjambu_prng_reseed (tinyjambu_prng_state_t *state) |
Forces a TinyJAMBU-based PRNG to re-seed from the system TRNG. More... | |
void | tinyjambu_prng_feed (tinyjambu_prng_state_t *state, const unsigned char *data, size_t size) |
Feeds data into a TinyJAMBU-based PRNG state to seed it from other sources besides the system TRNG. More... | |
int | tinyjambu_prng_fetch (tinyjambu_prng_state_t *state, unsigned char *data, size_t size) |
Fetches data from a TinyJAMBU-based PRNG state. More... | |
int | tinyjambu_prng_generate (unsigned char *data, size_t size) |
Fetches random data using a TinyJAMBU-based PRNG. More... | |
Pseudorandom number generator (PRNG) for TinyJAMBU.
void tinyjambu_prng_add_ident | ( | const unsigned char * | data, |
size_t | size | ||
) |
Adds unique identification information for this device to the global pool.
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.
void tinyjambu_prng_feed | ( | tinyjambu_prng_state_t * | state, |
const unsigned char * | data, | ||
size_t | size | ||
) |
Feeds data into a TinyJAMBU-based PRNG state to seed it from other sources besides the system TRNG.
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. |
int tinyjambu_prng_fetch | ( | tinyjambu_prng_state_t * | state, |
unsigned char * | data, | ||
size_t | size | ||
) |
Fetches data from a TinyJAMBU-based PRNG state.
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. |
void tinyjambu_prng_free | ( | tinyjambu_prng_state_t * | state | ) |
Frees a TinyJAMBU-based PRNG and destroys all sensitive information.
state | PRNG state to be freed. |
int tinyjambu_prng_generate | ( | unsigned char * | data, |
size_t | size | ||
) |
Fetches random data using a TinyJAMBU-based PRNG.
data | Points to a buffer to receive the generated random data. |
size | Number of bytes of random data to be generated. |
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.
int tinyjambu_prng_init | ( | tinyjambu_prng_state_t * | state | ) |
Initializes a TinyJAMBU-based PRNG.
state | PRNG state to be initialized. |
This function will fetch fresh data from the system TRNG to prepare the PRNG state to generate random data.
int tinyjambu_prng_reseed | ( | tinyjambu_prng_state_t * | state | ) |
Forces a TinyJAMBU-based PRNG to re-seed from the system TRNG.
state | PRNG state to be re-seeded. |