mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/4] add usage hints to prandom and switch to Xoshiro
@ 2025-07-04 12:52 Markus Theil
  2025-07-04 12:52 ` [PATCH v2 1/4] prandom: add usage comments for cryptography Markus Theil
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Markus Theil @ 2025-07-04 12:52 UTC (permalink / raw)
  To: netdev, linux-kernel; +Cc: davem, akpm, Jason, Markus Theil

This series builds on top of the crng/master repository, as other
prandom commits are already queued there.

v2:
  - fix indentation
  - add better checks against invalid state
  - rebase

With the current cryptographically safe PRNG in drivers/char/random.c
fast enough for most purposes, make annoyingly clear, that no one should
use the prandom PRNG for cryptographic purposes without known about
this.

While looking at the prandom/random32 code, I informed myself about
PRNGs and saw that currently fast PRNGs with better statistical
properties than LFSR113, which is currently used, are available.

Recent alternatives to consider are in my opinion:
* PCG: https://www.pcg-random.org
* Xoshiro: https://prng.di.unimi.it

While both seem to have good statistical properties, I recommend
to chose Xoshiro256++ here, because it seems to be even faster than
RNGs from the PCG series.

Furthermore, the authors of Xoshiro provide a small RNG named SplitMix64
for generating high quality seeds for the Xoshiro RNG. By using this in
the default way, no further seed checks or state warmup are necessary.
This simplifies the PRNG code IMHO.

Markus Theil (4):
  prandom: add usage comments for cryptography
  prandom/random32: switch to Xoshiro256++
  prandom/random32: add checks against invalid state
  test_hash.c: replace custom PRNG by prandom

 include/linux/prandom.h |  30 +---
 lib/random32.c          | 378 +++++++++++++++++++++-------------------
 lib/tests/test_hash.c   |  40 ++---
 3 files changed, 220 insertions(+), 228 deletions(-)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-04 12:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-04 12:52 [PATCH v2 0/4] add usage hints to prandom and switch to Xoshiro Markus Theil
2025-07-04 12:52 ` [PATCH v2 1/4] prandom: add usage comments for cryptography Markus Theil
2025-07-04 12:52 ` [PATCH v2 2/4] prandom/random32: switch to Xoshiro256++ Markus Theil
2025-07-04 12:52 ` [PATCH v2 3/4] prandom/random32: add checks against invalid state Markus Theil
2025-07-04 12:52 ` [PATCH v2 4/4] test_hash.c: replace custom PRNG by prandom Markus Theil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®