summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2013-08-30 17:47:53 +0000
committermarkm <markm@FreeBSD.org>2013-08-30 17:47:53 +0000
commit93487aecdd4f5d6019a45b33bb962359eb211a73 (patch)
treec8d40704b01d7542228da0a1d639c1cb2860e30f
parentb2aa4a3d16b3b9e307ab041807a95868be8b455a (diff)
downloadFreeBSD-src-93487aecdd4f5d6019a45b33bb962359eb211a73.zip
FreeBSD-src-93487aecdd4f5d6019a45b33bb962359eb211a73.tar.gz
Remove short-lived idea; thread to harvest (eg) RDRAND enropy into the usual harvest queues. It was a nifty idea, but too heavyweight.
Submitted by: Arthur Mesh <arthurmesh@gmail.com>
-rw-r--r--share/examples/kld/random_adaptor/random_adaptor_example.c20
-rw-r--r--sys/dev/random/random_adaptors.c71
-rw-r--r--sys/dev/random/random_adaptors.h2
3 files changed, 1 insertions, 92 deletions
diff --git a/share/examples/kld/random_adaptor/random_adaptor_example.c b/share/examples/kld/random_adaptor/random_adaptor_example.c
index f94a7c2..c0ab10a 100644
--- a/share/examples/kld/random_adaptor/random_adaptor_example.c
+++ b/share/examples/kld/random_adaptor/random_adaptor_example.c
@@ -37,16 +37,13 @@ __FBSDID("$FreeBSD$");
#include <dev/random/random_adaptors.h>
#include <dev/random/randomdev.h>
-static int random_example_entropy_control;
-
#define RNG_NAME "example"
static int random_example_read(void *, int);
-static void random_example_init(void);
struct random_adaptor random_example = {
.ident = "Example RNG",
- .init = random_example_init,
+ .init = (random_init_func_t *)random_null_func,
.deinit = (random_deinit_func_t *)random_null_func,
.read = random_example_read,
.write = (random_write_func_t *)random_null_func,
@@ -54,18 +51,6 @@ struct random_adaptor random_example = {
.seeded = 1,
};
-static void
-random_example_init(void)
-{
-
- /*
- * Init() is called only if this RNG was chosen to plugin in to
- * random(4). In which case, we should no longer use this adaptor as
- * an entropy source.
- */
- random_example_entropy_control = 1;
-}
-
/*
* Used under the license provided @ http://xkcd.com/221/
* http://creativecommons.org/licenses/by-nc/2.5/
@@ -98,9 +83,6 @@ random_example_modevent(module_t mod, int type, void *unused)
switch (type) {
case MOD_LOAD:
- /* start off by using this as an entropy source */
- random_adaptor_use_as_entropy(RNG_NAME, &random_example,
- &random_example_entropy_control);
random_adaptor_register(RNG_NAME, &random_example);
EVENTHANDLER_INVOKE(random_adaptor_attach, &random_example);
return (0);
diff --git a/sys/dev/random/random_adaptors.c b/sys/dev/random/random_adaptors.c
index b017993..f6a21f6 100644
--- a/sys/dev/random/random_adaptors.c
+++ b/sys/dev/random/random_adaptors.c
@@ -55,11 +55,6 @@ static struct sysctl_ctx_list random_clist;
MALLOC_DEFINE(M_RANDOM_ADAPTORS, "random_adaptors", "Random adaptors buffers");
-struct entropy_thread_ctx {
- struct random_adaptor *adaptor;
- int *control;
-};
-
int
random_adaptor_register(const char *name, struct random_adaptor *rsp)
{
@@ -186,72 +181,6 @@ random_adaptor_choose(struct random_adaptor **adaptor)
}
static void
-random_proc(void *arg)
-{
- struct entropy_thread_ctx *ctx;
- u_char randomness[HARVESTSIZE];
- int i;
-
- ctx = (struct entropy_thread_ctx *)arg;
-
- /* Sanity check. */
- if (ctx->adaptor == NULL || ctx->adaptor->read == NULL)
- return;
-
- for (; *ctx->control == 0;) {
- i = ctx->adaptor->read(randomness, sizeof(randomness));
-
- if (i > 0)
- /* Be very conservative with entropy estimation here. */
- random_harvest(randomness, i, 0, 0, RANDOM_PURE);
-
- /* Wake up every 10 secs. */
- tsleep_sbt(ctx->adaptor, PWAIT | PCATCH, "-", SBT_1M / 6, 0, 0);
- }
-
- printf("<%s> entropy source is exiting\n", ctx->adaptor->ident);
- free(ctx, M_RANDOM_ADAPTORS);
- kproc_exit(0);
-}
-
-/*
- * Use RNG's output as an entropy source for another RNG. i.e.:
- * +--------+ +--------+
- * | Intel | | Yarrow |
- * | RDRAND +--------->| |
- * +--------+ +--------+
- * Very useful for seeding software RNGs with output of
- * Hardware RNGs like Intel's RdRand and VIA's Padlock.
- *
- * Returns a handle to the newly created kernel process.
- */
-void *
-random_adaptor_use_as_entropy(const char *id, struct random_adaptor *adaptor,
- int *control)
-{
- int error;
- struct proc *random_chain_proc;
- struct entropy_thread_ctx *ctx;
-
- KASSERT(adaptor != NULL, ("can't obtain randomness"));
- KASSERT(control != NULL, ("can't control entropy process"));
-
- ctx = malloc(sizeof(struct entropy_thread_ctx), M_RANDOM_ADAPTORS,
- M_WAITOK);
-
- ctx->control = control;
- ctx->adaptor = adaptor;
-
- /* Start the thread */
- error = kproc_create(random_proc, ctx, &random_chain_proc, RFHIGHPID,
- 0, "%s_entropy", id);
- if (error != 0)
- panic("Cannot create rng chaining thread");
-
- return random_chain_proc;
-}
-
-static void
random_adaptors_deinit(void *unused)
{
diff --git a/sys/dev/random/random_adaptors.h b/sys/dev/random/random_adaptors.h
index b3038e7..98f8c2e 100644
--- a/sys/dev/random/random_adaptors.h
+++ b/sys/dev/random/random_adaptors.h
@@ -40,8 +40,6 @@ struct random_adaptors {
struct random_adaptor *random_adaptor_get(const char *);
int random_adaptor_register(const char *, struct random_adaptor *);
void random_adaptor_choose(struct random_adaptor **);
-void *random_adaptor_use_as_entropy(const char *, struct random_adaptor *,
- int *);
/*
* random_adaptor's should be registered prior to
OpenPOWER on IntegriCloud