* Re: Seeding /dev/random not working
2007-05-29 13:15 ` Theodore Tso
@ 2007-05-29 13:38 ` M Macnair
2007-05-29 14:14 ` Pavel Machek
2007-05-29 17:46 ` Matt Mackall
2 siblings, 0 replies; 17+ messages in thread
From: M Macnair @ 2007-05-29 13:38 UTC (permalink / raw)
To: Theodore Tso, M Macnair, linux-kernel
On 5/29/07, Theodore Tso <tytso@mit.edu> wrote:
> On Tue, May 29, 2007 at 12:53:10PM +0100, M Macnair wrote:
> Ok, so this is telling me a couple of things. First of all, if you're
> only getting three outputs, it means that you don't have any
> peripherals feeding entropy into the system from the boot sequence.
> Without any hard drives, keyboards or mice, and a NIC whose device
> driver hasn't been configured to feed entropy, you're definitely
> hosed.
Yes. However this isn't the issue I'm concerned with at the moment.
> Secondly, and more importantly, your boot scripts aren't set up
> correctly.
Sorry, I only posted the startup bit - the same does indeed happen on
shutdown, however I wasn't interested in it for the purposes of the
tests.
The key point I was trying to put across was that I can't get the
seeding process to work. No matter what I wrote to /dev/urandom on
startup, the output from reading /dev/urandom immediately afterwards
was the same (ignoring the occasional variation that I put down to
timing). As I understand it (from man 4 random and the boot script
examples), writing to /dev/[u]random should increase the amount of
entropy, thereby altering the output from the PRNG.
> Another thing which I noticed is that when Matt Mackall took over
> maintainership of /dev/random, he apparently took out one of the
> safeguards I had, which was that before, when entropy was extracted
> from the pool the time stamp when it was extracted was mixed back into
> the pool. The theory was that an external attacker might not know
> when a program might be calling /dev/random, so mixing in the time of
> that entropy was extracted wouldn't hurt, and might help. I'll submit
> a patch to add that support back in, which will help you a little.
When did Matt take over? From my experiments it would appear as
though the time is having an effect on the output, though as I say I'm
not totally sure.
Regards,
Michael Macnair
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Seeding /dev/random not working
2007-05-29 13:15 ` Theodore Tso
2007-05-29 13:38 ` M Macnair
@ 2007-05-29 14:14 ` Pavel Machek
2007-05-29 15:17 ` M Macnair
` (2 more replies)
2007-05-29 17:46 ` Matt Mackall
2 siblings, 3 replies; 17+ messages in thread
From: Pavel Machek @ 2007-05-29 14:14 UTC (permalink / raw)
To: Theodore Tso, M Macnair, linux-kernel
Hi!
> > I have two embedded boards (one ARM, one PowerPC), running two
> > different versions of 2.6. They have no hard drives, keyboards or
> > mice. They each have a NIC, but I understand these make no
> > contribution to the entropy pool.
> >
> > if [ -f $random_seed ]; then
> > cat $random_seed >/dev/urandom # should seed the pool
> > fi
> > dd if=/dev/urandom of=$random_seed count=1 2>/dev/null # save some
> > data from urandom for next boot
> >
> > I have rebooted my boards many times, and after each boot I read the
> > contents of $random_seed. Whilst it does not happen every time, the
> > contents of $random_seed are /often the same/. To give you a feel:
> > rebooted 11 times, got a total of 3 different outputs.
>
> Ok, so this is telling me a couple of things. First of all, if you're
> only getting three outputs, it means that you don't have any
> peripherals feeding entropy into the system from the boot sequence.
> Without any hard drives, keyboards or mice, and a NIC whose device
> driver hasn't been configured to feed entropy, you're definitely
> hosed.
Can we get at least time-of-boot from rtc clock to the pool? We really
should not be getting identical outputs...
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: Seeding /dev/random not working
2007-05-29 14:14 ` Pavel Machek
@ 2007-05-29 15:17 ` M Macnair
2007-05-29 15:31 ` Jesper Juhl
2007-05-29 16:30 ` Theodore Tso
2007-05-29 20:06 ` Folkert van Heusden
2 siblings, 1 reply; 17+ messages in thread
From: M Macnair @ 2007-05-29 15:17 UTC (permalink / raw)
To: Pavel Machek; +Cc: Theodore Tso, linux-kernel
On 5/29/07, Pavel Machek <pavel@ucw.cz> wrote:
> Hi!
>
> > > I have two embedded boards (one ARM, one PowerPC), running two
> > > different versions of 2.6. They have no hard drives, keyboards or
> > > mice. They each have a NIC, but I understand these make no
> > > contribution to the entropy pool.
> > >
> > > if [ -f $random_seed ]; then
> > > cat $random_seed >/dev/urandom # should seed the pool
> > > fi
> > > dd if=/dev/urandom of=$random_seed count=1 2>/dev/null # save some
> > > data from urandom for next boot
> > >
> > > I have rebooted my boards many times, and after each boot I read the
> > > contents of $random_seed. Whilst it does not happen every time, the
> > > contents of $random_seed are /often the same/. To give you a feel:
> > > rebooted 11 times, got a total of 3 different outputs.
> >
> > Ok, so this is telling me a couple of things. First of all, if you're
> > only getting three outputs, it means that you don't have any
> > peripherals feeding entropy into the system from the boot sequence.
> > Without any hard drives, keyboards or mice, and a NIC whose device
> > driver hasn't been configured to feed entropy, you're definitely
> > hosed.
>
> Can we get at least time-of-boot from rtc clock to the pool? We really
> should not be getting identical outputs...
Ah yes that is one thing I forgot to mention - when you turn these
boards off, you really do turn them off - no battery means no clock.
They wake up every time in 1970.
I am planning on providing my own entropy to this system by feeding
/dev/random (which leads to the problem of it not working...).
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Seeding /dev/random not working
2007-05-29 15:17 ` M Macnair
@ 2007-05-29 15:31 ` Jesper Juhl
0 siblings, 0 replies; 17+ messages in thread
From: Jesper Juhl @ 2007-05-29 15:31 UTC (permalink / raw)
To: M Macnair; +Cc: Pavel Machek, Theodore Tso, linux-kernel
On 29/05/07, M Macnair <mmacnair@gmail.com> wrote:
> On 5/29/07, Pavel Machek <pavel@ucw.cz> wrote:
> > Hi!
> >
> > > > I have two embedded boards (one ARM, one PowerPC), running two
> > > > different versions of 2.6. They have no hard drives, keyboards or
> > > > mice. They each have a NIC, but I understand these make no
> > > > contribution to the entropy pool.
> > > >
> > > > if [ -f $random_seed ]; then
> > > > cat $random_seed >/dev/urandom # should seed the pool
> > > > fi
> > > > dd if=/dev/urandom of=$random_seed count=1 2>/dev/null # save some
> > > > data from urandom for next boot
> > > >
> > > > I have rebooted my boards many times, and after each boot I read the
> > > > contents of $random_seed. Whilst it does not happen every time, the
> > > > contents of $random_seed are /often the same/. To give you a feel:
> > > > rebooted 11 times, got a total of 3 different outputs.
> > >
> > > Ok, so this is telling me a couple of things. First of all, if you're
> > > only getting three outputs, it means that you don't have any
> > > peripherals feeding entropy into the system from the boot sequence.
> > > Without any hard drives, keyboards or mice, and a NIC whose device
> > > driver hasn't been configured to feed entropy, you're definitely
> > > hosed.
> >
> > Can we get at least time-of-boot from rtc clock to the pool? We really
> > should not be getting identical outputs...
>
> Ah yes that is one thing I forgot to mention - when you turn these
> boards off, you really do turn them off - no battery means no clock.
> They wake up every time in 1970.
>
> I am planning on providing my own entropy to this system by feeding
> /dev/random (which leads to the problem of it not working...).
Depending on how high quality randomness you need, you could just let
your NIC driver provide entropy by changing interrupt handlers to use
SA_SAMPLE_RANDOM.
Sure, getting entropy that way allows an outside attacker to influence
the pool if they can obtain a high degree of control over what data
you recieve and when, but in most realistic scenarios it should be
acceptable (and it's certainly better than no entropy at all).
--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Seeding /dev/random not working
2007-05-29 14:14 ` Pavel Machek
2007-05-29 15:17 ` M Macnair
@ 2007-05-29 16:30 ` Theodore Tso
2007-05-29 20:06 ` Folkert van Heusden
2 siblings, 0 replies; 17+ messages in thread
From: Theodore Tso @ 2007-05-29 16:30 UTC (permalink / raw)
To: Pavel Machek; +Cc: M Macnair, linux-kernel
On Tue, May 29, 2007 at 02:14:56PM +0000, Pavel Machek wrote:
> Can we get at least time-of-boot from rtc clock to the pool? We really
> should not be getting identical outputs...
We are mixing the time-of-dat at boot time into the pool already,
using ktime_get_real() in random.c:init_std_data(). The problem
though is if the board doesn't have a valid RTC clock, or its battery
is dead, and the time-of-day clock is getting set by userspace, then
unless userspace also mixes in the time once it's been set via ntpdate
or whatever, it won't help the entropy pool.
- Ted
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Seeding /dev/random not working
2007-05-29 14:14 ` Pavel Machek
2007-05-29 15:17 ` M Macnair
2007-05-29 16:30 ` Theodore Tso
@ 2007-05-29 20:06 ` Folkert van Heusden
2 siblings, 0 replies; 17+ messages in thread
From: Folkert van Heusden @ 2007-05-29 20:06 UTC (permalink / raw)
To: Pavel Machek, Theodore Tso, M Macnair, linux-kernel
> > > I have two embedded boards (one ARM, one PowerPC), running two
> > > different versions of 2.6. They have no hard drives, keyboards or
> > > mice. They each have a NIC, but I understand these make no
> > > contribution to the entropy pool.
> > > if [ -f $random_seed ]; then
> > > cat $random_seed >/dev/urandom # should seed the pool
> > > fi
> > > dd if=/dev/urandom of=$random_seed count=1 2>/dev/null # save some
> > > data from urandom for next boot
> > > I have rebooted my boards many times, and after each boot I read the
> > > contents of $random_seed. Whilst it does not happen every time, the
> > > contents of $random_seed are /often the same/. To give you a feel:
> > > rebooted 11 times, got a total of 3 different outputs.
> >
> > Ok, so this is telling me a couple of things. First of all, if you're
> > only getting three outputs, it means that you don't have any
> > peripherals feeding entropy into the system from the boot sequence.
> > Without any hard drives, keyboards or mice, and a NIC whose device
> > driver hasn't been configured to feed entropy, you're definitely
> > hosed.
>
> Can we get at least time-of-boot from rtc clock to the pool? We really
> should not be getting identical outputs...
And add readings from lm-sensors as well? I guess harddisk and cpu
temperatures (lower bits) and such are pretty random?
Folkert van Heusden
--
MultiTail est un flexible tool pour suivre de logfiles et execution de
commandements. Filtrer, pourvoir de couleur, merge, 'diff-view', etc.
http://www.vanheusden.com/multitail/
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Seeding /dev/random not working
2007-05-29 13:15 ` Theodore Tso
2007-05-29 13:38 ` M Macnair
2007-05-29 14:14 ` Pavel Machek
@ 2007-05-29 17:46 ` Matt Mackall
2007-05-29 18:00 ` Matt Mackall
2007-05-29 19:23 ` Eric Dumazet
2 siblings, 2 replies; 17+ messages in thread
From: Matt Mackall @ 2007-05-29 17:46 UTC (permalink / raw)
To: Theodore Tso, M Macnair, linux-kernel
On Tue, May 29, 2007 at 09:15:01AM -0400, Theodore Tso wrote:
> Another thing which I noticed is that when Matt Mackall took over
> maintainership of /dev/random, he apparently took out one of the
> safeguards I had, which was that before, when entropy was extracted
> from the pool the time stamp when it was extracted was mixed back into
> the pool. The theory was that an external attacker might not know
> when a program might be calling /dev/random, so mixing in the time of
> that entropy was extracted wouldn't hurt, and might help. I'll submit
> a patch to add that support back in, which will help you a little.
It's still there, and in the same place, it just looks different:
static void add_timer_randomness(struct timer_rand_state *state,
unsigned num)
{
...
sample.jiffies = jiffies;
sample.cycles = get_cycles();
sample.num = num;
add_entropy_words(&input_pool, (u32 *)&sample,
sizeof(sample)/4);
Trouble is the write(2) interface calls add_entropy_words directly, as
does the pool initialization function.
We might as well mix jiffies and cycles in at init time in a manner
similar to the above. Something like this (untested):
Index: l/drivers/char/random.c
===================================================================
--- l.orig/drivers/char/random.c 2007-05-29 12:45:00.000000000 -0500
+++ l/drivers/char/random.c 2007-05-29 12:44:02.000000000 -0500
@@ -559,6 +559,26 @@ static struct timer_rand_state input_tim
static struct timer_rand_state *irq_timer_state[NR_IRQS];
/*
+ * Mix a sample of the current time into the pool with no entropy
+ * accounting
+ */
+static long __add_timer_randomness(void)
+{
+ struct {
+ cycles_t cycles;
+ long jiffies;
+ unsigned num;
+ } sample;
+
+ sample.jiffies = jiffies;
+ sample.cycles = get_cycles();
+ sample.num = num;
+ add_entropy_words(&input_pool, (u32 *)&sample, sizeof(sample)/4);
+
+ return sample.jiffies;
+}
+
+/*
* This function adds entropy to the entropy "pool" by using timing
* delays. It uses the timer_rand_state structure to make an estimate
* of how many bits of entropy this call has added to the pool.
@@ -570,12 +590,7 @@ static struct timer_rand_state *irq_time
*/
static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
{
- struct {
- cycles_t cycles;
- long jiffies;
- unsigned num;
- } sample;
- long delta, delta2, delta3;
+ long timestamp, delta, delta2, delta3;
preempt_disable();
/* if over the trickle threshold, use only 1 in 4096 samples */
@@ -583,10 +598,7 @@ static void add_timer_randomness(struct
(__get_cpu_var(trickle_count)++ & 0xfff))
goto out;
- sample.jiffies = jiffies;
- sample.cycles = get_cycles();
- sample.num = num;
- add_entropy_words(&input_pool, (u32 *)&sample, sizeof(sample)/4);
+ timestamp = __add_timer_randomness();
/*
* Calculate number of bits of randomness we probably added.
@@ -595,8 +607,8 @@ static void add_timer_randomness(struct
*/
if (!state->dont_count_entropy) {
- delta = sample.jiffies - state->last_time;
- state->last_time = sample.jiffies;
+ delta = timestamp - state->last_time;
+ state->last_time = timestamp;
delta2 = delta - state->last_delta;
state->last_delta = delta;
@@ -899,6 +911,7 @@ static int __init rand_initialize(void)
init_std_data(&input_pool);
init_std_data(&blocking_pool);
init_std_data(&nonblocking_pool);
+ __add_timer_randomness();
return 0;
}
module_init(rand_initialize);
@@ -1028,6 +1041,8 @@ random_write(struct file * file, const c
const char __user *p = buffer;
size_t c = count;
+ __add_timer_randomness();
+
while (c > 0) {
bytes = min(c, sizeof(buf));
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: Seeding /dev/random not working
2007-05-29 17:46 ` Matt Mackall
@ 2007-05-29 18:00 ` Matt Mackall
2007-05-29 19:23 ` Eric Dumazet
1 sibling, 0 replies; 17+ messages in thread
From: Matt Mackall @ 2007-05-29 18:00 UTC (permalink / raw)
To: Theodore Tso, M Macnair, linux-kernel
On Tue, May 29, 2007 at 12:46:14PM -0500, Matt Mackall wrote:
> We might as well mix jiffies and cycles in at init time in a manner
> similar to the above. Something like this (untested):
Scratch that one. Here's one that compiles and seems to work under
lguest:
Index: l/drivers/char/random.c
===================================================================
--- l.orig/drivers/char/random.c 2007-05-29 12:45:00.000000000 -0500
+++ l/drivers/char/random.c 2007-05-29 12:50:02.000000000 -0500
@@ -559,6 +559,26 @@ static struct timer_rand_state input_tim
static struct timer_rand_state *irq_timer_state[NR_IRQS];
/*
+ * Mix a sample of the current time into the pool with no entropy
+ * accounting
+ */
+static long __add_timer_randomness(unsigned num)
+{
+ struct {
+ cycles_t cycles;
+ long jiffies;
+ unsigned num;
+ } sample;
+
+ sample.jiffies = jiffies;
+ sample.cycles = get_cycles();
+ sample.num = num;
+ add_entropy_words(&input_pool, (u32 *)&sample, sizeof(sample)/4);
+
+ return sample.jiffies;
+}
+
+/*
* This function adds entropy to the entropy "pool" by using timing
* delays. It uses the timer_rand_state structure to make an estimate
* of how many bits of entropy this call has added to the pool.
@@ -570,12 +590,7 @@ static struct timer_rand_state *irq_time
*/
static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
{
- struct {
- cycles_t cycles;
- long jiffies;
- unsigned num;
- } sample;
- long delta, delta2, delta3;
+ long timestamp, delta, delta2, delta3;
preempt_disable();
/* if over the trickle threshold, use only 1 in 4096 samples */
@@ -583,10 +598,7 @@ static void add_timer_randomness(struct
(__get_cpu_var(trickle_count)++ & 0xfff))
goto out;
- sample.jiffies = jiffies;
- sample.cycles = get_cycles();
- sample.num = num;
- add_entropy_words(&input_pool, (u32 *)&sample, sizeof(sample)/4);
+ timestamp = __add_timer_randomness(num);
/*
* Calculate number of bits of randomness we probably added.
@@ -595,8 +607,8 @@ static void add_timer_randomness(struct
*/
if (!state->dont_count_entropy) {
- delta = sample.jiffies - state->last_time;
- state->last_time = sample.jiffies;
+ delta = timestamp - state->last_time;
+ state->last_time = timestamp;
delta2 = delta - state->last_delta;
state->last_delta = delta;
@@ -899,6 +911,7 @@ static int __init rand_initialize(void)
init_std_data(&input_pool);
init_std_data(&blocking_pool);
init_std_data(&nonblocking_pool);
+ __add_timer_randomness(0);
return 0;
}
module_init(rand_initialize);
@@ -1028,6 +1041,8 @@ random_write(struct file * file, const c
const char __user *p = buffer;
size_t c = count;
+ __add_timer_randomness(0);
+
while (c > 0) {
bytes = min(c, sizeof(buf));
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: Seeding /dev/random not working
2007-05-29 17:46 ` Matt Mackall
2007-05-29 18:00 ` Matt Mackall
@ 2007-05-29 19:23 ` Eric Dumazet
2007-05-29 19:35 ` Matt Mackall
1 sibling, 1 reply; 17+ messages in thread
From: Eric Dumazet @ 2007-05-29 19:23 UTC (permalink / raw)
To: Matt Mackall; +Cc: Theodore Tso, M Macnair, linux-kernel
Matt Mackall a écrit :
> On Tue, May 29, 2007 at 09:15:01AM -0400, Theodore Tso wrote:
>> Another thing which I noticed is that when Matt Mackall took over
>> maintainership of /dev/random, he apparently took out one of the
>> safeguards I had, which was that before, when entropy was extracted
>> from the pool the time stamp when it was extracted was mixed back into
>> the pool. The theory was that an external attacker might not know
>> when a program might be calling /dev/random, so mixing in the time of
>> that entropy was extracted wouldn't hurt, and might help. I'll submit
>> a patch to add that support back in, which will help you a little.
>
> It's still there, and in the same place, it just looks different:
>
> static void add_timer_randomness(struct timer_rand_state *state,
> unsigned num)
> {
> ...
> sample.jiffies = jiffies;
> sample.cycles = get_cycles();
> sample.num = num;
> add_entropy_words(&input_pool, (u32 *)&sample,
> sizeof(sample)/4);
>
> Trouble is the write(2) interface calls add_entropy_words directly, as
> does the pool initialization function.
>
> We might as well mix jiffies and cycles in at init time in a manner
> similar to the above. Something like this (untested):
>
> Index: l/drivers/char/random.c
> ===================================================================
> --- l.orig/drivers/char/random.c 2007-05-29 12:45:00.000000000 -0500
> +++ l/drivers/char/random.c 2007-05-29 12:44:02.000000000 -0500
> @@ -559,6 +559,26 @@ static struct timer_rand_state input_tim
> static struct timer_rand_state *irq_timer_state[NR_IRQS];
>
> /*
> + * Mix a sample of the current time into the pool with no entropy
> + * accounting
> + */
> +static long __add_timer_randomness(void)
> +{
> + struct {
> + cycles_t cycles;
> + long jiffies;
> + unsigned num;
> + } sample;
> +
> + sample.jiffies = jiffies;
> + sample.cycles = get_cycles();
> + sample.num = num;
> + add_entropy_words(&input_pool, (u32 *)&sample, sizeof(sample)/4);
Well, you need to pass 'num' argument I guess.
But... How is this supposed to work on 64 bits arches ?
Because of alignment, 'struct sample' will include a 4 bytes filler after
'unsigned num', and sizeof(sample) will include this (null) filler in entropy
pool.
Shouldn't we use __attribute__((packed)) on 'struct sample' definition ?
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: Seeding /dev/random not working
2007-05-29 19:23 ` Eric Dumazet
@ 2007-05-29 19:35 ` Matt Mackall
0 siblings, 0 replies; 17+ messages in thread
From: Matt Mackall @ 2007-05-29 19:35 UTC (permalink / raw)
To: Eric Dumazet; +Cc: Theodore Tso, M Macnair, linux-kernel
On Tue, May 29, 2007 at 09:23:31PM +0200, Eric Dumazet wrote:
> Matt Mackall a écrit :
> >On Tue, May 29, 2007 at 09:15:01AM -0400, Theodore Tso wrote:
> >>Another thing which I noticed is that when Matt Mackall took over
> >>maintainership of /dev/random, he apparently took out one of the
> >>safeguards I had, which was that before, when entropy was extracted
> >>from the pool the time stamp when it was extracted was mixed back into
> >>the pool. The theory was that an external attacker might not know
> >>when a program might be calling /dev/random, so mixing in the time of
> >>that entropy was extracted wouldn't hurt, and might help. I'll submit
> >>a patch to add that support back in, which will help you a little.
> >
> >It's still there, and in the same place, it just looks different:
> >
> >static void add_timer_randomness(struct timer_rand_state *state,
> >unsigned num)
> >{
> >...
> > sample.jiffies = jiffies;
> > sample.cycles = get_cycles();
> > sample.num = num;
> > add_entropy_words(&input_pool, (u32 *)&sample,
> > sizeof(sample)/4);
> >
> >Trouble is the write(2) interface calls add_entropy_words directly, as
> >does the pool initialization function.
> >
> >We might as well mix jiffies and cycles in at init time in a manner
> >similar to the above. Something like this (untested):
> >
> >Index: l/drivers/char/random.c
> >===================================================================
> >--- l.orig/drivers/char/random.c 2007-05-29 12:45:00.000000000 -0500
> >+++ l/drivers/char/random.c 2007-05-29 12:44:02.000000000 -0500
> >@@ -559,6 +559,26 @@ static struct timer_rand_state input_tim
> > static struct timer_rand_state *irq_timer_state[NR_IRQS];
> >
> > /*
> >+ * Mix a sample of the current time into the pool with no entropy
> >+ * accounting
> >+ */
> >+static long __add_timer_randomness(void)
> >+{
> >+ struct {
> >+ cycles_t cycles;
> >+ long jiffies;
> >+ unsigned num;
> >+ } sample;
> >+
> >+ sample.jiffies = jiffies;
> >+ sample.cycles = get_cycles();
> >+ sample.num = num;
> >+ add_entropy_words(&input_pool, (u32 *)&sample, sizeof(sample)/4);
>
> Well, you need to pass 'num' argument I guess.
Yep, fixed version already posted.
> But... How is this supposed to work on 64 bits arches ?
>
> Because of alignment, 'struct sample' will include a 4 bytes filler after
> 'unsigned num', and sizeof(sample) will include this (null) filler in
> entropy pool.
Doesn't matter, just churns the pool a bit more. It gets XORed over
existing data (aka NOP) and doesn't get counted as extra entropy or
anything.
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 17+ messages in thread