From b13d3ffb80d6d86a281fc62c5c258d1afd17686a Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Wed, 26 Mar 2014 12:51:25 +0100 Subject: [PATCH] Provide no info from entropy_func() on future entropy --- library/entropy.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/library/entropy.c b/library/entropy.c index 5ee40826f..982892668 100644 --- a/library/entropy.c +++ b/library/entropy.c @@ -269,24 +269,19 @@ int entropy_func( void *data, unsigned char *output, size_t len ) #if defined(POLARSSL_ENTROPY_SHA512_ACCUMULATOR) sha512_finish( &ctx->accumulator, buf ); - /* - * Perform second SHA-512 on entropy - */ - sha512( buf, ENTROPY_BLOCK_SIZE, buf, 0 ); - /* * Reset accumulator and counters and recycle existing entropy */ memset( &ctx->accumulator, 0, sizeof( sha512_context ) ); sha512_starts( &ctx->accumulator, 0 ); sha512_update( &ctx->accumulator, buf, ENTROPY_BLOCK_SIZE ); -#else /* POLARSSL_ENTROPY_SHA512_ACCUMULATOR */ - sha256_finish( &ctx->accumulator, buf ); /* - * Perform second SHA-256 on entropy + * Perform second SHA-512 on entropy */ - sha256( buf, ENTROPY_BLOCK_SIZE, buf, 0 ); + sha512( buf, ENTROPY_BLOCK_SIZE, buf, 0 ); +#else /* POLARSSL_ENTROPY_SHA512_ACCUMULATOR */ + sha256_finish( &ctx->accumulator, buf ); /* * Reset accumulator and counters and recycle existing entropy @@ -294,6 +289,11 @@ int entropy_func( void *data, unsigned char *output, size_t len ) memset( &ctx->accumulator, 0, sizeof( sha256_context ) ); sha256_starts( &ctx->accumulator, 0 ); sha256_update( &ctx->accumulator, buf, ENTROPY_BLOCK_SIZE ); + + /* + * Perform second SHA-256 on entropy + */ + sha256( buf, ENTROPY_BLOCK_SIZE, buf, 0 ); #endif /* POLARSSL_ENTROPY_SHA512_ACCUMULATOR */ for( i = 0; i < ctx->source_count; i++ )