Skip to content

add usage hints to prandom and switch to Xoshiro

Markus Theil lkml netdev 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 0 repliesNew
  2. v12 patches 3 repliesSuperseded

Changes in v2 from the cover letter

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

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4prandom: add usage comments for cryptographyinclude/linux/prandom.h lib/random32.c+8 -00 replies
2/4prandom/random32: switch to Xoshiro256++include/linux/prandom.h lib/random32.c+177 -2020 replies
3/4prandom/random32: add checks against invalid statelib/random32.c+24 -10 replies
4/4test_hash.c: replace custom PRNG by prandomlib/tests/test_hash.c+13 -270 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/4] add usage hints to prandom and switch to Xoshiro

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(-)
Signature · 1 line
2.49.0