- Added HAVEGE as a default entropy source
diff --git a/include/polarssl/entropy.h b/include/polarssl/entropy.h
index aeec8b2..6dea79a 100644
--- a/include/polarssl/entropy.h
+++ b/include/polarssl/entropy.h
@@ -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 @@
sha4_context accumulator;
int source_count;
source_state source[ENTROPY_MAX_SOURCES];
+#if defined(POLARSSL_HAVEGE_C)
+ havege_state havege_data;
+#endif
}
entropy_context;
diff --git a/library/entropy.c b/library/entropy.c
index bc0e141..ebace08 100644
--- a/library/entropy.c
+++ b/library/entropy.c
@@ -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 @@
#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,