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