24 #ifndef POLARSSL_ENTROPY_H
25 #define POLARSSL_ENTROPY_H
27 #if !defined(POLARSSL_CONFIG_FILE)
30 #include POLARSSL_CONFIG_FILE
35 #if defined(POLARSSL_SHA512_C) && !defined(POLARSSL_ENTROPY_FORCE_SHA256)
37 #define POLARSSL_ENTROPY_SHA512_ACCUMULATOR
39 #if defined(POLARSSL_SHA256_C)
40 #define POLARSSL_ENTROPY_SHA256_ACCUMULATOR
45 #if defined(POLARSSL_THREADING_C)
49 #if defined(POLARSSL_HAVEGE_C)
53 #define POLARSSL_ERR_ENTROPY_SOURCE_FAILED -0x003C
54 #define POLARSSL_ERR_ENTROPY_MAX_SOURCES -0x003E
55 #define POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED -0x0040
56 #define POLARSSL_ERR_ENTROPY_FILE_IO_ERROR -0x0058
66 #if !defined(ENTROPY_MAX_SOURCES)
67 #define ENTROPY_MAX_SOURCES 20
70 #if !defined(ENTROPY_MAX_GATHER)
71 #define ENTROPY_MAX_GATHER 128
76 #if defined(POLARSSL_ENTROPY_SHA512_ACCUMULATOR)
77 #define ENTROPY_BLOCK_SIZE 64
79 #define ENTROPY_BLOCK_SIZE 32
82 #define ENTROPY_MAX_SEED_SIZE 1024
83 #define ENTROPY_SOURCE_MANUAL ENTROPY_MAX_SOURCES
100 typedef int (*
f_source_ptr)(
void *data,
unsigned char *output,
size_t len,
120 #if defined(POLARSSL_ENTROPY_SHA512_ACCUMULATOR)
127 #if defined(POLARSSL_HAVEGE_C)
130 #if defined(POLARSSL_THREADING_C)
131 threading_mutex_t mutex;
187 int entropy_func(
void *data,
unsigned char *output,
size_t len );
200 const unsigned char *data,
size_t len );
202 #if defined(POLARSSL_FS_IO)
230 #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.
#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.