PolarSSL v1.2.8
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
43 #if !defined(POLARSSL_CONFIG_OPTIONS)
44 #define ENTROPY_MAX_SOURCES 20
45 #define ENTROPY_MAX_GATHER 128
46 #endif /* !POLARSSL_CONFIG_OPTIONS */
47 
48 #define ENTROPY_BLOCK_SIZE 64
50 #define ENTROPY_SOURCE_MANUAL ENTROPY_MAX_SOURCES
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
67 typedef int (*f_source_ptr)(void *, unsigned char *, size_t, size_t *);
68 
72 typedef struct
73 {
75  void * p_source;
76  size_t size;
77  size_t threshold;
78 }
80 
84 typedef struct
85 {
89 #if defined(POLARSSL_HAVEGE_C)
90  havege_state havege_data;
91 #endif
92 }
94 
100 void entropy_init( entropy_context *ctx );
101 
114  f_source_ptr f_source, void *p_source,
115  size_t threshold );
116 
124 int entropy_gather( entropy_context *ctx );
125 
135 int entropy_func( void *data, unsigned char *output, size_t len );
136 
147  const unsigned char *data, size_t len );
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #endif /* entropy.h */