27 #ifndef POLARSSL_ENTROPY_H
28 #define POLARSSL_ENTROPY_H
35 #if defined(POLARSSL_HAVEGE_C)
39 #define POLARSSL_ERR_ENTROPY_SOURCE_FAILED -0x003C
40 #define POLARSSL_ERR_ENTROPY_MAX_SOURCES -0x003E
41 #define POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED -0x0040
42 #define POLARSSL_ERR_ENTROPY_FILE_IO_ERROR -0x0058
44 #if !defined(POLARSSL_CONFIG_OPTIONS)
45 #define ENTROPY_MAX_SOURCES 20
46 #define ENTROPY_MAX_GATHER 128
49 #define ENTROPY_BLOCK_SIZE 64
51 #define ENTROPY_MAX_SEED_SIZE 1024
52 #define ENTROPY_SOURCE_MANUAL ENTROPY_MAX_SOURCES
69 typedef int (*
f_source_ptr)(
void *,
unsigned char *, size_t,
size_t *);
91 #if defined(POLARSSL_HAVEGE_C)
137 int entropy_func(
void *data,
unsigned char *output,
size_t len );
149 const unsigned char *data,
size_t len );
151 #if defined(POLARSSL_FS_IO)
int entropy_add_source(entropy_context *ctx, f_source_ptr f_source, void *p_source, size_t threshold)
Adds an entropy source to poll.
int entropy_update_manual(entropy_context *ctx, const unsigned char *data, size_t len)
Add data to the accumulator manually.
Configuration options (set of defines)
int entropy_gather(entropy_context *ctx)
Trigger an extra gather poll for the accumulator.
Entropy context structure.
void * p_source
The callback data pointer.
int entropy_write_seed_file(entropy_context *ctx, const char *path)
Write a seed file.
SHA-384 and SHA-512 cryptographic hash function.
size_t size
Amount received.
f_source_ptr f_source
The entropy source callback.
HAVEGE: HArdware Volatile Entropy Gathering and Expansion.
#define ENTROPY_MAX_SOURCES
Maximum number of sources supported.
size_t threshold
Minimum level required before release.
SHA-512 context structure.
int entropy_update_seed_file(entropy_context *ctx, const char *path)
Read and update a seed file.
void entropy_init(entropy_context *ctx)
Initialize the context.
int(* f_source_ptr)(void *, unsigned char *, size_t, size_t *)
Entropy poll callback pointer.
int entropy_func(void *data, unsigned char *output, size_t len)
Retrieve entropy from the accumulator (Max ENTROPY_BLOCK_SIZE)