summaryrefslogtreecommitdiffstats
path: root/sys/dev/random/unit_test.c
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2015-08-17 07:36:12 +0000
committermarkm <markm@FreeBSD.org>2015-08-17 07:36:12 +0000
commit3f5a6af67aa31b22afbac2e407ff527052cbc720 (patch)
tree607f453932abecc199a5542abc16308de508677e /sys/dev/random/unit_test.c
parent9d08caeba8295dbd7762ac4c959b02bbeeeb8559 (diff)
downloadFreeBSD-src-3f5a6af67aa31b22afbac2e407ff527052cbc720.zip
FreeBSD-src-3f5a6af67aa31b22afbac2e407ff527052cbc720.tar.gz
Add DEV_RANDOM pseudo-option and use it to "include out" random(4)
if desired. Retire randomdev_none.c and introduce random_infra.c for resident infrastructure. Completely stub out random(4) calls in the "without DEV_RANDOM" case. Add RANDOM_LOADABLE option to allow loadable Yarrow/Fortuna/LocallyWritten algorithm. Add a skeleton "other" algorithm framework for folks to add their own processing code. NIST, anyone? Retire the RANDOM_DUMMY option. Build modules for Yarrow, Fortuna and "other". Use atomics for the live entropy rate-tracking. Convert ints to bools for the 'seeded' logic. Move _write() function from the algorithm-specific areas to randomdev.c Get rid of reseed() function - it is unused. Tidy up the opt_*.h includes. Update documentation for random(4) modules. Fix test program (reviewers, please leave this). Differential Revision: https://reviews.freebsd.org/D3354 Reviewed by: wblock,delphij,jmg,bjk Approved by: so (/dev/random blanket)
Diffstat (limited to 'sys/dev/random/unit_test.c')
-rw-r--r--sys/dev/random/unit_test.c32
1 files changed, 2 insertions, 30 deletions
diff --git a/sys/dev/random/unit_test.c b/sys/dev/random/unit_test.c
index 7ae5716..fac4c8d 100644
--- a/sys/dev/random/unit_test.c
+++ b/sys/dev/random/unit_test.c
@@ -46,6 +46,7 @@ Where <alg> is YARROW or FORTUNA.
#include <sys/types.h>
#include <inttypes.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <threads.h>
@@ -172,35 +173,6 @@ RunHarvester(void *arg __unused)
}
static int
-WriteCSPRNG(void *threadid)
-{
- uint8_t *buf;
- int i;
-
- printf("Thread #1 starts\n");
-
- for (i = 0; ; i++) {
- if (stopseeding)
- break;
- buf = malloc(4096);
- if (i % 1000 == 0)
- printf("Thread write 1 - %d\n", i);
- if (buf != NULL) {
- printf("Thread 1 writing.\n");
- random_alg_context.ra_write(buf, i);
- free(buf);
- }
- usleep(1000000);
- }
-
- printf("Thread #1 ends\n");
-
- thrd_exit(0);
-
- return (0);
-}
-
-static int
ReadCSPRNG(void *threadid)
{
size_t tid, zsize;
@@ -271,7 +243,7 @@ main(int argc, char *argv[])
for (t = 0; t < NUM_THREADS; t++) {
printf("In main: creating thread %ld\n", t);
- rc = thrd_create(&threads[t], (t == 0 ? RunHarvester : (t == 1 ? WriteCSPRNG : ReadCSPRNG)), NULL);
+ rc = thrd_create(&threads[t], (t == 0 ? RunHarvester : ReadCSPRNG), NULL);
if (rc != thrd_success) {
printf("ERROR; return code from thrd_create() is %d\n", rc);
exit(-1);
OpenPOWER on IntegriCloud