randomdev.c (720a3741cf8c06f597bac5a1a216b6018278dc89) randomdev.c (7aa4389a6c7429f679ba5d0348c4251242ed4702)
1/*-
2 * Copyright (c) 2000 Mark R V Murray
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 32 unchanged lines hidden (view full) ---

41#include <machine/resource.h>
42#include <sys/rman.h>
43#include <sys/signalvar.h>
44#include <sys/sysctl.h>
45#include <crypto/blowfish/blowfish.h>
46
47#include <dev/randomdev/yarrow.h>
48
1/*-
2 * Copyright (c) 2000 Mark R V Murray
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 32 unchanged lines hidden (view full) ---

41#include <machine/resource.h>
42#include <sys/rman.h>
43#include <sys/signalvar.h>
44#include <sys/sysctl.h>
45#include <crypto/blowfish/blowfish.h>
46
47#include <dev/randomdev/yarrow.h>
48
49static d_open_t random_open;
49static d_read_t random_read;
50static d_write_t random_write;
51
52#define CDEV_MAJOR 2
53#define RANDOM_MINOR 3
54#define URANDOM_MINOR 4
55
56static struct cdevsw random_cdevsw = {
50static d_read_t random_read;
51static d_write_t random_write;
52
53#define CDEV_MAJOR 2
54#define RANDOM_MINOR 3
55#define URANDOM_MINOR 4
56
57static struct cdevsw random_cdevsw = {
57 /* open */ (d_open_t *)nullop,
58 /* open */ random_open,
58 /* close */ (d_close_t *)nullop,
59 /* read */ random_read,
60 /* write */ random_write,
61 /* ioctl */ noioctl,
62 /* poll */ nopoll,
63 /* mmap */ nommap,
64 /* strategy */ nostrategy,
65 /* name */ "random",

--- 12 unchanged lines hidden (view full) ---

78SYSCTL_NODE(_kern_random, OID_AUTO, yarrow, CTLFLAG_RW, 0, "Yarrow Parameters");
79SYSCTL_INT(_kern_random_yarrow, OID_AUTO, gengateinterval, CTLFLAG_RW,
80 &random_state.gengateinterval, 10, "Generator Gate Interval");
81SYSCTL_INT(_kern_random_yarrow, OID_AUTO, bins, CTLFLAG_RW,
82 &random_state.bins, 10, "Execution time tuner");
83SYSCTL_INT(_kern_random_yarrow, OID_AUTO, fastthresh, CTLFLAG_RW,
84 &random_state.pool[0].thresh, 100, "Fast pool reseed threshhold");
85SYSCTL_INT(_kern_random_yarrow, OID_AUTO, slowthresh, CTLFLAG_RW,
59 /* close */ (d_close_t *)nullop,
60 /* read */ random_read,
61 /* write */ random_write,
62 /* ioctl */ noioctl,
63 /* poll */ nopoll,
64 /* mmap */ nommap,
65 /* strategy */ nostrategy,
66 /* name */ "random",

--- 12 unchanged lines hidden (view full) ---

79SYSCTL_NODE(_kern_random, OID_AUTO, yarrow, CTLFLAG_RW, 0, "Yarrow Parameters");
80SYSCTL_INT(_kern_random_yarrow, OID_AUTO, gengateinterval, CTLFLAG_RW,
81 &random_state.gengateinterval, 10, "Generator Gate Interval");
82SYSCTL_INT(_kern_random_yarrow, OID_AUTO, bins, CTLFLAG_RW,
83 &random_state.bins, 10, "Execution time tuner");
84SYSCTL_INT(_kern_random_yarrow, OID_AUTO, fastthresh, CTLFLAG_RW,
85 &random_state.pool[0].thresh, 100, "Fast pool reseed threshhold");
86SYSCTL_INT(_kern_random_yarrow, OID_AUTO, slowthresh, CTLFLAG_RW,
86 &random_state.pool[1].thresh, 100, "Slow pool reseed threshhold");
87 &random_state.pool[1].thresh, 160, "Slow pool reseed threshhold");
87SYSCTL_INT(_kern_random_yarrow, OID_AUTO, slowoverthresh, CTLFLAG_RW,
88 &random_state.slowoverthresh, 2, "Slow pool over-threshhold reseed");
89
90static int
88SYSCTL_INT(_kern_random_yarrow, OID_AUTO, slowoverthresh, CTLFLAG_RW,
89 &random_state.slowoverthresh, 2, "Slow pool over-threshhold reseed");
90
91static int
92random_open(dev_t dev, int flags, int fmt, struct proc *p)
93{
94 if ((flags & FWRITE) && (securelevel > 0 || suser(p)))
95 return EPERM;
96 else
97 return 0;
98}
99
100static int
91random_read(dev_t dev, struct uio *uio, int flag)
92{
93 u_int c, ret;
94 int error = 0;
95 void *random_buf;
96
97 c = min(uio->uio_resid, PAGE_SIZE);
98 random_buf = (void *)malloc(c, M_TEMP, M_WAITOK);

--- 56 unchanged lines hidden ---
101random_read(dev_t dev, struct uio *uio, int flag)
102{
103 u_int c, ret;
104 int error = 0;
105 void *random_buf;
106
107 c = min(uio->uio_resid, PAGE_SIZE);
108 random_buf = (void *)malloc(c, M_TEMP, M_WAITOK);

--- 56 unchanged lines hidden ---