RANDOM_HARVEST(9)

✨ RANDOM_HARVEST(9) ✨

okay bestie, welcome to the Kernel Developer's Manual entry for random_harvest β€” it's giving "gather entropy from the kernel for the entropy device" and honestly? iconic. πŸŽ€


πŸ’– NAME πŸ’–

random_harvest β€” gather entropy from the kernel for the entropy device 🧚


🌸 SYNOPSIS 🌸

#include <sys/types.h>
#include <sys/random.h>

void
random_harvest_direct(void *entropy, u_int size, enum esource source);

void
random_harvest_fast(void *entropy, u_int size, enum esource source);

void
random_harvest_queue(void *entropy, u_int size, enum esource source);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the random_harvest_*() functions are the ones device drivers and other kernel processes use to hand over data that counts as (at least partially) stochastic to the entropy device. like, they're the little delivery girlies feeding the vibes in. πŸ’…

the caller should pass a pointer pointing to the "random" data in entropy. the argument size contains the number of bytes pointed to. and source gets picked from one of the values enumerated in sys/dev/random.h, and it's used to indicate where the entropy came from. 🫢

  • random_harvest_direct() β€” this variant is for early harvesting, before any multitasking is enabled. no multitasking, no problem. ✨
  • random_harvest_fast() β€” this one is for sources that should not take a performance hit from harvesting, because they're high-rate sources. some entropy is sacrificed, but the high rate of supply will compensate for that. trade-off queen behavior, honestly. πŸ’€
  • random_harvest_queue() β€” this is for general harvesting, and it's the default choice for most entropy sources such as interrupts or console events. the main character of harvest variants, no cap. πŸ‘‘

interrupt harvesting has been in part simplified for the kernel programmer. so here's the tea: if a device driver registers an interrupt handler with BUS_SETUP_INTR(9) or bus_setup_intr(9), then it is only necessary to include the INTR_ENTROPY bit in the flags argument to have that interrupt source be used for entropy harvesting. and bestie, this should be done wherever practicable. periodt. 🌈


πŸ”₯ SEE ALSO πŸ”₯


πŸ‘‘ AUTHORS πŸ‘‘

the FreeBSD random(4) entropy device and supporting documentation was written by Mark R V Murray. we stan. 🫢


mwah πŸ’– that's the whole page, bestie β€” from the Debian folks, dated August 26, 2018, on the RANDOM_HARVEST(9) tip. go harvest some entropy, you got this. πŸŽ€βœ¨

πŸ“¦ where this page comes from