Re: [PATCH] crypto: loongson - Select CRYPTO_RNG

From: Qunqin Zhao

Date: Mon May 25 2026 - 04:23:31 EST



在 2026/5/25 上午11:20, Eric Biggers 写道:
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?

Alternatively,the reseed function can serve  as a stirring mechanism, where the primary entropy comes from the internal hardware TRNG.

Or simply ignore the  entropy from the Linux RNG entirely, trigger a reseeding internal.


The driver merely forwards the seed to the firmware; how it is utilized and what kind of random numbers are returned are entirely determined by the firmware implementation.


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?

I mean crypto_rng.

We might use the hwrng interface to add support for the TRNG in this driver.


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.

If we are dropping crypto-rng drivers entirely,

I am fine with removing the Loongson driver along with the others.

However, targeting the Loongson driver alone is unacceptable.


Thanks,

Qunqin.


- Eric