コード例 #1
0
ファイル: fortuna.c プロジェクト: jaiminpan/bizgres
/*
 * update pools
 */
static void
add_entropy(FState * st, const uint8 *data, unsigned len)
{
	unsigned	pos;
	uint8		hash[BLOCK];
	MD_CTX		md;

	/* hash given data */
	md_init(&md);
	md_update(&md, data, len);
	md_result(&md, hash);

	/*
	 * Make sure the pool 0 is initialized, then update randomly.
	 */
	if (st->reseed_count == 0 && st->pool0_bytes < POOL0_FILL)
		pos = 0;
	else
		pos = get_rand_pool(st);
	md_update(&st->pool[pos], hash, BLOCK);

	if (pos == 0)
		st->pool0_bytes += len;

	memset(hash, 0, BLOCK);
	memset(&md, 0, sizeof(md));
}
コード例 #2
0
ファイル: fortuna.c プロジェクト: anandab/akaros
/*
 * update pools
 */
static void add_entropy(FState *st, const uint8_t *data, unsigned len)
{
	unsigned pos;
	uint8_t hash[block];
	mdCtx md;

	/* hash given data */
	md_init(&md);
	md_update(&md, data, len);
	md_result(&md, hash);

	/*
	 * Make sure the pool 0 is initialized, then update randomly.
	 */
	if (st->reseedCount == 0)
		pos = 0;
	else
		pos = get_rand_pool(st);
	md_update(&st->pool[pos], hash, block);

	if (pos == 0)
		st->pool0Bytes += len;

	memset(hash, 0, block);
	memset(&md, 0, sizeof(md));
}