#include "polarssl/config.h"
#include "polarssl/entropy.h"
#include "polarssl/entropy_poll.h"
Go to the source code of this file.
Defines | |
#define | ENTROPY_MAX_LOOP 256 |
Maximum amount to loop before error. | |
Functions | |
void | entropy_init (entropy_context *ctx) |
Initialize the context. | |
void | entropy_free (entropy_context *ctx) |
Free the data in the context. | |
int | entropy_add_source (entropy_context *ctx, f_source_ptr f_source, void *p_source, size_t threshold) |
Adds an entropy source to poll. | |
static int | entropy_update (entropy_context *ctx, unsigned char source_id, const unsigned char *data, size_t len) |
int | entropy_update_manual (entropy_context *ctx, const unsigned char *data, size_t len) |
Add data to the accumulator manually. | |
int | entropy_gather (entropy_context *ctx) |
Trigger an extra gather poll for the accumulator. | |
int | entropy_func (void *data, unsigned char *output, size_t len) |
Retrieve entropy from the accumulator (Max ENTROPY_BLOCK_SIZE) (Thread-safe if POLARSSL_THREADING_C is enabled). |
#define ENTROPY_MAX_LOOP 256 |
Maximum amount to loop before error.
Definition at line 37 of file entropy.c.
Referenced by entropy_func().
int entropy_add_source | ( | entropy_context * | ctx, | |
f_source_ptr | f_source, | |||
void * | p_source, | |||
size_t | threshold | |||
) |
Adds an entropy source to poll.
ctx | Entropy context | |
f_source | Entropy function | |
p_source | Function data | |
threshold | Minimum required from source before entropy is released ( with entropy_func() ) |
Definition at line 79 of file entropy.c.
References ENTROPY_MAX_SOURCES, source_state::f_source, source_state::p_source, POLARSSL_ERR_ENTROPY_MAX_SOURCES, entropy_context::source, entropy_context::source_count, and source_state::threshold.
Referenced by entropy_init().
void entropy_free | ( | entropy_context * | ctx | ) |
Free the data in the context.
ctx | Entropy context to free |
Definition at line 71 of file entropy.c.
References polarssl_mutex_free.
int entropy_func | ( | void * | data, | |
unsigned char * | output, | |||
size_t | len | |||
) |
Retrieve entropy from the accumulator (Max ENTROPY_BLOCK_SIZE) (Thread-safe if POLARSSL_THREADING_C is enabled).
data | Entropy context | |
output | Buffer to fill | |
len | Length of buffer |
Definition at line 176 of file entropy.c.
References entropy_context::accumulator, ENTROPY_BLOCK_SIZE, entropy_gather(), ENTROPY_MAX_LOOP, POLARSSL_ERR_ENTROPY_SOURCE_FAILED, POLARSSL_ERR_THREADING_MUTEX_ERROR, polarssl_mutex_lock, polarssl_mutex_unlock, sha256(), sha256_finish(), sha256_starts(), sha256_update(), sha512(), sha512_finish(), sha512_starts(), sha512_update(), source_state::size, entropy_context::source, entropy_context::source_count, and source_state::threshold.
int entropy_gather | ( | entropy_context * | ctx | ) |
Trigger an extra gather poll for the accumulator.
ctx | Entropy context |
Definition at line 142 of file entropy.c.
References ENTROPY_MAX_GATHER, entropy_update(), source_state::f_source, source_state::p_source, POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED, source_state::size, entropy_context::source, and entropy_context::source_count.
Referenced by entropy_func().
void entropy_init | ( | entropy_context * | ctx | ) |
Initialize the context.
ctx | Entropy context to initialize |
Definition at line 39 of file entropy.c.
References entropy_add_source(), ENTROPY_MIN_HARDCLOCK, ENTROPY_MIN_HAVEGE, ENTROPY_MIN_PLATFORM, hardclock_poll(), havege_init(), platform_entropy_poll(), polarssl_mutex_init, sha256_starts(), and sha512_starts().
static int entropy_update | ( | entropy_context * | ctx, | |
unsigned char | source_id, | |||
const unsigned char * | data, | |||
size_t | len | |||
) | [static] |
Definition at line 100 of file entropy.c.
References entropy_context::accumulator, ENTROPY_BLOCK_SIZE, sha256(), sha256_update(), sha512(), and sha512_update().
Referenced by entropy_gather(), and entropy_update_manual().
int entropy_update_manual | ( | entropy_context * | ctx, | |
const unsigned char * | data, | |||
size_t | len | |||
) |
Add data to the accumulator manually.
ctx | Entropy context | |
data | Data to add | |
len | Length of data |
Definition at line 133 of file entropy.c.
References ENTROPY_SOURCE_MANUAL, and entropy_update().