summaryrefslogtreecommitdiffstats
path: root/sys/dev/random
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2013-10-08 11:05:26 +0000
committerdes <des@FreeBSD.org>2013-10-08 11:05:26 +0000
commit7dad8b80f64fa04622126b49286eec60b14fb990 (patch)
tree3a76eaf5937dae5bf48a986655448c98557092f2 /sys/dev/random
parent9dda6bc99f96dc85a417e718b740a228a4c0d0db (diff)
downloadFreeBSD-src-7dad8b80f64fa04622126b49286eec60b14fb990.zip
FreeBSD-src-7dad8b80f64fa04622126b49286eec60b14fb990.tar.gz
Add YARROW_RNG and FORTUNA_RNG to sys/conf/options.
Add a SYSINIT that forces a reseed during proc0 setup, which happens fairly late in the boot process. Add a RANDOM_DEBUG option which enables some debugging printf()s. Add a new RANDOM_ATTACH entropy source which harvests entropy from the get_cyclecount() delta across each call to a device attach method.
Diffstat (limited to 'sys/dev/random')
-rw-r--r--sys/dev/random/random_adaptors.c14
-rw-r--r--sys/dev/random/randomdev_soft.c5
-rw-r--r--sys/dev/random/yarrow.c14
3 files changed, 33 insertions, 0 deletions
diff --git a/sys/dev/random/random_adaptors.c b/sys/dev/random/random_adaptors.c
index 3d58214..8cbebbc 100644
--- a/sys/dev/random/random_adaptors.c
+++ b/sys/dev/random/random_adaptors.c
@@ -227,3 +227,17 @@ SYSINIT(random_adaptors, SI_SUB_DRIVERS, SI_ORDER_FIRST, random_adaptors_init,
NULL);
SYSUNINIT(random_adaptors, SI_SUB_DRIVERS, SI_ORDER_FIRST,
random_adaptors_deinit, NULL);
+
+static void
+random_adaptors_reseed(void *unused)
+{
+
+ (void)unused;
+ if (random_adaptor != NULL) {
+ (*random_adaptor->reseed)();
+ random_adaptor->seeded = 1;
+ }
+ arc4rand(NULL, 0, 1);
+}
+SYSINIT(random_reseed, SI_SUB_INTRINSIC_POST, SI_ORDER_SECOND,
+ random_adaptors_reseed, NULL);
diff --git a/sys/dev/random/randomdev_soft.c b/sys/dev/random/randomdev_soft.c
index 352d0ae..9c3aa53 100644
--- a/sys/dev/random/randomdev_soft.c
+++ b/sys/dev/random/randomdev_soft.c
@@ -26,11 +26,16 @@
*
*/
+#include "opt_random.h"
+
#if !defined(YARROW_RNG) && !defined(FORTUNA_RNG)
#define YARROW_RNG
#elif defined(YARROW_RNG) && defined(FORTUNA_RNG)
#error "Must define either YARROW_RNG or FORTUNA_RNG"
#endif
+#if defined(FORTUNA_RNG)
+#error "Fortuna is not yet implemented"
+#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
diff --git a/sys/dev/random/yarrow.c b/sys/dev/random/yarrow.c
index 6d2ea3b..1cfa373 100644
--- a/sys/dev/random/yarrow.c
+++ b/sys/dev/random/yarrow.c
@@ -28,6 +28,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_random.h"
+
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/lock.h>
@@ -398,5 +400,17 @@ generator_gate(void)
void
random_yarrow_reseed(void)
{
+#ifdef RANDOM_DEBUG
+ int i;
+
+ printf("%s(): fast:", __func__);
+ for (i = RANDOM_START; i < ENTROPYSOURCE; ++i)
+ printf(" %d", random_state.pool[FAST].source[i].bits);
+ printf("\n");
+ printf("%s(): slow:", __func__);
+ for (i = RANDOM_START; i < ENTROPYSOURCE; ++i)
+ printf(" %d", random_state.pool[SLOW].source[i].bits);
+ printf("\n");
+#endif
reseed(SLOW);
}
OpenPOWER on IntegriCloud