Write static funcion push_byte.
[bertos.git] / algos / randpool.c
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  * \version $Id$
11  * \author Daniele Basile <asterix@develer.com>
12  */
13
14 /*#*
15  *#* $Log$
16  *#* Revision 1.3  2007/02/08 14:25:29  asterix
17  *#* Write static funcion push_byte.
18  *#*
19  *#*/
20
21 #include "randpool.h"
22 #include "md2.h"
23
24 #include <string.h>            //memset(), memcpy();
25 #include <cfg/compiler.h>
26 #include <cfg/debug.h>        //ASSERT()
27
28 static void stir(EntrPool *pool)
29 {
30         
31 }
32
33 /*
34  * Insert bytes in entropy pool, making a XOR of bytes present
35  * in entropy pool.
36  */
37 static void push_byte(EntrPool *pool, void *_byte)
38 {
39         size_t i = pool->pool_pos_add; // Current number of byte insert in entropy pool.
40         size_t len_byte;
41         uint8_t *byte;
42
43                 
44         byte = (uint8_t *)_byte;
45         len_byte = strlen(byte);
46
47         /*
48          * Insert a bytes in entropy pool.
49          */
50         for(int j = 0; j < len_byte; j++)
51         {
52                 pool->pool_entropy[i] = pool->pool_entropy[i] ^ byte[j];
53                 i = (i++) % CONFIG_SIZE_ENTROPY_POOL;
54         }
55
56         pool->pool_pos_add  =  i; // Update a insert bytes.
57 }
58
59 void init_pool(EntrPool *pool)
60 {
61         
62         memset(pool, 0, sizeof(EntrPool));
63
64 }
65
66 void add_data(EntrPool *pool, void *data, size_t n_bit)
67 {
68
69 }
70
71 size_t pool_size(EntrPool *pool)
72 {
73 }
74
75 void get_bit(EntrPool *pool, void *data, size_t n_bit)
76 {
77 }
78
79 void get_bit_n(EntrPool *pool, void *data, size_t n_bit)
80 {
81 }
82
83 bool save_pool(void *data)
84 {
85 }
86
87 uint8_t *load_pool(void)
88 {
89 }
90