+/*
+ * This function stir entropy pool with MD2 function hash.
+ *
+ */
+static void randpool_stir(EntropyPool *pool)
+{
+ size_t entropy = pool->entropy; //Save current calue of entropy.
+ Md2Context context;
+ uint8_t tmp_buf[((sizeof(size_t) * 2) + sizeof(int)) * 2 + 1]; //Temporary buffer.
+
+ md2_init(&context); //Init MD2 algorithm.
+
+ randpool_add(pool, NULL, 0);
+
+ 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);
+
+ /*
+ * Hash with MD2 algorithm the entropy pool.
+ */
+ md2_update(&context, pool->pool_entropy, CONFIG_SIZE_ENTROPY_POOL);
+
+ md2_update(&context, tmp_buf, sizeof(tmp_buf) - 1);
+
+ /*Insert a message digest in entropy pool.*/
+ randpool_push(pool, md2_end(&context), MD2_DIGEST_LEN);
+
+ pool->counter = pool->counter + 1;
+
+ }
+
+ /*Insert in pool the difference between a two call of this function (see above).*/
+ randpool_add(pool, NULL, 0);
+
+ pool->entropy = entropy; //Restore old value of entropy. We haven't add entropy.
+}
+