Re: [PATCH 07/12] random: use the arch-specific rng in xfer_secondary_pool

Ben Hutchings
2012-07-08T01:07:05Z

[-- Attachment #1: Type: text/plain, Size: 1119 bytes --]

On Fri, 2012-07-06 at 18:44 -0400, Theodore Ts'o wrote:
> If the CPU supports a hardware random number generator, use it in
> xfer_secondary_pool(), where it will significantly improve things and
> where we can afford it.
>
> Also, remove the use of the arch-specific rng in
> add_timer_randomness(), since the call is significantly slower than
> get_cycles(), and we're much better off using it in
> xfer_secondary_pool() anyway.
[...]
> @@ -838,7 +834,11 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,
> */
> static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
> {
> - __u32 tmp[OUTPUT_POOL_WORDS];
> + union {
> + __u32 tmp[OUTPUT_POOL_WORDS];
> + long hwrand[4];
> + } u;
> + int i;
[...]
> + for (i = 0; i < 4; i++)
> + if (arch_get_random_long(&u.hwrand[i]))
> + break;
> + if (i)
> + mix_pool_bytes(r, &u.hwrand, sizeof(u.hwrand), 0);
[...]

Surely the number of random bytes being added is i * sizeof(long), not
sizeof(u.hwrand)?

Ben.

--
Ben Hutchings
Life would be so much easier if we could look at the source code.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]