Re: [PATCH v2] random: avoid superfluous call to RDRAND in CRNG extraction
From: Jason A. Donenfeld
Date: Thu Jan 20 2022 - 10:04:02 EST
On Tue, Jan 4, 2022 at 6:55 AM Theodore Ts'o <tytso@xxxxxxx> wrote:
> If we want to worry about what happens if we could actually manage to
> call _extract_crng() more than 2**64 times before the reseed interval
> is up --- which *is* one of the benefits of:
>
> if (arch_get_random_long(^v))
> crng->state[14] ^= v;
>
> I could see doing perhaps this instead:
>
> if (crng->state[12] == 0) {
> crng->state[13]++;
> if (crng->state[13] == 0) {
> crng->state[14]++;
> if (crng->state[14] == 0) {
> crng->state[15]++;
> }
> }
> }
While probably overkill, I've got a patch that does this while also
labeling these constants. I'll send that as a reply to this message.
Jason