aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/libkern.h
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2020-10-10 21:48:06 +0000
committerConrad Meyer <cem@FreeBSD.org>2020-10-10 21:48:06 +0000
commit10b1a17594a27f83c3ddbce44814f15a0b6bab91 (patch)
treefd4767cadb7447afff7aca06e8ade82fdbe06741 /sys/sys/libkern.h
parenta3c41f8bfbc713e748ee00dd61316c15eea9b3d1 (diff)
downloadsrc-10b1a17594a27f83c3ddbce44814f15a0b6bab91.tar.gz
src-10b1a17594a27f83c3ddbce44814f15a0b6bab91.zip
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
Notes
Notes: svn path=/head/; revision=366621
Diffstat (limited to 'sys/sys/libkern.h')
-rw-r--r--sys/sys/libkern.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h
index 8d976e18ea28..7385df139297 100644
--- a/sys/sys/libkern.h
+++ b/sys/sys/libkern.h
@@ -116,10 +116,12 @@ static __inline int abs(int a) { return (a < 0 ? -a : a); }
static __inline long labs(long a) { return (a < 0 ? -a : a); }
static __inline quad_t qabs(quad_t a) { return (a < 0 ? -a : a); }
+#ifndef RANDOM_FENESTRASX
#define ARC4_ENTR_NONE 0 /* Don't have entropy yet. */
#define ARC4_ENTR_HAVE 1 /* Have entropy. */
#define ARC4_ENTR_SEED 2 /* Reseeding. */
extern int arc4rand_iniseed_state;
+#endif
/* Prototypes for non-quad routines. */
struct malloc_type;