From: asterix Date: Thu, 8 Feb 2007 14:25:29 +0000 (+0000) Subject: Write static funcion push_byte. X-Git-Tag: 1.0.0~473 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=43cc9dde2073972fc586ee95d2de5797d654f6cb;p=bertos.git Write static funcion push_byte. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@768 38d2e660-2303-0410-9eaa-f027e97ec537 --- 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) { }