Re: [PATCH] crypto: loongson - Select CRYPTO_RNG

From: Eric Biggers

Date: Sun May 24 2026 - 23:20:26 EST


On Mon, May 25, 2026 at 10:45:14AM +0800, Qunqin Zhao wrote:
> > > To be honest, I previously assumed that the `hw_random` was designed
> > > strictly and exclusively for the TRNG mode.
> > >
> > > Is it architecturally acceptable or common practice for a PRNG mode to
> > > utilize `hw_random` as well?
> > >
> > > Thanks,
> > So the Loongson RNG is a PRNG? Where does it get its entropy from, and
> > what is its security strength?
>
> Loongson's hardware supports both TRNG and PRNG simultaneously.
>
> We can locate a reseed function within loongson-rng.c, which clearly
> indicates that it is a PRNG driver.

That reseed function gets called with entropy from the Linux RNG. So,
it seems it's really just a PRNG seeded from the Linux RNG. What value
does that provide over just using the Linux RNG directly?

> So the core issue here is whether a PRNG driver can utilize the crypto
> interface.

If you're asking about crypto_rng, it can. But the crypto_rng interface
is also kind of useless. If you're asking about hwrng, it does look
like it's designed for TRNGs. Would it be possible for this driver to
use the TRNG mode?

> If it cannot, does that imply the drivers listed below serve no practical
> purpose? (7.1-rc1)
>
> loongson@loongson:~/upstream/linux/drivers/crypto$ grep crypto_register_rng

Most of the drivers in drivers/crypto/ are added by the hardware
manufacturer without any regard for whether they're useful or not.

- Eric