Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/random/fortuna.c
Show First 20 Lines • Show All 362 Lines • ▼ Show 20 Lines | #ifdef _KERNEL | ||||
sbintime_t now; | sbintime_t now; | ||||
#endif | #endif | ||||
struct randomdev_hash context; | struct randomdev_hash context; | ||||
uint32_t s[RANDOM_FORTUNA_NPOOLS*RANDOM_KEYSIZE_WORDS]; | uint32_t s[RANDOM_FORTUNA_NPOOLS*RANDOM_KEYSIZE_WORDS]; | ||||
uint8_t temp[RANDOM_KEYSIZE]; | uint8_t temp[RANDOM_KEYSIZE]; | ||||
u_int i; | u_int i; | ||||
KASSERT(fortuna_state.fs_minpoolsize > 0, ("random: Fortuna threshold must be > 0")); | KASSERT(fortuna_state.fs_minpoolsize > 0, ("random: Fortuna threshold must be > 0")); | ||||
RANDOM_RESEED_LOCK(); | |||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
/* FS&K - Use 'getsbinuptime()' to prevent reseed-spamming. */ | /* FS&K - Use 'getsbinuptime()' to prevent reseed-spamming. */ | ||||
now = getsbinuptime(); | now = getsbinuptime(); | ||||
#endif | #endif | ||||
RANDOM_RESEED_LOCK(); | |||||
if (fortuna_state.fs_pool[0].fsp_length >= fortuna_state.fs_minpoolsize | if (fortuna_state.fs_pool[0].fsp_length >= fortuna_state.fs_minpoolsize | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
/* FS&K - Use 'getsbinuptime()' to prevent reseed-spamming. */ | /* FS&K - Use 'getsbinuptime()' to prevent reseed-spamming. */ | ||||
&& (now - fortuna_state.fs_lasttime > SBT_1S/10) | && (now - fortuna_state.fs_lasttime > SBT_1S/10) | ||||
#endif | #endif | ||||
) { | ) { | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |