Reseed the random generator now and then from external sources.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21196 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2007-06-20 05:08:58 +00:00
parent ab41f4906d
commit 124f90e3dc

View File

@@ -427,6 +427,8 @@ extract_data(FState * st, unsigned count, unsigned char *dst)
static FState main_state;
static int init_done;
static int have_entropy;
#define FORTUNA_RESEED_BYTE 10000
static unsigned resend_bytes;
/*
* Try our best to do an inital seed
@@ -546,6 +548,11 @@ fortuna_bytes(unsigned char *outdata, int size)
{
if (!fortuna_init())
return 0;
resend_bytes += size;
if (resend_bytes > FORTUNA_RESEED_BYTE || resend_bytes < size) {
resend_bytes = 0;
fortuna_reseed();
}
extract_data(&main_state, size, outdata);
return 1;
}