X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=algos%2Frandpool.c;h=b7f090b92daeabe6b805db3fcddcef84686a384f;hb=43cc9dde2073972fc586ee95d2de5797d654f6cb;hp=42d50d5565716cc10799f759296824ec95d0510a;hpb=775a4c184ac4b83d0a0a6d1cef015ad912c769bc;p=bertos.git diff --git a/algos/randpool.c b/algos/randpool.c index 42d50d55..b7f090b9 100755 --- a/algos/randpool.c +++ b/algos/randpool.c @@ -13,46 +13,78 @@ /*#* *#* $Log$ - *#* Revision 1.2 2007/02/08 11:53:03 asterix - *#* Add EntrPool struct. Typos. + *#* Revision 1.3 2007/02/08 14:25:29 asterix + *#* Write static funcion push_byte. *#* *#*/ #include "randpool.h" #include "md2.h" +#include //memset(), memcpy(); #include #include //ASSERT() static void stir(EntrPool *pool) { + } -void init_pool(EntrPool *pool); +/* + * Insert bytes in entropy pool, making a XOR of bytes present + * in entropy pool. + */ +static void push_byte(EntrPool *pool, void *_byte) { + size_t i = pool->pool_pos_add; // Current number of byte insert in entropy pool. + size_t len_byte; + uint8_t *byte; + + + byte = (uint8_t *)_byte; + len_byte = strlen(byte); + + /* + * Insert a bytes in entropy pool. + */ + for(int j = 0; j < len_byte; j++) + { + pool->pool_entropy[i] = pool->pool_entropy[i] ^ byte[j]; + i = (i++) % CONFIG_SIZE_ENTROPY_POOL; + } + + pool->pool_pos_add = i; // Update a insert bytes. } -void add_data(EntrPool *pool, void *data, size_t n_bit); +void init_pool(EntrPool *pool) { + + memset(pool, 0, sizeof(EntrPool)); + +} + +void add_data(EntrPool *pool, void *data, size_t n_bit) +{ + } -size_t pool_size(EntrPool *pool); +size_t pool_size(EntrPool *pool) { } -void get_bit(EntrPool *pool, void *data, size_t n_bit); +void get_bit(EntrPool *pool, void *data, size_t n_bit) { } -void get_bit_n(EntrPool *pool, void *data, size_t n_bit); +void get_bit_n(EntrPool *pool, void *data, size_t n_bit) { } -bool save_pool(void *data); +bool save_pool(void *data) { } -uint8_t *load_pool(void); +uint8_t *load_pool(void) { }