2180bda416ae57c762a9d523cb2a15b80ed62aea
[openwrt.git] / target / linux / generic / patches-3.0 / 941-ocf_20110720.patch
1 --- a/drivers/char/random.c
2 +++ b/drivers/char/random.c
3 @@ -130,6 +130,9 @@
4 * void add_interrupt_randomness(int irq);
5 * void add_disk_randomness(struct gendisk *disk);
6 *
7 + * void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
8 + * int random_input_wait(void);
9 + *
10 * add_input_randomness() uses the input layer interrupt timing, as well as
11 * the event type information from the hardware.
12 *
13 @@ -147,6 +150,13 @@
14 * seek times do not make for good sources of entropy, as their seek
15 * times are usually fairly consistent.
16 *
17 + * random_input_words() just provides a raw block of entropy to the input
18 + * pool, such as from a hardware entropy generator.
19 + *
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.
23 + *
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 @@ -722,6 +732,63 @@ void add_disk_randomness(struct gendisk
28 }
29 #endif
30
31 +/*
32 + * random_input_words - add bulk entropy to pool
33 + *
34 + * @buf: buffer to add
35 + * @wordcount: number of __u32 words to add
36 + * @ent_count: total amount of entropy (in bits) to credit
37 + *
38 + * this provides bulk input of entropy to the input pool
39 + *
40 + */
41 +void random_input_words(__u32 *buf, size_t wordcount, int ent_count)
42 +{
43 + mix_pool_bytes(&input_pool, buf, wordcount*4);
44 +
45 + credit_entropy_bits(&input_pool, ent_count);
46 +
47 + DEBUG_ENT("crediting %d bits => %d\n",
48 + ent_count, input_pool.entropy_count);
49 + /*
50 + * Wake up waiting processes if we have enough
51 + * entropy.
52 + */
53 + if (input_pool.entropy_count >= random_read_wakeup_thresh)
54 + wake_up_interruptible(&random_read_wait);
55 +}
56 +EXPORT_SYMBOL(random_input_words);
57 +
58 +/*
59 + * random_input_wait - wait until random needs entropy
60 + *
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.
64 + */
65 +int random_input_wait(void)
66 +{
67 + int count;
68 +
69 + wait_event_interruptible(random_write_wait,
70 + input_pool.entropy_count < random_write_wakeup_thresh);
71 +
72 + count = random_write_wakeup_thresh - input_pool.entropy_count;
73 +
74 + /* likely we got woken up due to a signal */
75 + if (count <= 0) count = random_read_wakeup_thresh;
76 +
77 + DEBUG_ENT("requesting %d bits from input_wait()er %d<%d\n",
78 + count,
79 + input_pool.entropy_count, random_write_wakeup_thresh);
80 +
81 + return count;
82 +}
83 +EXPORT_SYMBOL(random_input_wait);
84 +
85 +
86 +#define EXTRACT_SIZE 10
87 +
88 /*********************************************************************
89 *
90 * Entropy extraction routines
91 --- a/fs/fcntl.c
92 +++ b/fs/fcntl.c
93 @@ -142,6 +142,7 @@ SYSCALL_DEFINE1(dup, unsigned int, filde
94 }
95 return ret;
96 }
97 +EXPORT_SYMBOL(sys_dup);
98
99 #define SETFL_MASK (O_APPEND | O_NONBLOCK | O_NDELAY | O_DIRECT | O_NOATIME)
100
101 --- a/include/linux/miscdevice.h
102 +++ b/include/linux/miscdevice.h
103 @@ -18,6 +18,7 @@
104 #define APOLLO_MOUSE_MINOR 7
105 #define PC110PAD_MINOR 9
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/linux/random.h
112 +++ b/include/linux/random.h
113 @@ -54,6 +54,10 @@ extern void add_input_randomness(unsigne
114 unsigned int value);
115 extern void add_interrupt_randomness(int irq);
116
117 +extern void random_input_words(__u32 *buf, size_t wordcount, int ent_count);
118 +extern int random_input_wait(void);
119 +#define HAS_RANDOM_INPUT_WAIT 1
120 +
121 extern void get_random_bytes(void *buf, int nbytes);
122 void generate_random_uuid(unsigned char uuid_out[16]);
123
This page took 0.0625 seconds and 3 git commands to generate.