1 --- a/drivers/char/random.c
2 +++ b/drivers/char/random.c
5 * void add_interrupt_randomness(int irq);
7 + * void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
8 + * int random_input_wait(void);
10 * add_input_randomness() uses the input layer interrupt timing, as well as
11 * the event type information from the hardware.
14 * a better measure, since the timing of the disk interrupts are more
17 + * random_input_words() just provides a raw block of entropy to the input
18 + * pool, such as from a hardware entropy generator.
20 + * random_input_wait() suspends the caller until such time as the
21 + * entropy pool falls below the write threshold, and returns a count of how
22 + * much entropy (in bits) is needed to sustain the pool.
24 * All of these routines try to estimate how many bits of randomness a
25 * particular randomness source. They do this by keeping track of the
26 * first and second order deltas of the event timings.
27 @@ -715,6 +725,61 @@ void add_disk_randomness(struct gendisk
32 + * random_input_words - add bulk entropy to pool
34 + * @buf: buffer to add
35 + * @wordcount: number of __u32 words to add
36 + * @ent_count: total amount of entropy (in bits) to credit
38 + * this provides bulk input of entropy to the input pool
41 +void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
43 + mix_pool_bytes(&input_pool, buf, wordcount*4);
45 + credit_entropy_bits(&input_pool, ent_count);
47 + DEBUG_ENT("crediting %d bits => %d\n",
48 + ent_count, input_pool.entropy_count);
50 + * Wake up waiting processes if we have enough
53 + if (input_pool.entropy_count >= random_read_wakeup_thresh)
54 + wake_up_interruptible(&random_read_wait);
56 +EXPORT_SYMBOL(random_input_words);
59 + * random_input_wait - wait until random needs entropy
61 + * this function sleeps until the /dev/random subsystem actually
62 + * needs more entropy, and then return the amount of entropy
63 + * that it would be nice to have added to the system.
65 +int random_input_wait(void)
69 + wait_event_interruptible(random_write_wait,
70 + input_pool.entropy_count < random_write_wakeup_thresh);
72 + count = random_write_wakeup_thresh - input_pool.entropy_count;
74 + /* likely we got woken up due to a signal */
75 + if (count <= 0) count = random_read_wakeup_thresh;
77 + DEBUG_ENT("requesting %d bits from input_wait()er %d<%d\n",
79 + input_pool.entropy_count, random_write_wakeup_thresh);
83 +EXPORT_SYMBOL(random_input_wait);
86 /*********************************************************************
88 * Entropy extraction routines
91 @@ -142,6 +142,7 @@ SYSCALL_DEFINE1(dup, unsigned int, filde
95 +EXPORT_SYMBOL(sys_dup);
97 #define SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | O_DIRECT | O_NOATIME)
99 --- a/include/linux/miscdevice.h
100 +++ b/include/linux/miscdevice.h
102 #define APOLLO_MOUSE_MINOR 7
103 #define PC110PAD_MINOR 9
104 /*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */
105 +#define CRYPTODEV_MINOR 70 /* /dev/crypto */
106 #define WATCHDOG_MINOR 130 /* Watchdog timer */
107 #define TEMP_MINOR 131 /* Temperature Sensor */
108 #define RTC_MINOR 135
109 --- a/include/linux/random.h
110 +++ b/include/linux/random.h
113 #include <linux/types.h>
114 #include <linux/ioctl.h>
115 +#include <linux/types.h> /* for __u32 in user space */
116 #include <linux/irqnr.h>
118 /* ioctl()'s for the random number generator */
120 /* Clear the entropy pool and associated counters. (Superuser only.) */
121 #define RNDCLEARPOOL _IO( 'R', 0x06 )
123 +#ifdef CONFIG_FIPS_RNG
125 +/* Size of seed value - equal to AES blocksize */
126 +#define AES_BLOCK_SIZE_BYTES 16
127 +#define SEED_SIZE_BYTES AES_BLOCK_SIZE_BYTES
128 +/* Size of AES key */
129 +#define KEY_SIZE_BYTES 16
131 +/* ioctl() structure used by FIPS 140-2 Tests */
132 +struct rand_fips_test {
133 + unsigned char key[KEY_SIZE_BYTES]; /* Input */
134 + unsigned char datetime[SEED_SIZE_BYTES]; /* Input */
135 + unsigned char seed[SEED_SIZE_BYTES]; /* Input */
136 + unsigned char result[SEED_SIZE_BYTES]; /* Output */
139 +/* FIPS 140-2 RNG Variable Seed Test. (Superuser only.) */
140 +#define RNDFIPSVST _IOWR('R', 0x10, struct rand_fips_test)
142 +/* FIPS 140-2 RNG Monte Carlo Test. (Superuser only.) */
143 +#define RNDFIPSMCT _IOWR('R', 0x11, struct rand_fips_test)
145 +#endif /* #ifdef CONFIG_FIPS_RNG */
147 struct rand_pool_info {
150 @@ -54,6 +79,10 @@ extern void add_input_randomness(unsigne
152 extern void add_interrupt_randomness(int irq);
154 +extern void random_input_words(__u32 *buf, size_t wordcount, int ent_count);
155 +extern int random_input_wait(void);
156 +#define HAS_RANDOM_INPUT_WAIT 1
158 extern void get_random_bytes(void *buf, int nbytes);
159 void generate_random_uuid(unsigned char uuid_out[16]);
163 @@ -423,6 +423,7 @@ struct task_struct *find_task_by_vpid(pi
165 return find_task_by_pid_ns(vnr, current->nsproxy->pid_ns);
167 +EXPORT_SYMBOL(find_task_by_vpid);
169 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)