mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-10-30 11:11:12 -04:00 
			
		
		
		
	- Added HAVEGE as a default entropy source
This commit is contained in:
		
							parent
							
								
									543c8e46b6
								
							
						
					
					
						commit
						28c7e7f6fa
					
				| @ -29,7 +29,12 @@ | |||||||
| 
 | 
 | ||||||
| #include <string.h> | #include <string.h> | ||||||
| 
 | 
 | ||||||
|  | #include "config.h" | ||||||
|  | 
 | ||||||
| #include "sha4.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_SOURCE_FAILED                 -0x003C  /**< Critical entropy source failure. */ | ||||||
| #define POLARSSL_ERR_ENTROPY_MAX_SOURCES                   -0x003E  /**< No more sources can be added. */ | #define POLARSSL_ERR_ENTROPY_MAX_SOURCES                   -0x003E  /**< No more sources can be added. */ | ||||||
| @ -77,6 +82,9 @@ typedef struct | |||||||
|     sha4_context    accumulator; |     sha4_context    accumulator; | ||||||
|     int             source_count; |     int             source_count; | ||||||
|     source_state    source[ENTROPY_MAX_SOURCES]; |     source_state    source[ENTROPY_MAX_SOURCES]; | ||||||
|  | #if defined(POLARSSL_HAVEGE_C) | ||||||
|  |     havege_state    havege_data; | ||||||
|  | #endif | ||||||
| } | } | ||||||
| entropy_context; | entropy_context; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -30,6 +30,10 @@ | |||||||
| #include "polarssl/entropy.h" | #include "polarssl/entropy.h" | ||||||
| #include "polarssl/entropy_poll.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 */ | #define ENTROPY_MAX_LOOP    256     /**< Maximum amount to loop before error */ | ||||||
| 
 | 
 | ||||||
| void entropy_init( entropy_context *ctx ) | void entropy_init( entropy_context *ctx ) | ||||||
| @ -45,6 +49,11 @@ void entropy_init( entropy_context *ctx ) | |||||||
| #if defined(POLARSSL_TIMING_C) | #if defined(POLARSSL_TIMING_C) | ||||||
|     entropy_add_source( ctx, hardclock_poll, NULL, ENTROPY_MIN_HARDCLOCK ); |     entropy_add_source( ctx, hardclock_poll, NULL, ENTROPY_MIN_HARDCLOCK ); | ||||||
| #endif | #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, | int entropy_add_source( entropy_context *ctx, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Paul Bakker
						Paul Bakker