From: Mark Andrews Date: Tue, 20 Oct 2009 04:47:52 +0000 (+0000) Subject: 2721. [port] Have dst__entropy_status() prime the random number X-Git-Tag: v9.5.2-P1~1^5~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f52e23ca824489ba6d7e72108297902de5fed1f;p=thirdparty%2Fbind9.git 2721. [port] Have dst__entropy_status() prime the random number generator. [RT #20369] --- diff --git a/CHANGES b/CHANGES index c79121bca96..78104b93d6a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +2721. [port] Have dst__entropy_status() prime the random number + generator. [RT #20369] + 2718. [bug] The space calculations in opensslrsa_todns() were incorrect. [RT #20394] diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index 2c0987a1770..21a0a67b2a8 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -31,7 +31,7 @@ /* * Principal Author: Brian Wellington - * $Id: dst_api.c,v 1.11.92.9 2009/09/25 01:48:10 marka Exp $ + * $Id: dst_api.c,v 1.11.92.10 2009/10/20 04:47:52 marka Exp $ */ /*! \file */ @@ -1256,6 +1256,9 @@ addsuffix(char *filename, unsigned int len, const char *ofilename, isc_result_t dst__entropy_getdata(void *buf, unsigned int len, isc_boolean_t pseudo) { unsigned int flags = dst_entropy_flags; + + if (len == 0) + return (ISC_R_SUCCESS); if (pseudo) flags &= ~ISC_ENTROPY_GOODONLY; return (isc_entropy_getdata(dst_entropy_pool, buf, len, NULL, flags)); @@ -1263,5 +1266,22 @@ dst__entropy_getdata(void *buf, unsigned int len, isc_boolean_t pseudo) { unsigned int dst__entropy_status(void) { +#ifdef GSSAPI + unsigned int flags = dst_entropy_flags; + isc_result_t ret; + unsigned char buf[32]; + static isc_boolean_t first = ISC_TRUE; + + if (first) { + /* Someone believes RAND_status() initializes the PRNG */ + flags &= ~ISC_ENTROPY_GOODONLY; + ret = isc_entropy_getdata(dst_entropy_pool, buf, + sizeof(buf), NULL, flags); + INSIST(ret == ISC_R_SUCCESS); + isc_entropy_putdata(dst_entropy_pool, buf, + sizeof(buf), 2 * sizeof(buf)); + first = ISC_FALSE; + } +#endif return (isc_entropy_status(dst_entropy_pool)); }