1 Index: linux-2.6.30.10/drivers/char/random.c
2 ===================================================================
3 --- linux-2.6.30.10.orig/drivers/char/random.c 2009-12-04 07:00:07.000000000 +0100
4 +++ linux-2.6.30.10/drivers/char/random.c 2010-05-15 15:44:19.000000000 +0200
7 * void add_interrupt_randomness(int irq);
9 + * void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
10 + * int random_input_wait(void);
12 * add_input_randomness() uses the input layer interrupt timing, as well as
13 * the event type information from the hardware.
16 * a better measure, since the timing of the disk interrupts are more
19 + * random_input_words() just provides a raw block of entropy to the input
20 + * pool, such as from a hardware entropy generator.
22 + * random_input_wait() suspends the caller until such time as the
23 + * entropy pool falls below the write threshold, and returns a count of how
24 + * much entropy (in bits) is needed to sustain the pool.
26 * All of these routines try to estimate how many bits of randomness a
27 * particular randomness source. They do this by keeping track of the
28 * first and second order deltas of the event timings.
34 + * random_input_words - add bulk entropy to pool
36 + * @buf: buffer to add
37 + * @wordcount: number of __u32 words to add
38 + * @ent_count: total amount of entropy (in bits) to credit
40 + * this provides bulk input of entropy to the input pool
43 +void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
45 + mix_pool_bytes(&input_pool, buf, wordcount*4);
47 + credit_entropy_bits(&input_pool, ent_count);
49 + DEBUG_ENT("crediting %d bits => %d\n",
50 + ent_count, input_pool.entropy_count);
52 + * Wake up waiting processes if we have enough
55 + if (input_pool.entropy_count >= random_read_wakeup_thresh)
56 + wake_up_interruptible(&random_read_wait);
58 +EXPORT_SYMBOL(random_input_words);
61 + * random_input_wait - wait until random needs entropy
63 + * this function sleeps until the /dev/random subsystem actually
64 + * needs more entropy, and then return the amount of entropy
65 + * that it would be nice to have added to the system.
67 +int random_input_wait(void)
71 + wait_event_interruptible(random_write_wait,
72 + input_pool.entropy_count < random_write_wakeup_thresh);
74 + count = random_write_wakeup_thresh - input_pool.entropy_count;
76 + /* likely we got woken up due to a signal */
77 + if (count <= 0) count = random_read_wakeup_thresh;
79 + DEBUG_ENT("requesting %d bits from input_wait()er %d<%d\n",
81 + input_pool.entropy_count, random_write_wakeup_thresh);
85 +EXPORT_SYMBOL(random_input_wait);
88 #define EXTRACT_SIZE 10
90 /*********************************************************************
91 Index: linux-2.6.30.10/fs/fcntl.c
92 ===================================================================
93 --- linux-2.6.30.10.orig/fs/fcntl.c 2009-12-04 07:00:07.000000000 +0100
94 +++ linux-2.6.30.10/fs/fcntl.c 2010-05-15 15:44:19.000000000 +0200
99 +EXPORT_SYMBOL(sys_dup);
101 #define SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | O_DIRECT | O_NOATIME)
103 Index: linux-2.6.30.10/include/linux/miscdevice.h
104 ===================================================================
105 --- linux-2.6.30.10.orig/include/linux/miscdevice.h 2009-12-04 07:00:07.000000000 +0100
106 +++ linux-2.6.30.10/include/linux/miscdevice.h 2010-05-15 15:44:19.000000000 +0200
108 #define APOLLO_MOUSE_MINOR 7
109 #define PC110PAD_MINOR 9
110 /*#define ADB_MOUSE_MINOR 10 FIXME OBSOLETE */
111 +#define CRYPTODEV_MINOR 70 /* /dev/crypto */
112 #define WATCHDOG_MINOR 130 /* Watchdog timer */
113 #define TEMP_MINOR 131 /* Temperature Sensor */
114 #define RTC_MINOR 135
115 Index: linux-2.6.30.10/include/linux/random.h
116 ===================================================================
117 --- linux-2.6.30.10.orig/include/linux/random.h 2009-12-04 07:00:07.000000000 +0100
118 +++ linux-2.6.30.10/include/linux/random.h 2010-05-15 15:44:19.000000000 +0200
121 #include <linux/types.h>
122 #include <linux/ioctl.h>
123 +#include <linux/types.h> /* for __u32 in user space */
124 #include <linux/irqnr.h>
126 /* ioctl()'s for the random number generator */
128 /* Clear the entropy pool and associated counters. (Superuser only.) */
129 #define RNDCLEARPOOL _IO( 'R', 0x06 )
131 +#ifdef CONFIG_FIPS_RNG
133 +/* Size of seed value - equal to AES blocksize */
134 +#define AES_BLOCK_SIZE_BYTES 16
135 +#define SEED_SIZE_BYTES AES_BLOCK_SIZE_BYTES
136 +/* Size of AES key */
137 +#define KEY_SIZE_BYTES 16
139 +/* ioctl() structure used by FIPS 140-2 Tests */
140 +struct rand_fips_test {
141 + unsigned char key[KEY_SIZE_BYTES]; /* Input */
142 + unsigned char datetime[SEED_SIZE_BYTES]; /* Input */
143 + unsigned char seed[SEED_SIZE_BYTES]; /* Input */
144 + unsigned char result[SEED_SIZE_BYTES]; /* Output */
147 +/* FIPS 140-2 RNG Variable Seed Test. (Superuser only.) */
148 +#define RNDFIPSVST _IOWR('R', 0x10, struct rand_fips_test)
150 +/* FIPS 140-2 RNG Monte Carlo Test. (Superuser only.) */
151 +#define RNDFIPSMCT _IOWR('R', 0x11, struct rand_fips_test)
153 +#endif /* #ifdef CONFIG_FIPS_RNG */
155 struct rand_pool_info {
160 extern void add_interrupt_randomness(int irq);
162 +extern void random_input_words(__u32 *buf, size_t wordcount, int ent_count);
163 +extern int random_input_wait(void);
164 +#define HAS_RANDOM_INPUT_WAIT 1
166 extern void get_random_bytes(void *buf, int nbytes);
167 void generate_random_uuid(unsigned char uuid_out[16]);