Re: [PATCH v3] x86/coco: Require seeding RNG with RDRAND on CoCo systems

From: Jason A. Donenfeld
Date: Wed Feb 21 2024 - 12:20:03 EST


On Wed, Feb 21, 2024 at 5:55 PM Dave Hansen <dave.hansen@xxxxxxxxx> wrote:
>
> On 2/21/24 04:32, Jason A. Donenfeld wrote:
> > +__init void cc_random_init(void)
> > +{
> > + unsigned long rng_seed[32 / sizeof(long)];
>
> My only nit with this is the magic "32".
>
> Why not 16? Or 64?

32 bytes = 256-bits = what we're targeting. Very normal thing to see
places in the RNG, used all over random.c and lots of platform
drivers. Pretty obvious and straightforward to anyone familiar with
this kind of code. Not the kind of thing you'd want to replace with
some abstracted constant that makes you search.