Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/random/fortuna.c
Show All 29 Lines | |||||
* This implementation of Fortuna is based on the descriptions found in | * This implementation of Fortuna is based on the descriptions found in | ||||
* ISBN 978-0-470-47424-2 "Cryptography Engineering" by Ferguson, Schneier | * ISBN 978-0-470-47424-2 "Cryptography Engineering" by Ferguson, Schneier | ||||
* and Kohno ("FS&K"). | * and Kohno ("FS&K"). | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | |||||
#include <sys/limits.h> | #include <sys/limits.h> | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
#include <sys/param.h> | |||||
#include <sys/fail.h> | #include <sys/fail.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/random.h> | #include <sys/random.h> | ||||
#include <sys/sdt.h> | #include <sys/sdt.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <machine/cpu.h> | #include <machine/cpu.h> | ||||
#include <crypto/rijndael/rijndael-api-fst.h> | |||||
#include <crypto/sha2/sha256.h> | |||||
#include <dev/random/hash.h> | |||||
#include <dev/random/randomdev.h> | |||||
#include <dev/random/random_harvestq.h> | |||||
#include <dev/random/uint128.h> | |||||
#include <dev/random/fortuna.h> | |||||
#else /* !_KERNEL */ | #else /* !_KERNEL */ | ||||
#include <sys/param.h> | |||||
#include <inttypes.h> | #include <inttypes.h> | ||||
#include <stdbool.h> | #include <stdbool.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <threads.h> | #include <threads.h> | ||||
#include "unit_test.h" | #include "unit_test.h" | ||||
#endif /* _KERNEL */ | |||||
#include <crypto/rijndael/rijndael-api-fst.h> | #include <crypto/rijndael/rijndael-api-fst.h> | ||||
#include <crypto/sha2/sha256.h> | #include <crypto/sha2/sha256.h> | ||||
#include <dev/random/hash.h> | #include <dev/random/hash.h> | ||||
#include <dev/random/randomdev.h> | #include <dev/random/randomdev.h> | ||||
#ifdef _KERNEL | |||||
#include <dev/random/random_harvestq.h> | |||||
#endif | |||||
#include <dev/random/uint128.h> | #include <dev/random/uint128.h> | ||||
#include <dev/random/fortuna.h> | #include <dev/random/fortuna.h> | ||||
#endif /* _KERNEL */ | |||||
/* Defined in FS&K */ | /* Defined in FS&K */ | ||||
#define RANDOM_FORTUNA_NPOOLS 32 /* The number of accumulation pools */ | #define RANDOM_FORTUNA_NPOOLS 32 /* The number of accumulation pools */ | ||||
#define RANDOM_FORTUNA_DEFPOOLSIZE 64 /* The default pool size/length for a (re)seed */ | #define RANDOM_FORTUNA_DEFPOOLSIZE 64 /* The default pool size/length for a (re)seed */ | ||||
#define RANDOM_FORTUNA_MAX_READ (1 << 20) /* Max bytes in a single read */ | #define RANDOM_FORTUNA_MAX_READ (1 << 20) /* Max bytes in a single read */ | ||||
/* | /* | ||||
* The allowable range of RANDOM_FORTUNA_DEFPOOLSIZE. The default value is above. | * The allowable range of RANDOM_FORTUNA_DEFPOOLSIZE. The default value is above. | ||||
▲ Show 20 Lines • Show All 375 Lines • Show Last 20 Lines |