From: Markus Theil <theil.markus@gmail.com>
To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: davem@davemloft.net, akpm@linux-foundation.org, Jason@zx2c4.com,
Markus Theil <theil.markus@gmail.com>
Subject: [PATCH v2 0/4] add usage hints to prandom and switch to Xoshiro
Date: Fri, 4 Jul 2025 14:52:29 +0200 [thread overview]
Message-ID: <20250704125233.2653779-1-theil.markus@gmail.com> (raw)
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
next reply other threads:[~2025-07-04 12:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-04 12:52 Markus Theil [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250704125233.2653779-1-theil.markus@gmail.com \
--to=theil.markus@gmail.com \
--cc=Jason@zx2c4.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®