On Tue, Apr 05, 2022 at 12:47:14AM +0200, Jason A. Donenfeld wrote: > On Mon, Apr 4, 2022 at 8:49 PM Kees Cook <keescook@xxxxxxxxxxxx> wrote: > > This mixes two changes: the pRNG change and the "use urandom if > > non-deterministic" change. I think these should be split, so the pRNG > > change can be explicitly justified. > > Alright, I'll split those. Or, more probably, just drop the xorshift > thing. There's not actually a strong reason for preferring xorshift. I > did it because it produces more uniformity and is faster to compute and > all that. But none of that stuff actually matters here. It was just a > sort of "well I'm at it..." thing. Well, it's nice to have and you already wrote it, so seems a waste to just drop it. :) > > > static struct plugin_info latent_entropy_plugin_info = { > > > - .version = "201606141920vanilla", > > > + .version = "202203311920vanilla", > > > > This doesn't really need to be versioned. We can change this to just > > "vanilla", IMO. > > Okay. I suppose you want it to be in a different patch too, right? In > which case I'll leave it out and maybe get to it later. (I suppose one > probably needs to double check whether it's used for anything > interesting like dwarf debug info or whatever, where maybe it's > helpful?) Hm, I don't think it shows up anywhere, but you can just drop the hunk that touch it. I can remove them all with a separate patch later. > > > + if (deterministic_seed) { > > > + unsigned HOST_WIDE_INT w = deterministic_seed; > > > + w ^= w << 13; > > > + w ^= w >> 7; > > > + w ^= w << 17; > > > + deterministic_seed = w; > > > + return deterministic_seed; > > > > While seemingly impossible, perhaps don't reset "deterministic_seed", > > and just continue to use "seed", so that it can never become "0" again. > > Not sure I follow. It's an LFSR. The "L" is important. It'll never become > zero. It's not "seemingly". We can prove it trivially in Magma: Got it; yeah. I was reading too quickly. My brain misparsed and got stuck on "left shift", but it's using rotation. Sorry for the noise. -- Kees Cook