Test.
[bertos.git] / algo / randpool.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2007 Develer S.r.l. (http://www.develer.com/);
30  *
31  * -->
32  *
33  * \brief API function for to manage entropy pool.
34  *
35  *
36  * \version $Id$
37  * \author Daniele Basile <asterix@develer.com>
38  */
39
40 /*#*
41  *#* $Log$
42  *#* Revision 1.11  2007/02/15 13:54:26  asterix
43  *#* Rename randpool_getN in randpool_get. Fix bug in randpool_get.
44  *#*
45  *#* Revision 1.10  2007/02/15 13:40:42  asterix
46  *#* Fix bug in randpool_add and randpool_strir.
47  *#*
48  *#* Revision 1.9  2007/02/13 09:57:12  asterix
49  *#* Add directive #if in struct EntropyPool, and remove #else in randpool_add.
50  *#*
51  *#* Revision 1.8  2007/02/12 09:47:39  asterix
52  *#* Remove randpool_save. Add randpool_pool.
53  *#*
54  *#* Revision 1.6  2007/02/09 15:49:54  asterix
55  *#* Fix bug in randpool_stir and randpool_add. Typos.
56  *#*
57  *#* Revision 1.5  2007/02/09 09:24:38  asterix
58  *#* Typos. Add data_len in randpool_add and n_byte in randpool_push pototypes.
59  *#*
60  *#* Revision 1.4  2007/02/08 17:18:01  asterix
61  *#* Write add_data and stir function. Typos
62  *#*
63  *#* Revision 1.3  2007/02/08 14:25:56  asterix
64  *#* Typos.
65  *#*
66  *#* Revision 1.2  2007/02/08 11:53:03  asterix
67  *#* Add EntropyPool struct. Typos.
68  *#*
69  *#* Revision 1.1  2007/02/08 11:13:41  asterix
70  *#* Add function prototypes.
71  *#*
72  *#*/
73
74 #ifndef RANDPOOL_H 
75 #define RANDPOOL_H
76
77 #include <cfg/compiler.h>
78 #include <appconfig.h>
79
80
81 /**
82  * Sturct data of entropy pool.
83  */
84 typedef struct EntropyPool 
85 {
86         size_t entropy;                                  ///< Actual value of entropy (byte).
87         size_t pos_add;                                  ///< Number of byte  idd in entropy pool.
88         size_t pos_get;                                  ///< Number of byte get in entropy pool.
89         size_t counter;                                  ///< Counter.
90
91 #if CONFIG_RANDPOOL_TIMER
92         size_t last_counter;                             ///< Last timer value.
93 #endif
94
95         uint8_t pool_entropy[CONFIG_SIZE_ENTROPY_POOL];  ///< Entropy pool.
96
97 } EntropyPool;
98
99
100 void randpool_add(EntropyPool *pool, void *data, size_t entropy);
101 void randpool_init(EntropyPool *pool, void *_data, size_t len);
102 size_t randpool_size(EntropyPool *pool);
103 void randpool_get(EntropyPool *pool, void *data, size_t n_byte);
104 uint8_t *randpool_pool(EntropyPool *pool);
105
106 #endif /* RANDPOOL_H */