API Documentation (Doxygen generated)

These pages are generated with doxygen directly from the source code!

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 #if defined(POLARSSL_SHA512_C) && !defined(POLARSSL_ENTROPY_FORCE_SHA256)
35 #include "sha512.h"
36 #define POLARSSL_ENTROPY_SHA512_ACCUMULATOR
37 #else
38 #if defined(POLARSSL_SHA256_C)
39 #define POLARSSL_ENTROPY_SHA256_ACCUMULATOR
40 #include "sha256.h"
41 #endif
42 #endif
43 
44 #if defined(POLARSSL_THREADING_C)
45 #include "threading.h"
46 #endif
47 
48 #if defined(POLARSSL_HAVEGE_C)
49 #include "havege.h"
50 #endif
51 
52 #define POLARSSL_ERR_ENTROPY_SOURCE_FAILED -0x003C
53 #define POLARSSL_ERR_ENTROPY_MAX_SOURCES -0x003E
54 #define POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED -0x0040
55 #define POLARSSL_ERR_ENTROPY_FILE_IO_ERROR -0x0058
57 #if !defined(POLARSSL_CONFIG_OPTIONS)
58 #define ENTROPY_MAX_SOURCES 20
59 #define ENTROPY_MAX_GATHER 128
60 #endif /* !POLARSSL_CONFIG_OPTIONS */
61 
62 #if defined(POLARSSL_ENTROPY_SHA512_ACCUMULATOR)
63 #define ENTROPY_BLOCK_SIZE 64
64 #else
65 #define ENTROPY_BLOCK_SIZE 32
66 #endif
67 
68 #define ENTROPY_MAX_SEED_SIZE 1024
69 #define ENTROPY_SOURCE_MANUAL ENTROPY_MAX_SOURCES
70 
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74 
86 typedef int (*f_source_ptr)(void *data, unsigned char *output, size_t len,
87  size_t *olen);
88 
92 typedef struct
93 {
95  void * p_source;
96  size_t size;
97  size_t threshold;
98 }
100 
104 typedef struct
105 {
106 #if defined(POLARSSL_ENTROPY_SHA512_ACCUMULATOR)
108 #else
109  sha256_context accumulator;
110 #endif
113 #if defined(POLARSSL_HAVEGE_C)
114  havege_state havege_data;
115 #endif
116 #if defined(POLARSSL_THREADING_C)
117  threading_mutex_t mutex;
118 #endif
119 }
121 
127 void entropy_init( entropy_context *ctx );
128 
134 void entropy_free( entropy_context *ctx );
135 
149  f_source_ptr f_source, void *p_source,
150  size_t threshold );
151 
160 int entropy_gather( entropy_context *ctx );
161 
172 int entropy_func( void *data, unsigned char *output, size_t len );
173 
185  const unsigned char *data, size_t len );
186 
187 #if defined(POLARSSL_FS_IO)
188 
198 int entropy_write_seed_file( entropy_context *ctx, const char *path );
199 
212 int entropy_update_seed_file( entropy_context *ctx, const char *path );
213 #endif
214 
215 #ifdef __cplusplus
216 }
217 #endif
218 
219 #endif /* entropy.h */