libhcs
|
Provides secure random state for use in functions which require random values. More...
#include <gmp.h>
Go to the source code of this file.
Data Structures | |
struct | hcs_random |
Random state used by a number of cryptographic functions. More... | |
Macros | |
#define | HCS_RAND_SEED_BITS 256 |
If this define is set, then a static seed of 0 will always be used in any hcs_random functions. More... | |
Functions | |
hcs_random * | hcs_init_random (void) |
Initialise an hcs_random and return a pointer to the newly created structure. More... | |
int | hcs_reseed_random (hcs_random *hr) |
Reseed the given hcs_random. More... | |
void | hcs_free_random (hcs_random *hr) |
Frees a hcs_random and all associated memory. More... | |
Provides secure random state for use in functions which require random values.
This is a wrapper around gmp_randstate_t, and utilizes them internally as a PRNG. Currently, it uses gmp_randinit_default for choice of PRNG.
Seed is gathered from the operating systems provided entropy. For example, /dev/urandom is used under Linux. This may be slightly altered, but for now it satisfies the required randomness.
#define HCS_RAND_SEED_BITS 256 |
If this define is set, then a static seed of 0 will always be used in any hcs_random functions.
ONLY use this for testing. The number of bits of seed which is gathered from our entropy source.
hcs_random* hcs_init_random | ( | void | ) |
Initialise an hcs_random and return a pointer to the newly created structure.
int hcs_reseed_random | ( | hcs_random * | hr | ) |
Reseed the given hcs_random.
If we fail to gather sufficient entropy, we return with an error.
hr | A pointer to an initialised hcs_random |
void hcs_free_random | ( | hcs_random * | hr | ) |
Frees a hcs_random and all associated memory.
hr | A pointer to an initliased hcs_random |