From 43cc9dde2073972fc586ee95d2de5797d654f6cb Mon Sep 17 00:00:00 2001 From: asterix Date: Thu, 8 Feb 2007 14:25:29 +0000 Subject: [PATCH] Write static funcion push_byte. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@768 38d2e660-2303-0410-9eaa-f027e97ec537 --- algos/randpool.c | 50 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) 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) { } -- 2.25.1