From 124f90e3dc93d24f24d2bc11c7afaa9fdbbf5fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Wed, 20 Jun 2007 05:08:58 +0000 Subject: [PATCH] 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 --- lib/hcrypto/rand-fortuna.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/hcrypto/rand-fortuna.c b/lib/hcrypto/rand-fortuna.c index 645ceeba4..de83b3cce 100644 --- a/lib/hcrypto/rand-fortuna.c +++ b/lib/hcrypto/rand-fortuna.c @@ -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; }