Index | Thread | Search

From:
"Theo de Raadt" <deraadt@openbsd.org>
Subject:
Re: mtrng(4): MediaTek random number generator
To:
James Hastings <moosetek4@gmail.com>
Cc:
Janne Johansson <icepic.dz@gmail.com>, tech@openbsd.org
Date:
Wed, 12 Feb 2025 21:22:05 -0700

Download raw body.

Thread
James Hastings <moosetek4@gmail.com> wrote:

> On Wed, Feb 12, 2025 at 1:04 PM Janne Johansson <icepic.dz@gmail.com> wrote:
> > Den tis 11 feb. 2025 kl 10:40 skrev James Hastings <moosetek4@gmail.com>:
> > >
> > > Add support for the 32-bit random number generator on MediaTek SoCs.
> >
> > > +       if ((sta & RNG_READY) == RNG_READY)
> > > +               enqueue_randomness(bus_space_read_4(sc->sc_iot,
> > > +                   sc->sc_ioh, RNG_DATA));
> > > +
> > > +       timeout_add_sec(&sc->sc_to, 1);
> > > +}
> >
> > Looking at other rngs it seems to be a mix of 10ms or 1s, just
> > wondering what the criteria is for choosing either.
> >
> 
> None of the public datasheets that I have seen include any information
> regarding the RNG at all.
> 
> Without any hard data I chose 1s, as do the majority of *rng drivers in dev/fdt.

One factor might be hardware that can't be read very quickly.  I suspect
all modern hardware can be read very rapidly.  There's a bit that says it
is ready.  You don't want to spin, or waste time in a timeout, that's all.

On the random subsystem side, there's no purpose for being aggressive.
Our random subsystem ALWAYS has good entropy, even from kernel start.
We have numerous small perturbers, which put a very small value in, and
create big effects on through multiple layers of output.  That's why
these drivers are good, but even one 32-bit word once in a while is nice
to have