From: asterix Date: Mon, 12 Feb 2007 09:03:32 +0000 (+0000) Subject: Add CONFIG_RANDPOOL_TIMER macro to swich on or off timer support X-Git-Tag: 1.0.0~465 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=20ef0a88e1750885d5ac26160bf786a1e55d4777;p=bertos.git Add CONFIG_RANDPOOL_TIMER macro to swich on or off timer support git-svn-id: https://src.develer.com/svnoss/bertos/trunk@776 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/algos/randpool.c b/algos/randpool.c index 029f5ba1..58415efe 100755 --- a/algos/randpool.c +++ b/algos/randpool.c @@ -13,6 +13,9 @@ /*#* *#* $Log$ + *#* Revision 1.10 2007/02/12 09:03:32 asterix + *#* Add CONFIG_RANDPOOL_TIMER macro to swich on or off timer support + *#* *#* Revision 1.9 2007/02/09 17:58:09 asterix *#* Add macro CONFIG_RANDPOOL_TIMER. *#* @@ -27,21 +30,19 @@ #include "randpool.h" #include "md2.h" +#include //sprintf(); #include //memset(), memcpy(); + #include #include //ASSERT() #include //MIN() -#include //timer_clock(); -#include //sprintf(); - -//TODO: -#if CONFIG_RANDPOOL_TIMER - #define TIMER() timer_clock() -#else - #define TIMER() 0 //TODO: +#if CONFIG_RANDPOOL_TIMER + #include //timer_clock(); #endif + + /* * Insert bytes in entropy pool, making a XOR of bytes present * in entropy pool. @@ -109,17 +110,21 @@ static void randpool_stir(EntropyPool *pool) */ void randpool_add(EntropyPool *pool, void *data, size_t data_len, size_t entropy) { - ticks_t event = TIMER(); - uint32_t delta; uint8_t sep[] = "\xaa\xaa\xaa\xaa"; // ?? randpool_push(pool, data, data_len); //Insert data to entropy pool. randpool_push(pool, sep, strlen(sep)); // ?? +#if CONFIG_RANDPOOL_TIMER + + ticks_t event = timer_clock(); + uint32_t delta; + /*Difference of time between a two accese to entropy pool.*/ delta = event - pool->last_counter; + randpool_push(pool, &delta, sizeof(delta)); delta = delta & 0xff; @@ -135,6 +140,14 @@ void randpool_add(EntropyPool *pool, void *data, size_t data_len, size_t entropy entropy++; } +#else + size_t event = 0; + + /*Difference of time between a two accese to entropy pool.*/ + event = pool->last_counter++; + +#endif + pool->entropy += entropy; //Update a entropy of the pool. pool->last_counter = event; } @@ -145,9 +158,11 @@ void randpool_init(EntropyPool *pool) memset(pool, 0, sizeof(EntropyPool)); pool->pos_get = CONFIG_MD2_BLOCK_LEN; - pool->last_counter = TIMER(); - //TODO: inizializzazione del timer di sistema. +#if CONFIG_RANDPOOL_TIMER + pool->last_counter = timer_clock(); +#endif + }