Changeset View
Standalone View
sys/dev/random/random_harvestq.c
Show First 20 Lines • Show All 346 Lines • ▼ Show 20 Lines | random_harvestq_prime(void *unused __unused) | ||||
struct harvest_event event; | struct harvest_event event; | ||||
size_t count, size, i; | size_t count, size, i; | ||||
uint8_t *keyfile, *data; | uint8_t *keyfile, *data; | ||||
/* | /* | ||||
* Get entropy that may have been preloaded by loader(8) | * Get entropy that may have been preloaded by loader(8) | ||||
* and use it to pre-charge the entropy harvest queue. | * and use it to pre-charge the entropy harvest queue. | ||||
*/ | */ | ||||
keyfile = preload_search_by_type(RANDOM_HARVESTQ_BOOT_ENTROPY_FILE); | keyfile = preload_search_by_type(RANDOM_CACHED_BOOT_ENTROPY_MODULE); | ||||
#ifndef NO_BACKWARD_COMPATIBILITY | |||||
if (keyfile == NULL) | |||||
keyfile = preload_search_by_type(RANDOM_LEGACY_BOOT_ENTROPY_MODULE); | |||||
#endif | |||||
jmg: the name _ENTROPY_FILE is misnamed and should be named _ENTROPY_MODULE as this is the name of… | |||||
Done Inline ActionsI agree. I'd like to point out that the choose of value is somewhat confusing (e.g. if someone change the value, they may do a s,/boot/entropy,/my/entropy, which will render this configuration useless), by the way, as all other loader file types are named in "module_type" style. Perhaps we should change this to something like "random_cachedentropy", and add support to the old value? delphij: I agree.
I'd like to point out that the choose of value is somewhat confusing (e.g. if someone… | |||||
Done Inline ActionsI think we should do something like this in addition to the existing code: #ifndef NO_BACKWARD_COMPATIBILITY if (keyfile != NULL) keyfile = preload_search_by_type(RANDOM_CACHED_BOOT_LEGACY_ENTROPY_MODULE); #endif So the kernel knows to try loading it if the "new" cached type do not exist? Without it, users upgrading may end up with unseeded pool. delphij: I think we should do something like this in addition to the existing code:
```
#ifndef… | |||||
Done Inline ActionsThis says "if the preload_search_by_type() search worked, then replace it by another search that might not work". Is this what you meant to say? markm: This says "if the preload_search_by_type() search worked, then replace it by another search… | |||||
Done Inline ActionsOh good catch! Yes, you are correct that this should be if (keyfile == NULL) i.e. if we can't find the new type, fallback to old type. delphij: Oh good catch! Yes, you are correct that this should be if (keyfile == NULL) i.e. if we can't… | |||||
if (keyfile != NULL) { | if (keyfile != NULL) { | ||||
data = preload_fetch_addr(keyfile); | data = preload_fetch_addr(keyfile); | ||||
size = preload_fetch_size(keyfile); | size = preload_fetch_size(keyfile); | ||||
/* skip the first bit of the stash so others like arc4 can also have some. */ | |||||
if (size > RANDOM_CACHED_SKIP_START) { | |||||
data += RANDOM_CACHED_SKIP_START; | |||||
Not Done Inline Actionsthis is a hack and should be solved in a better manner, like having chacha pull it's data from the random subsystem like arc4 did instead of seeding it this way. jmg: this is a hack and should be solved in a better manner, like having chacha pull it's data from… | |||||
size -= RANDOM_CACHED_SKIP_START; | |||||
} | |||||
/* Trim the size. If the admin has a file with a funny size, we lose some. Tough. */ | /* Trim the size. If the admin has a file with a funny size, we lose some. Tough. */ | ||||
size -= (size % sizeof(event.he_entropy)); | size -= (size % sizeof(event.he_entropy)); | ||||
if (data != NULL && size != 0) { | if (data != NULL && size != 0) { | ||||
for (i = 0; i < size; i += sizeof(event.he_entropy)) { | for (i = 0; i < size; i += sizeof(event.he_entropy)) { | ||||
count = sizeof(event.he_entropy); | count = sizeof(event.he_entropy); | ||||
event.he_somecounter = (uint32_t)get_cyclecount(); | event.he_somecounter = (uint32_t)get_cyclecount(); | ||||
event.he_size = count; | event.he_size = count; | ||||
event.he_bits = count/4; /* Underestimate the size for Yarrow */ | event.he_bits = count/4; /* Underestimate the size for Yarrow */ | ||||
▲ Show 20 Lines • Show All 121 Lines • Show Last 20 Lines |
the name _ENTROPY_FILE is misnamed and should be named _ENTROPY_MODULE as this is the name of the module, not a name of a file.