- Added HAVEGE as a default entropy source

This commit is contained in:
Paul Bakker 2011-12-15 19:49:30 +00:00
parent 543c8e46b6
commit 28c7e7f6fa
2 changed files with 17 additions and 0 deletions

View file

@ -29,7 +29,12 @@
#include <string.h>
#include "config.h"
#include "sha4.h"
#if defined(POLARSSL_HAVEGE_C)
#include "havege.h"
#endif
#define POLARSSL_ERR_ENTROPY_SOURCE_FAILED -0x003C /**< Critical entropy source failure. */
#define POLARSSL_ERR_ENTROPY_MAX_SOURCES -0x003E /**< No more sources can be added. */
@ -77,6 +82,9 @@ typedef struct
sha4_context accumulator;
int source_count;
source_state source[ENTROPY_MAX_SOURCES];
#if defined(POLARSSL_HAVEGE_C)
havege_state havege_data;
#endif
}
entropy_context;

View file

@ -30,6 +30,10 @@
#include "polarssl/entropy.h"
#include "polarssl/entropy_poll.h"
#if defined(POLARSSL_HAVEGE_C)
#include "polarssl/havege.h"
#endif
#define ENTROPY_MAX_LOOP 256 /**< Maximum amount to loop before error */
void entropy_init( entropy_context *ctx )
@ -45,6 +49,11 @@ void entropy_init( entropy_context *ctx )
#if defined(POLARSSL_TIMING_C)
entropy_add_source( ctx, hardclock_poll, NULL, ENTROPY_MIN_HARDCLOCK );
#endif
#if defined(POLARSSL_HAVEGE_C)
havege_init( &ctx->havege_data );
entropy_add_source( ctx, havege_poll, &ctx->havege_data,
ENTROPY_MIN_HAVEGE );
#endif
}
int entropy_add_source( entropy_context *ctx,