7556494337e3cf2a7a369835aef13d30c0916da4
[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.5  2007/02/09 09:24:38  asterix
18  *#* Typos. Add data_len in randpool_add and n_byte in randpool_push pototypes.
19  *#*
20  *#* Revision 1.4  2007/02/08 17:18:01  asterix
21  *#* Write add_data and stir function. Typos
22  *#*
23  *#* Revision 1.3  2007/02/08 14:25:56  asterix
24  *#* Typos.
25  *#*
26  *#* Revision 1.2  2007/02/08 11:53:03  asterix
27  *#* Add EntrPool struct. Typos.
28  *#*
29  *#* Revision 1.1  2007/02/08 11:13:41  asterix
30  *#* Add function prototypes.
31  *#*
32  *#*/
33
34 #ifndef RANDPOOL_H 
35 #define RANDPOOL_H
36
37 #include <cfg/compiler.h>
38 #include <appconfig.h>
39
40 /**
41  * Sturct data of entropy pool.
42  */
43 typedef struct EntrPool 
44 {
45         size_t entropy;                                  ///< Actual value of entropy (byte).
46         size_t pos_add;                                  ///< Size of byte insert in entropy pool.
47         size_t pos_get;                                  ///< Size of byte take in entropy pool.
48         size_t counter;                                  ///< Counter.
49         size_t last_counter;                             ///< Last timer value.
50         uint8_t pool_entropy[CONFIG_SIZE_ENTROPY_POOL];  ///< Entropy pool.
51
52 } EntrPool;
53
54
55 void randpool_add(EntrPool *pool, void *data, size_t data_len, size_t entropy);
56 void randpool_init(EntrPool *pool);
57 size_t randpool_size(EntrPool *pool);
58 void randpool_get(EntrPool *pool, void *data, size_t n_byte);
59 void randpool_getN(EntrPool *pool, void *data, size_t n_byte);
60 bool randpool_save(void *data);
61 uint8_t *randpool_load(void);
62
63 #endif /* RANDPOOL_H */