Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev mix in another counter when called if not yet satisfied



details:   https://anonhg.NetBSD.org/src/rev/de88907ebb80
branches:  trunk
changeset: 537883:de88907ebb80
user:      dan <dan%NetBSD.org@localhost>
date:      Mon Oct 07 11:02:20 2002 +0000

description:
mix in another counter when called if not yet satisfied

diffstat:

 sys/dev/rnd.c |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (41 lines):

diff -r 281a4ae4d5b2 -r de88907ebb80 sys/dev/rnd.c
--- a/sys/dev/rnd.c     Mon Oct 07 11:01:52 2002 +0000
+++ b/sys/dev/rnd.c     Mon Oct 07 11:02:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rnd.c,v 1.31 2002/10/07 09:41:51 dan Exp $     */
+/*     $NetBSD: rnd.c,v 1.32 2002/10/07 11:02:20 dan Exp $     */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.31 2002/10/07 09:41:51 dan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.32 2002/10/07 11:02:20 dan Exp $");
 
 #include <sys/param.h>
 #include <sys/ioctl.h>
@@ -1000,14 +1000,21 @@
 rnd_extract_data(void *p, u_int32_t len, u_int32_t flags)
 {
        int retval, s;
+       u_int32_t c;
 
+       if (!rnd_have_entropy) {
+               /* Try once again to put something in the pool */
+               c = rnd_counter();
 #ifdef RND_VERBOSE
-       if (!rnd_have_entropy)
                printf("rnd: WARNING! initial entropy low (%u).\n",
                       rndpool_get_entropy_count(&rnd_pool));
 #endif
+       }
 
        s = splsoftclock();
+       if (!rnd_have_entropy) {
+               rndpool_add_data(&rnd_pool, &c, sizeof(u_int32_t), 0);
+       }
        retval = rndpool_extract_data(&rnd_pool, p, len, flags);
        splx(s);
 



Home | Main Index | Thread Index | Old Index