27 #ifndef POLARSSL_ENTROPY_H
28 #define POLARSSL_ENTROPY_H
34 #if defined(POLARSSL_SHA512_C)
36 #define POLARSSL_ENTROPY_SHA512_ACCUMULATOR
38 #if defined(POLARSSL_SHA256_C)
39 #define POLARSSL_ENTROPY_SHA256_ACCUMULATOR
44 #if defined(POLARSSL_THREADING_C)
48 #if defined(POLARSSL_HAVEGE_C)
52 #define POLARSSL_ERR_ENTROPY_SOURCE_FAILED -0x003C
53 #define POLARSSL_ERR_ENTROPY_MAX_SOURCES -0x003E
54 #define POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED -0x0040
56 #if !defined(POLARSSL_CONFIG_OPTIONS)
57 #define ENTROPY_MAX_SOURCES 20
58 #define ENTROPY_MAX_GATHER 128
61 #if defined(POLARSSL_ENTROPY_SHA512_ACCUMULATOR)
62 #define ENTROPY_BLOCK_SIZE 64
64 #define ENTROPY_BLOCK_SIZE 32
67 #define ENTROPY_SOURCE_MANUAL ENTROPY_MAX_SOURCES
84 typedef int (*
f_source_ptr)(
void *,
unsigned char *, size_t,
size_t *);
103 #if defined(POLARSSL_ENTROPY_SHA512_ACCUMULATOR)
110 #if defined(POLARSSL_HAVEGE_C)
113 #if defined(POLARSSL_THREADING_C)
114 threading_mutex_t mutex;
167 int entropy_func(
void *data,
unsigned char *output,
size_t len );
179 const unsigned char *data,
size_t len );
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.
sha512_context accumulator
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.
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.
size_t threshold
Minimum level required before release.
SHA-384 and SHA-512 cryptographic hash function.
SHA-256 context structure.
void entropy_init(entropy_context *ctx)
Initialize the context.
int(* f_source_ptr)(void *, unsigned char *, size_t, size_t *)
Entropy poll callback pointer.
SHA-224 and SHA-256 cryptographic hash function.
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 i...
void entropy_free(entropy_context *ctx)
Free the data in the context.