1 --- a/drivers/char/random.c
2 +++ b/drivers/char/random.c
4 * that might otherwise be identical and have very little entropy
5 * available to them (particularly common in the embedded world).
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 * seek times do not make for good sources of entropy, as their seek
15 * times are usually fairly consistent.
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 @@ -938,6 +948,63 @@ void add_disk_randomness(struct gendisk
28 EXPORT_SYMBOL_GPL(add_disk_randomness);
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 + pr_notice("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_bits)
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_bits);
72 + count = random_write_wakeup_bits - input_pool.entropy_count;
74 + /* likely we got woken up due to a signal */
75 + if (count <= 0) count = random_read_wakeup_bits;
77 + pr_notice("requesting %d bits from input_wait()er %d<%d\n",
79 + input_pool.entropy_count, random_write_wakeup_bits);
83 +EXPORT_SYMBOL(random_input_wait);
86 +#define EXTRACT_SIZE 10
88 /*********************************************************************
90 * Entropy extraction routines
93 @@ -140,6 +140,7 @@ pid_t f_getown(struct file *filp)
94 read_unlock(&filp->f_owner.lock);
97 +EXPORT_SYMBOL(sys_dup);
99 static int f_setown_ex(struct file *filp, unsigned long arg)
101 --- a/include/linux/miscdevice.h
102 +++ b/include/linux/miscdevice.h
104 #define APOLLO_MOUSE_MINOR 7 /* unused */
105 #define PC110PAD_MINOR 9 /* unused */
106 /*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */
107 +#define CRYPTODEV_MINOR 70 /* /dev/crypto */
108 #define WATCHDOG_MINOR 130 /* Watchdog timer */
109 #define TEMP_MINOR 131 /* Temperature Sensor */
110 #define RTC_MINOR 135
111 --- a/include/uapi/linux/random.h
112 +++ b/include/uapi/linux/random.h
114 /* Clear the entropy pool and associated counters. (Superuser only.) */
115 #define RNDCLEARPOOL _IO( 'R', 0x06 )
117 +#ifdef CONFIG_FIPS_RNG
119 +/* Size of seed value - equal to AES blocksize */
120 +#define AES_BLOCK_SIZE_BYTES 16
121 +#define SEED_SIZE_BYTES AES_BLOCK_SIZE_BYTES
122 +/* Size of AES key */
123 +#define KEY_SIZE_BYTES 16
125 +/* ioctl() structure used by FIPS 140-2 Tests */
126 +struct rand_fips_test {
127 + unsigned char key[KEY_SIZE_BYTES]; /* Input */
128 + unsigned char datetime[SEED_SIZE_BYTES]; /* Input */
129 + unsigned char seed[SEED_SIZE_BYTES]; /* Input */
130 + unsigned char result[SEED_SIZE_BYTES]; /* Output */
133 +/* FIPS 140-2 RNG Variable Seed Test. (Superuser only.) */
134 +#define RNDFIPSVST _IOWR('R', 0x10, struct rand_fips_test)
136 +/* FIPS 140-2 RNG Monte Carlo Test. (Superuser only.) */
137 +#define RNDFIPSMCT _IOWR('R', 0x11, struct rand_fips_test)
139 +#endif /* #ifdef CONFIG_FIPS_RNG */
141 struct rand_pool_info {
144 --- a/include/linux/random.h
145 +++ b/include/linux/random.h
146 @@ -13,6 +13,10 @@ extern void add_input_randomness(unsigne
148 extern void add_interrupt_randomness(int irq, int irq_flags);
150 +extern void random_input_words(__u32 *buf, size_t wordcount, int ent_count);
151 +extern int random_input_wait(void);
152 +#define HAS_RANDOM_INPUT_WAIT 1
154 extern void get_random_bytes(void *buf, int nbytes);
155 extern void get_random_bytes_arch(void *buf, int nbytes);
156 void generate_random_uuid(unsigned char uuid_out[16]);
159 @@ -425,6 +425,7 @@ void transfer_pid(struct task_struct *ol
160 new->pids[type].pid = old->pids[type].pid;
161 hlist_replace_rcu(&old->pids[type].node, &new->pids[type].node);
163 +EXPORT_SYMBOL(find_task_by_vpid);
165 struct task_struct *pid_task(struct pid *pid, enum pid_type type)