remove linux 2.4 specific build system code
[openwrt/staging/wigyori.git] / target / linux / generic-2.6 / patches-2.6.30 / 971-ocf_20100325.patch
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
5 @@ -129,6 +129,9 @@
6 * unsigned int value);
7 * void add_interrupt_randomness(int irq);
8 *
9 + * void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
10 + * int random_input_wait(void);
11 + *
12 * add_input_randomness() uses the input layer interrupt timing, as well as
13 * the event type information from the hardware.
14 *
15 @@ -140,6 +143,13 @@
16 * a better measure, since the timing of the disk interrupts are more
17 * unpredictable.
18 *
19 + * random_input_words() just provides a raw block of entropy to the input
20 + * pool, such as from a hardware entropy generator.
21 + *
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.
25 + *
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.
29 @@ -712,6 +722,61 @@
30 }
31 #endif
32
33 +/*
34 + * random_input_words - add bulk entropy to pool
35 + *
36 + * @buf: buffer to add
37 + * @wordcount: number of __u32 words to add
38 + * @ent_count: total amount of entropy (in bits) to credit
39 + *
40 + * this provides bulk input of entropy to the input pool
41 + *
42 + */
43 +void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
44 +{
45 + mix_pool_bytes(&input_pool, buf, wordcount*4);
46 +
47 + credit_entropy_bits(&input_pool, ent_count);
48 +
49 + DEBUG_ENT("crediting %d bits => %d\n",
50 + ent_count, input_pool.entropy_count);
51 + /*
52 + * Wake up waiting processes if we have enough
53 + * entropy.
54 + */
55 + if (input_pool.entropy_count >= random_read_wakeup_thresh)
56 + wake_up_interruptible(&random_read_wait);
57 +}
58 +EXPORT_SYMBOL(random_input_words);
59 +
60 +/*
61 + * random_input_wait - wait until random needs entropy
62 + *
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.
66 + */
67 +int random_input_wait(void)
68 +{
69 + int count;
70 +
71 + wait_event_interruptible(random_write_wait,
72 + input_pool.entropy_count < random_write_wakeup_thresh);
73 +
74 + count = random_write_wakeup_thresh - input_pool.entropy_count;
75 +
76 + /* likely we got woken up due to a signal */
77 + if (count <= 0) count = random_read_wakeup_thresh;
78 +
79 + DEBUG_ENT("requesting %d bits from input_wait()er %d<%d\n",
80 + count,
81 + input_pool.entropy_count, random_write_wakeup_thresh);
82 +
83 + return count;
84 +}
85 +EXPORT_SYMBOL(random_input_wait);
86 +
87 +
88 #define EXTRACT_SIZE 10
89
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
95 @@ -142,6 +142,7 @@
96 }
97 return ret;
98 }
99 +EXPORT_SYMBOL(sys_dup);
100
101 #define SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | O_DIRECT | O_NOATIME)
102
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
107 @@ -12,6 +12,7 @@
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
119 @@ -9,6 +9,7 @@
120
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>
125
126 /* ioctl()'s for the random number generator */
127 @@ -34,6 +35,30 @@
128 /* Clear the entropy pool and associated counters. (Superuser only.) */
129 #define RNDCLEARPOOL _IO( 'R', 0x06 )
130
131 +#ifdef CONFIG_FIPS_RNG
132 +
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
138 +
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 */
145 +};
146 +
147 +/* FIPS 140-2 RNG Variable Seed Test. (Superuser only.) */
148 +#define RNDFIPSVST _IOWR('R', 0x10, struct rand_fips_test)
149 +
150 +/* FIPS 140-2 RNG Monte Carlo Test. (Superuser only.) */
151 +#define RNDFIPSMCT _IOWR('R', 0x11, struct rand_fips_test)
152 +
153 +#endif /* #ifdef CONFIG_FIPS_RNG */
154 +
155 struct rand_pool_info {
156 int entropy_count;
157 int buf_size;
158 @@ -50,6 +75,10 @@
159 unsigned int value);
160 extern void add_interrupt_randomness(int irq);
161
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
165 +
166 extern void get_random_bytes(void *buf, int nbytes);
167 void generate_random_uuid(unsigned char uuid_out[16]);
168