ASCON Suite
|
#include <ascon/random.h>
#include <ascon/utility.h>
#include "random/ascon-trng.h"
#include "core/ascon-util-snp.h"
Go to the source code of this file.
Macros | |
#define | ASCON_RANDOM_RESEED_LIMIT 16384 |
Automatically re-seed after generating more than this many bytes. More... | |
Functions | |
int | ascon_random_init (ascon_random_state_t *state) |
Initializes a pseudorandom number generator from the system random number source. More... | |
void | ascon_random_free (ascon_random_state_t *state) |
Frees a pseudorandom number generator and destroys any sensitive values. More... | |
void | ascon_random_fetch (ascon_random_state_t *state, unsigned char *out, size_t outlen) |
Fetches data from a pseudorandom number generator. More... | |
int | ascon_random_reseed (ascon_random_state_t *state) |
Explicitly re-seeds a pseudorandom number generator from the system random number source. More... | |
void | ascon_random_feed (ascon_random_state_t *state, const unsigned char *entropy, size_t size) |
Feeds entropy into a pseudorandom number generator. More... | |
#define ASCON_RANDOM_RESEED_LIMIT 16384 |
Automatically re-seed after generating more than this many bytes.
Definition at line 31 of file ascon-prng.c.
void ascon_random_feed | ( | ascon_random_state_t * | state, |
const unsigned char * | entropy, | ||
size_t | size | ||
) |
Feeds entropy into a pseudorandom number generator.
state | The pseudorandom number generator to feed the entropy into. |
entropy | Points to a buffer containing the entropy. |
size | Number of bytes of entropy to add, which can be zero to "stir" the random pool but not introduce any new entropy. |
This API does not keep track of how much entropy has been collected. Estimating the amount of entropy contained in noise sources is difficult and would make the API very complex.
The application can keep track of "entropy credits" itself if that is important. And then only call ascon_random_fetch() when it judges that the entropy pool is sufficiently populated.
Definition at line 135 of file ascon-prng.c.
void ascon_random_fetch | ( | ascon_random_state_t * | state, |
unsigned char * | out, | ||
size_t | outlen | ||
) |
Fetches data from a pseudorandom number generator.
state | The pseudorandom number generator state to use. |
out | Points to a buffer to receive the random data. |
outlen | Number of bytes of random data to fetch. |
Definition at line 90 of file ascon-prng.c.
void ascon_random_free | ( | ascon_random_state_t * | state | ) |
Frees a pseudorandom number generator and destroys any sensitive values.
state | The pseudorandom number generator state to free. |
Definition at line 82 of file ascon-prng.c.
int ascon_random_init | ( | ascon_random_state_t * | state | ) |
Initializes a pseudorandom number generator from the system random number source.
state | The pseudorandom number generator state to initialize. |
In the case of a zero return, the returned data may be predictable so the application should avoid using the pseudorandom number generator unless it has some other source of entropy it can use.
Definition at line 66 of file ascon-prng.c.
int ascon_random_reseed | ( | ascon_random_state_t * | state | ) |
Explicitly re-seeds a pseudorandom number generator from the system random number source.
state | The pseudorandom number generator to re-seed. |
The pseudorandom number generator will be re-seeded periodically by ascon_random_fetch() but the application can choose to re-seed more often if it needs fresh random data.
Definition at line 116 of file ascon-prng.c.