lkml.org 
[lkml]   [2017]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 1/2] random: use chacha20 for get_random_int/long
Hi Ted,

On Wed, Jan 18, 2017 at 4:49 AM, Theodore Ts'o <tytso@mit.edu> wrote:
> 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.

This is most certainly not the case. Read closely.

I use a different variable for each function. get_random_u32 only
touches batched_entropy_u32, and get_random_u64 only touches
bached_entropy_u64. Under no circumstances will one function use the
other's batched entropy.

I use a union so that only one struct must be declared. If you think
that's unclear, I can declare two separate structs instead. Let me
know which strategy you prefer -- what I have now, or splitting it
into two structs.

Jason

\
 
 \ /
  Last update: 2017-01-20 06:28    [W:0.091 / U:0.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site