Source-Changes-HG archive

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

[src/trunk]: src Make the rndsave structure public -- the kernel will learn t...



details:   https://anonhg.NetBSD.org/src/rev/abb4d0078035
branches:  trunk
changeset: 771597:abb4d0078035
user:      tls <tls%NetBSD.org@localhost>
date:      Sat Nov 26 01:17:17 2011 +0000

description:
Make the rndsave structure public -- the kernel will learn to read it
and sysinst may learn to write it (since, on some systems, most of
the keyboard input they ever get happens to be during install).  Fix a
couple of minor problems with the random_seed rc script addition.

diffstat:

 etc/mtree/special                |   3 ++-
 sbin/rndctl/rndctl.c             |  10 ++--------
 sys/sys/rnd.h                    |  20 ++++++++++++++++++--
 usr.sbin/postinstall/postinstall |   5 +++--
 4 files changed, 25 insertions(+), 13 deletions(-)

diffs (124 lines):

diff -r a9014fa8b114 -r abb4d0078035 etc/mtree/special
--- a/etc/mtree/special Fri Nov 25 23:31:53 2011 +0000
+++ b/etc/mtree/special Sat Nov 26 01:17:17 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: special,v 1.138 2011/05/27 09:28:42 plunky Exp $
+#      $NetBSD: special,v 1.139 2011/11/26 01:17:17 tls Exp $
 #      @(#)special     8.2 (Berkeley) 1/23/94
 #
 # This file may be overwritten on upgrades.
@@ -252,6 +252,7 @@
 ./etc/rc.d/racoon              type=file mode=0555
 ./etc/rc.d/raidframe           type=file mode=0555
 ./etc/rc.d/raidframeparity     type=file mode=0555
+./etc/rc.d/random_seed         type=file mode=0555
 ./etc/rc.d/rarpd               type=file mode=0555
 ./etc/rc.d/rbootd              type=file mode=0555
 ./etc/rc.d/rndctl              type=file mode=0555
diff -r a9014fa8b114 -r abb4d0078035 sbin/rndctl/rndctl.c
--- a/sbin/rndctl/rndctl.c      Fri Nov 25 23:31:53 2011 +0000
+++ b/sbin/rndctl/rndctl.c      Sat Nov 26 01:17:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rndctl.c,v 1.21 2011/11/23 10:47:49 tls Exp $  */
+/*     $NetBSD: rndctl.c,v 1.22 2011/11/26 01:17:17 tls Exp $  */
 
 /*-
  * Copyright (c) 1997 Michael Graff.
@@ -33,7 +33,7 @@
 #include <sha1.h>
 
 #ifndef lint
-__RCSID("$NetBSD: rndctl.c,v 1.21 2011/11/23 10:47:49 tls Exp $");
+__RCSID("$NetBSD: rndctl.c,v 1.22 2011/11/26 01:17:17 tls Exp $");
 #endif
 
 
@@ -51,12 +51,6 @@
 #include <string.h>
 
 typedef struct {
-       uint32_t entropy;
-       uint8_t data[RND_POOLWORDS * sizeof(uint32_t)];
-       uint8_t digest[SHA1_DIGEST_LENGTH];
-} rndsave_t;
-
-typedef struct {
        const char *a_name;
        u_int32_t a_type;
 } arg_t;
diff -r a9014fa8b114 -r abb4d0078035 sys/sys/rnd.h
--- a/sys/sys/rnd.h     Fri Nov 25 23:31:53 2011 +0000
+++ b/sys/sys/rnd.h     Sat Nov 26 01:17:17 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rnd.h,v 1.23 2011/11/23 10:47:49 tls Exp $     */
+/*     $NetBSD: rnd.h,v 1.24 2011/11/26 01:17:17 tls Exp $     */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -38,6 +38,7 @@
 #endif /* !_KERNEL */
 
 #include <sys/types.h>
+#include <sys/sha1.h>
 
 #ifdef _KERNEL
 #include <sys/queue.h>
@@ -50,6 +51,7 @@
 #define        RND_DEV_RANDOM  0       /* minor devices for random and kinda random */
 #define        RND_DEV_URANDOM 1
 
+#ifdef _KERNEL
 /*
  * Size of entropy pool in 32-bit words.  This _MUST_ be a power of 2.  Don't
  * change this unless you really know what you are doing...
@@ -73,6 +75,20 @@
 #define        RND_EVENTQSIZE  128
 #endif
 
+#endif /* _KERNEL */
+
+/*
+ * Exposed "size" of entropy pool, for convenience in load/save
+ * from userspace.  Do not assume this is the same as the actual in-kernel
+ * pool size!
+ */
+#define RND_SAVEWORDS  128
+typedef struct {
+       uint32_t entropy;
+       uint8_t data[RND_SAVEWORDS * sizeof(uint32_t)];
+       uint8_t digest[SHA1_DIGEST_LENGTH];
+} rndsave_t;
+
 typedef struct
 {
        uint32_t        poolsize;
@@ -209,7 +225,7 @@
 typedef struct {
        uint32_t        len;
        uint32_t        entropy;
-       u_char          data[RND_POOLWORDS * sizeof(uint32_t)];
+       u_char          data[RND_SAVEWORDS * sizeof(uint32_t)];
 } rnddata_t;
 
 #define        RNDGETENTCNT    _IOR('R',  101, uint32_t) /* get entropy count */
diff -r a9014fa8b114 -r abb4d0078035 usr.sbin/postinstall/postinstall
--- a/usr.sbin/postinstall/postinstall  Fri Nov 25 23:31:53 2011 +0000
+++ b/usr.sbin/postinstall/postinstall  Sat Nov 26 01:17:17 2011 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall,v 1.126 2011/10/07 02:07:56 mrg Exp $
+# $NetBSD: postinstall,v 1.127 2011/11/26 01:17:17 tls Exp $
 #
 # Copyright (c) 2002-2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1149,7 +1149,8 @@
                ntpd ntpdate \
                perusertmp pf pf_boot pflogd postfix powerd ppp pwcheck \
                quota \
-               racoon rpcbind raidframe raidframeparity rarpd rbootd rndctl \
+               racoon rpcbind raidframe raidframeparity random_seed \
+               rarpd rbootd rndctl \
                root route6d routed rtadvd rtclocaltime rtsold rwho \
                savecore screenblank securelevel sshd \
                staticroute swap1 swap2 sysctl sysdb syslogd \



Home | Main Index | Thread Index | Old Index