X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Falgo%2Frandpool.c;h=45bf52851321c2bf418633cef82532073d70ff33;hb=cb382ef2759a551342924626d01f902441ec928a;hp=0fc2ee9db667da8b35b1635264974a2ad83912e8;hpb=d62963b4a64efe8d2917f489fefaf586a9a99126;p=bertos.git diff --git a/bertos/algo/randpool.c b/bertos/algo/randpool.c index 0fc2ee9d..45bf5285 100644 --- a/bertos/algo/randpool.c +++ b/bertos/algo/randpool.c @@ -66,10 +66,11 @@ static void randpool_push(EntropyPool *pool, void *_byte, size_t n_byte) /* * Insert a bytes in entropy pool. */ - for(int j = 0; j < n_byte; j++) + for(size_t j = 0; j < n_byte; j++) { pool->pool_entropy[i] = pool->pool_entropy[i] ^ byte[j]; - i = (++i) % CONFIG_SIZE_ENTROPY_POOL; + i++; + i = i % CONFIG_SIZE_ENTROPY_POOL; } pool->pos_add = i; // Update a insert bytes. @@ -92,7 +93,7 @@ static void randpool_stir(EntropyPool *pool) for (int i = 0; i < (CONFIG_SIZE_ENTROPY_POOL / MD2_DIGEST_LEN); i++) { - sprintf(tmp_buf, "%0x%0x%0x",pool->counter, i, pool->pos_add); + sprintf((char *)tmp_buf, "%0x%0x%0x", pool->counter, i, pool->pos_add); /* * Hash with MD2 algorithm the entropy pool. @@ -245,10 +246,6 @@ void randpool_get(EntropyPool *pool, void *_data, size_t n_byte) pool->pos_get = i; //Current number of byte we get from pool. pool->entropy -= n_byte; //Update a entropy. - /*If we get all entropy entropy is 0*/ - if(pool->entropy < 0) - pool->entropy = 0; - } /**