diff options
| author | Conrad Meyer <cem@FreeBSD.org> | 2018-10-26 21:03:57 +0000 |
|---|---|---|
| committer | Conrad Meyer <cem@FreeBSD.org> | 2018-10-26 21:03:57 +0000 |
| commit | 9b8d0fe462b2f3f689cb87fe34bd42c388e23d49 (patch) | |
| tree | 7ff7a21e52fca88f1ac24f280a507f93b734242e /sys/dev/random | |
| parent | 7be4093a844e80a591221e93d03f3daf6a972be3 (diff) | |
Notes
Diffstat (limited to 'sys/dev/random')
| -rw-r--r-- | sys/dev/random/fortuna.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/dev/random/fortuna.c b/sys/dev/random/fortuna.c index 866899846212..3a46d527fa9a 100644 --- a/sys/dev/random/fortuna.c +++ b/sys/dev/random/fortuna.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #ifdef _KERNEL #include <sys/param.h> +#include <sys/fail.h> #include <sys/kernel.h> #include <sys/lock.h> #include <sys/malloc.h> @@ -385,6 +386,18 @@ random_fortuna_pre_read(void) } #ifdef _KERNEL + /* + * When set, pretend we do not have enough entropy to reseed yet. + */ + KFAIL_POINT_CODE(DEBUG_FP, random_fortuna_pre_read, { + if (RETURN_VALUE != 0) { + RANDOM_RESEED_UNLOCK(); + return; + } + }); +#endif + +#ifdef _KERNEL fortuna_state.fs_lasttime = now; #endif @@ -442,5 +455,13 @@ bool random_fortuna_seeded(void) { +#ifdef _KERNEL + /* When set, act as if we are not seeded. */ + KFAIL_POINT_CODE(DEBUG_FP, random_fortuna_seeded, { + if (RETURN_VALUE != 0) + fortuna_state.fs_counter = UINT128_ZERO; + }); +#endif + return (!uint128_is_zero(fortuna_state.fs_counter)); } |
