8560c7e7db67191ac7ad30b4f7564741f6d8aca6
[bertos.git] / algos / randpool.h
1 /**
2  * \file
3  * <!--
4  * Copyright 2007 Develer S.r.l. (http://www.develer.com/);
5  * This file is part of DevLib - See README.devlib for information.
6  * -->
7  *
8  * \brief API function for to manage entropy pool.
9  *
10  *
11  * \version $Id$
12  * \author Daniele Basile <asterix@develer.com>
13  */
14
15 /*#*
16  *#* $Log$
17  *#* Revision 1.11  2007/02/15 13:54:26  asterix
18  *#* Rename randpool_getN in randpool_get. Fix bug in randpool_get.
19  *#*
20  *#* Revision 1.10  2007/02/15 13:40:42  asterix
21  *#* Fix bug in randpool_add and randpool_strir.
22  *#*
23  *#* Revision 1.9  2007/02/13 09:57:12  asterix
24  *#* Add directive #if in struct EntropyPool, and remove #else in randpool_add.
25  *#*
26  *#* Revision 1.8  2007/02/12 09:47:39  asterix
27  *#* Remove randpool_save. Add randpool_pool.
28  *#*
29  *#* Revision 1.6  2007/02/09 15:49:54  asterix
30  *#* Fix bug in randpool_stir and randpool_add. Typos.
31  *#*
32  *#* Revision 1.5  2007/02/09 09:24:38  asterix
33  *#* Typos. Add data_len in randpool_add and n_byte in randpool_push pototypes.
34  *#*
35  *#* Revision 1.4  2007/02/08 17:18:01  asterix
36  *#* Write add_data and stir function. Typos
37  *#*
38  *#* Revision 1.3  2007/02/08 14:25:56  asterix
39  *#* Typos.
40  *#*
41  *#* Revision 1.2  2007/02/08 11:53:03  asterix
42  *#* Add EntropyPool struct. Typos.
43  *#*
44  *#* Revision 1.1  2007/02/08 11:13:41  asterix
45  *#* Add function prototypes.
46  *#*
47  *#*/
48
49 #ifndef RANDPOOL_H 
50 #define RANDPOOL_H
51
52 #include <cfg/compiler.h>
53 #include <appconfig.h>
54
55
56 /**
57  * Sturct data of entropy pool.
58  */
59 typedef struct EntropyPool 
60 {
61         size_t entropy;                                  ///< Actual value of entropy (byte).
62         size_t pos_add;                                  ///< Number of byte  idd in entropy pool.
63         size_t pos_get;                                  ///< Number of byte get in entropy pool.
64         size_t counter;                                  ///< Counter.
65
66 #if CONFIG_RANDPOOL_TIMER
67         size_t last_counter;                             ///< Last timer value.
68 #endif
69
70         uint8_t pool_entropy[CONFIG_SIZE_ENTROPY_POOL];  ///< Entropy pool.
71
72 } EntropyPool;
73
74
75 void randpool_add(EntropyPool *pool, void *data, size_t entropy);
76 void randpool_init(EntropyPool *pool, void *_data, size_t len);
77 size_t randpool_size(EntropyPool *pool);
78 void randpool_get(EntropyPool *pool, void *data, size_t n_byte);
79 uint8_t *randpool_pool(EntropyPool *pool);
80
81 #endif /* RANDPOOL_H */