27 #ifndef POLARSSL_ENTROPY_H 28 #define POLARSSL_ENTROPY_H 32 #if !defined(POLARSSL_CONFIG_FILE) 35 #include POLARSSL_CONFIG_FILE 38 #if defined(POLARSSL_SHA512_C) && !defined(POLARSSL_ENTROPY_FORCE_SHA256) 40 #define POLARSSL_ENTROPY_SHA512_ACCUMULATOR 42 #if defined(POLARSSL_SHA256_C) 43 #define POLARSSL_ENTROPY_SHA256_ACCUMULATOR 48 #if defined(POLARSSL_THREADING_C) 52 #if defined(POLARSSL_HAVEGE_C) 56 #define POLARSSL_ERR_ENTROPY_SOURCE_FAILED -0x003C 57 #define POLARSSL_ERR_ENTROPY_MAX_SOURCES -0x003E 58 #define POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED -0x0040 59 #define POLARSSL_ERR_ENTROPY_FILE_IO_ERROR -0x0058 69 #if !defined(ENTROPY_MAX_SOURCES) 70 #define ENTROPY_MAX_SOURCES 20 73 #if !defined(ENTROPY_MAX_GATHER) 74 #define ENTROPY_MAX_GATHER 128 79 #if defined(POLARSSL_ENTROPY_SHA512_ACCUMULATOR) 80 #define ENTROPY_BLOCK_SIZE 64 82 #define ENTROPY_BLOCK_SIZE 32 85 #define ENTROPY_MAX_SEED_SIZE 1024 86 #define ENTROPY_SOURCE_MANUAL ENTROPY_MAX_SOURCES 103 typedef int (*
f_source_ptr)(
void *data,
unsigned char *output,
size_t len,
123 #if defined(POLARSSL_ENTROPY_SHA512_ACCUMULATOR) 130 #if defined(POLARSSL_HAVEGE_C) 133 #if defined(POLARSSL_THREADING_C) 190 int entropy_func(
void *data,
unsigned char *output,
size_t len );
203 const unsigned char *data,
size_t len );
205 #if defined(POLARSSL_FS_IO) 233 #if defined(POLARSSL_SELF_TEST)
int entropy_add_source(entropy_context *ctx, f_source_ptr f_source, void *p_source, size_t threshold)
Adds an entropy source to poll (Thread-safe if POLARSSL_THREADING_C is enabled)
int entropy_update_manual(entropy_context *ctx, const unsigned char *data, size_t len)
Add data to the accumulator manually (Thread-safe if POLARSSL_THREADING_C is enabled) ...
sha512_context accumulator
Configuration options (set of defines)
int entropy_gather(entropy_context *ctx)
Trigger an extra gather poll for the accumulator (Thread-safe if POLARSSL_THREADING_C is enabled) ...
Entropy context structure.
void * p_source
The callback data pointer.
int(* f_source_ptr)(void *data, unsigned char *output, size_t len, size_t *olen)
Entropy poll callback pointer.
int entropy_write_seed_file(entropy_context *ctx, const char *path)
Write a seed file.
Threading abstraction layer.
size_t size
Amount received.
f_source_ptr f_source
The entropy source callback.
SHA-512 context structure.
HAVEGE: HArdware Volatile Entropy Gathering and Expansion.
pthread_mutex_t threading_mutex_t
#define ENTROPY_MAX_SOURCES
Maximum number of sources supported.
int entropy_self_test(int verbose)
Checkup routine.
size_t threshold
Minimum level required before release.
SHA-384 and SHA-512 cryptographic hash function.
int entropy_update_seed_file(entropy_context *ctx, const char *path)
Read and update a seed file.
SHA-256 context structure.
void entropy_init(entropy_context *ctx)
Initialize the context.
SHA-224 and SHA-256 cryptographic hash function.
int entropy_func(void *data, unsigned char *output, size_t len)
Retrieve entropy from the accumulator (Maximum length: ENTROPY_BLOCK_SIZE) (Thread-safe if POLARSSL_T...
void entropy_free(entropy_context *ctx)
Free the data in the context.