28 #if defined(POLARSSL_ENTROPY_C)
33 #if defined(POLARSSL_HAVEGE_C)
37 #define ENTROPY_MAX_LOOP 256
39 void entropy_init( entropy_context *ctx )
44 #if defined(POLARSSL_HAVEGE_C)
48 #if !defined(POLARSSL_NO_DEFAULT_ENTROPY_SOURCES)
49 #if !defined(POLARSSL_NO_PLATFORM_ENTROPY)
53 #if defined(POLARSSL_TIMING_C)
56 #if defined(POLARSSL_HAVEGE_C)
85 const unsigned char *data,
size_t len )
87 unsigned char header[2];
90 const unsigned char *p = data;
94 sha4( data, len, tmp, 0 );
100 header[0] = source_id;
101 header[1] = use_len & 0xFF;
110 const unsigned char *data,
size_t len )
144 entropy_update( ctx, (
unsigned char) i, buf, olen );
152 int entropy_func(
void *data,
unsigned char *output,
size_t len )
154 int ret, count = 0, i, reached;
166 if( count++ > ENTROPY_MAX_LOOP )
199 memcpy( output, buf, 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.
#define ENTROPY_MIN_PLATFORM
Minimum for platform source.
int entropy_update_manual(entropy_context *ctx, const unsigned char *data, size_t len)
Add data to the accumulator manually.
#define POLARSSL_ERR_ENTROPY_MAX_SOURCES
No more sources can be added.
Configuration options (set of defines)
int entropy_gather(entropy_context *ctx)
Trigger an extra gather poll for the accumulator.
#define ENTROPY_MIN_HARDCLOCK
Minimum for hardclock()
Entropy context structure.
#define ENTROPY_MAX_GATHER
Maximum amount requested from entropy sources.
void * p_source
The callback data pointer.
Platform-specific and custom entropy polling functions.
Entropy accumulator implementation.
#define ENTROPY_SOURCE_MANUAL
source_state source[ENTROPY_MAX_SOURCES]
#define ENTROPY_BLOCK_SIZE
Block size of entropy accumulator (SHA-512)
void sha4_starts(sha4_context *ctx, int is384)
SHA-512 context setup.
#define ENTROPY_MIN_HAVEGE
Minimum for HAVEGE.
size_t size
Amount received.
f_source_ptr f_source
The entropy source callback.
void sha4_update(sha4_context *ctx, const unsigned char *input, size_t ilen)
SHA-512 process buffer.
HAVEGE: HArdware Volatile Entropy Gathering and Expansion.
int platform_entropy_poll(void *data, unsigned char *output, size_t len, size_t *olen)
Platform-specific entropy poll callback.
#define ENTROPY_MAX_SOURCES
Maximum number of sources supported.
void havege_init(havege_state *hs)
HAVEGE initialization.
void sha4(const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
Output = SHA-512( input buffer )
size_t threshold
Minimum level required before release.
#define POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED
No sources have been added to poll.
SHA-512 context structure.
void sha4_finish(sha4_context *ctx, unsigned char output[64])
SHA-512 final digest.
#define POLARSSL_ERR_ENTROPY_SOURCE_FAILED
Critical entropy source failure.
int(* f_source_ptr)(void *, unsigned char *, size_t, size_t *)
Entropy poll callback pointer.
int hardclock_poll(void *data, unsigned char *output, size_t len, size_t *olen)
hardclock-based entropy poll callback
int entropy_func(void *data, unsigned char *output, size_t len)
Retrieve entropy from the accumulator (Max ENTROPY_BLOCK_SIZE)