From accfa803ec16d64e675f2be104692326ffd0258e Mon Sep 17 00:00:00 2001 From: "rrelyea%redhat.com" Date: Wed, 10 Jun 2009 03:24:01 +0000 Subject: [PATCH] Bug 497217 - The first random value ever generated by the RNG should be discarded r= nelson git-svn-id: svn://10.0.0.236/trunk@257454 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/security/nss/lib/freebl/drbg.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mozilla/security/nss/lib/freebl/drbg.c b/mozilla/security/nss/lib/freebl/drbg.c index 590f2caa899..101790b1995 100644 --- a/mozilla/security/nss/lib/freebl/drbg.c +++ b/mozilla/security/nss/lib/freebl/drbg.c @@ -36,7 +36,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/* $Id: drbg.c,v 1.8 2009-04-01 03:37:29 wtc%google.com Exp $ */ +/* $Id: drbg.c,v 1.9 2009-06-10 03:24:01 rrelyea%redhat.com Exp $ */ #ifdef FREEBL_NO_DEPEND #include "stubs.h" @@ -381,6 +381,9 @@ static PRStatus rng_init(void) PRUint8 bytes[PRNG_SEEDLEN*2]; /* entropy + nonce */ unsigned int numBytes; if (globalrng == NULL) { + /* bytes needs to have enough space to hold + * a SHA256 hash value. Blow up at compile time if this isn't true */ + PR_STATIC_ASSERT(sizeof(bytes) >= SHA256_LENGTH); /* create a new global RNG context */ globalrng = &theGlobalRng; PORT_Assert(NULL == globalrng->lock); @@ -414,6 +417,10 @@ static PRStatus rng_init(void) /* the RNG is in a valid state */ globalrng->isValid = PR_TRUE; + /* fetch one random value so that we can populate rng->oldV for our + * continous random number test. */ + prng_generateNewBytes(globalrng, bytes, SHA256_LENGTH, NULL, 0); + /* Fetch more entropy into the PRNG */ RNG_SystemInfoForRNG(); }