]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2721. [port] Have dst__entropy_status() prime the random number
authorMark Andrews <marka@isc.org>
Tue, 20 Oct 2009 04:47:52 +0000 (04:47 +0000)
committerMark Andrews <marka@isc.org>
Tue, 20 Oct 2009 04:47:52 +0000 (04:47 +0000)
                        generator. [RT #20369]

CHANGES
lib/dns/dst_api.c

diff --git a/CHANGES b/CHANGES
index c79121bca96766ecf017cac8953122be0870e4a7..78104b93d6abdfe1be6f0c553660af3c525d4750 100644 (file)
--- 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]
 
index 2c0987a17702fd174802dd234f63c639ff4db935..21a0a67b2a813a301f221dcf70a8cf62cbae83f5 100644 (file)
@@ -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));
 }