]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
arc4random(9): Integrate with RANDOM_FENESTRASX push-reseed
authorcem <cem@FreeBSD.org>
Sat, 10 Oct 2020 21:48:06 +0000 (21:48 +0000)
committercem <cem@FreeBSD.org>
Sat, 10 Oct 2020 21:48:06 +0000 (21:48 +0000)
commit0c0ad482a09a0d7d0bed8d58994255081ce6e8d0
treefd4767cadb7447afff7aca06e8ade82fdbe06741
parentfa9cd3bffae6f2d0023c43bad06265ee4721701c
arc4random(9): Integrate with RANDOM_FENESTRASX push-reseed

There is no functional change for the existing Fortuna random(4)
implementation, which remains the default in GENERIC.

In the FenestrasX model, when the root CSPRNG is reseeded from pools due to
an (infrequent) timer, child CSPRNGs can cheaply detect this condition and
reseed.  To do so, they just need to track an additional 64-bit value in the
associated state, and compare it against the root seed version (generation)
on random reads.

This revision integrates arc4random(9) into that model without substantially
changing the design or implementation of arc4random(9).  The motivation is
that arc4random(9) is immediately reseeded when the backing random(4)
implementation has additional entropy.  This is arguably most important
during boot, when fenestrasX is reseeding at 1, 3, 9, 27, etc., second
intervals.  Today, arc4random(9) has a hardcoded 300 second reseed window.
Without this mechanism, if arc4random(9) gets weak entropy during initial
seed (and arc4random(9) is used early in boot, so this is quite possible),
it may continue to emit poorly seeded output for 5 minutes.  The FenestrasX
push-reseed scheme corrects consumers, like arc4random(9), as soon as
possible.

Reviewed by: markm
Approved by: csprng (markm)
Differential Revision: https://reviews.freebsd.org/D22838
sys/dev/random/fenestrasX/fx_brng.c
sys/dev/random/fenestrasX/fx_main.c
sys/dev/random/fenestrasX/fx_pool.c
sys/dev/random/fenestrasX/fx_priv.h
sys/dev/random/fenestrasX/fx_pub.h [new file with mode: 0644]
sys/dev/random/randomdev.c
sys/libkern/arc4random.c
sys/sys/libkern.h