PolarSSL v1.2.11
entropy.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_ENTROPY_H
28 #define POLARSSL_ENTROPY_H
29 
30 #include <string.h>
31 
32 #include "config.h"
33 
34 #include "sha4.h"
35 #if defined(POLARSSL_HAVEGE_C)
36 #include "havege.h"
37 #endif
38 
39 #define POLARSSL_ERR_ENTROPY_SOURCE_FAILED -0x003C
40 #define POLARSSL_ERR_ENTROPY_MAX_SOURCES -0x003E
41 #define POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED -0x0040
42 #define POLARSSL_ERR_ENTROPY_FILE_IO_ERROR -0x0058
44 #if !defined(POLARSSL_CONFIG_OPTIONS)
45 #define ENTROPY_MAX_SOURCES 20
46 #define ENTROPY_MAX_GATHER 128
47 #endif /* !POLARSSL_CONFIG_OPTIONS */
48 
49 #define ENTROPY_BLOCK_SIZE 64
51 #define ENTROPY_MAX_SEED_SIZE 1024
52 #define ENTROPY_SOURCE_MANUAL ENTROPY_MAX_SOURCES
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
69 typedef int (*f_source_ptr)(void *, unsigned char *, size_t, size_t *);
70 
74 typedef struct
75 {
77  void * p_source;
78  size_t size;
79  size_t threshold;
80 }
82 
86 typedef struct
87 {
91 #if defined(POLARSSL_HAVEGE_C)
92  havege_state havege_data;
93 #endif
94 }
96 
102 void entropy_init( entropy_context *ctx );
103 
116  f_source_ptr f_source, void *p_source,
117  size_t threshold );
118 
126 int entropy_gather( entropy_context *ctx );
127 
137 int entropy_func( void *data, unsigned char *output, size_t len );
138 
149  const unsigned char *data, size_t len );
150 
151 #if defined(POLARSSL_FS_IO)
152 
162 int entropy_write_seed_file( entropy_context *ctx, const char *path );
163 
176 int entropy_update_seed_file( entropy_context *ctx, const char *path );
177 #endif
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #endif /* entropy.h */