Module Name: src
Committed By: riz
Date: Fri Nov 23 16:16:56 UTC 2012
Modified Files:
src/sys/kern [netbsd-6]: kern_rndq.c
Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #696):
sys/kern/kern_rndq.c: revision 1.6
Fix hardware RNGs -- accept their entropy estimates *rather than* using
timestamps to estimate the entropy of their input. I'd accidentally
made it so no entropy was ever counted from them at all.
To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/kern/kern_rndq.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.1.2.3 src/sys/kern/kern_rndq.c:1.1.2.4
--- src/sys/kern/kern_rndq.c:1.1.2.3 Wed Oct 17 21:27:12 2012
+++ src/sys/kern/kern_rndq.c Fri Nov 23 16:16:56 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_rndq.c,v 1.1.2.3 2012/10/17 21:27:12 riz Exp $ */
+/* $NetBSD: kern_rndq.c,v 1.1.2.4 2012/11/23 16:16:56 riz Exp $ */
/*-
* Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.1.2.3 2012/10/17 21:27:12 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.1.2.4 2012/11/23 16:16:56 riz Exp $");
#include <sys/param.h>
#include <sys/ioctl.h>
@@ -640,6 +640,11 @@ void
rnd_add_data(krndsource_t *rs, const void *const data, uint32_t len,
uint32_t entropy)
{
+ /*
+ * This interface is meant for feeding data which is,
+ * itself, random. Don't estimate entropy based on
+ * timestamp, just directly add the data.
+ */
rnd_add_data_ts(rs, data, len, entropy, rnd_counter());
}
@@ -835,8 +840,6 @@ rnd_process_events(void *arg)
SIMPLEQ_REMOVE_HEAD(&dq_samples, next);
source = sample->source;
entropy = sample->entropy;
- if (source->flags & RND_FLAG_NO_ESTIMATE)
- entropy = 0;
/*
* Hardware generators are great but sometimes they