Re: [PATCH 1/2] random: use chacha20 for get_random_int/long
From: Theodore Ts'o
Date: Tue Jan 17 2017 - 23:50:24 EST
Hi Jason,
I've been taking a look at your patch, and i think it's... problematic.
You're using a union for the entropy_u64 and entropy_u32 arrays, and
the position field is used to indexed into those two arrays.
So if the first caller calls get_random_u64 with position=0, it will
get the first 64 bits out of the batched entropy, and increment the
position to 1. If the second caller calls get_random_u32 with
position=1... it will get the second of the 32-bit chunks in the
batched entropy array --- which will include the 64 bits returned to
the first caller.
That's not very random. :-(
- Ted