Re: [PATCH 1/2] random: use chacha20 for get_random_int/long

From: Jason A. Donenfeld
Date: Fri Jan 20 2017 - 19:13:53 EST


Hi Ted,

On Sat, Jan 21, 2017 at 1:10 AM, Theodore Ts'o <tytso@xxxxxxx> wrote:
> Why would there be an unaligned access? What I was suggesting was an
> array of u32, and we just do two separate u32 accesses with a shift in
> the case of get_random_u64. There's nothing illegal about that.
>
> u64 retval;
>
> retval = (array[pointer] << 32) + array[pointer+1];
> pointer += 2;

Oh, I see now. I thought you were suggesting casting u32* to u64*.

Yea, this approach works. It's slower than my code, but it gets the job done.

Unless I hear back from you saying "keep with your approach instead of
this one", I'll submit a v2 to you containing this approach instead.

Jason