- Merged Trunk changes for 1.1 into branch
diff --git a/library/entropy.c b/library/entropy.c
index bc0e141..9662454 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 )
@@ -37,7 +41,11 @@
memset( ctx, 0, sizeof(entropy_context) );
sha4_starts( &ctx->accumulator, 0 );
+#if defined(POLARSSL_HAVEGE_C)
+ havege_init( &ctx->havege_data );
+#endif
+#if !defined(POLARSSL_NO_DEFAULT_ENTROPY_SOURCES)
#if !defined(POLARSSL_NO_PLATFORM_ENTROPY)
entropy_add_source( ctx, platform_entropy_poll, NULL,
ENTROPY_MIN_PLATFORM );
@@ -45,6 +53,11 @@
#if defined(POLARSSL_TIMING_C)
entropy_add_source( ctx, hardclock_poll, NULL, ENTROPY_MIN_HARDCLOCK );
#endif
+#if defined(POLARSSL_HAVEGE_C)
+ entropy_add_source( ctx, havege_poll, &ctx->havege_data,
+ ENTROPY_MIN_HAVEGE );
+#endif
+#endif /* POLARSSL_NO_DEFAULT_ENTROPY_SOURCES */
}
int entropy_add_source( entropy_context *ctx,
@@ -108,6 +121,9 @@
unsigned char buf[ENTROPY_MAX_GATHER];
size_t olen;
+ if( ctx->source_count == 0 )
+ return( POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED );
+
/*
* Run through our entropy sources
*/
diff --git a/library/error.c b/library/error.c
index 05e84e7..5dcd175 100644
--- a/library/error.c
+++ b/library/error.c
@@ -436,6 +436,8 @@
snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" );
if( use_ret == -(POLARSSL_ERR_ENTROPY_MAX_SOURCES) )
snprintf( buf, buflen, "ENTROPY - No more sources can be added" );
+ if( use_ret == -(POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED) )
+ snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" );
#endif /* POLARSSL_ENTROPY_C */
#if defined(POLARSSL_MD2_C)
diff --git a/library/net.c b/library/net.c
index 85c4e79..9724c07 100644
--- a/library/net.c
+++ b/library/net.c
@@ -227,7 +227,8 @@
{
struct sockaddr_in client_addr;
-#if defined(__socklen_t_defined) || defined(_SOCKLEN_T)
+#if defined(__socklen_t_defined) || defined(_SOCKLEN_T) || \
+ defined(_SOCKLEN_T_DECLARED)
socklen_t n = (socklen_t) sizeof( client_addr );
#else
int n = (int) sizeof( client_addr );