RANDOM_HARVEST(9)
π RANDOM_HARVEST(9) β gather entropy from the kernel for the entropy device π
okay bestie, welcome to this little Kernel Developerβs Manual moment π
. This is the random_harvest(9) page, and itβs all about feeding βrandom-ishβ data from kernel land into the entropy device. iconic behavior, honestly β¨
πΈ 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 β¨
The random_harvest_*() functions are used by device drivers and other kernel processes to pass data that is considered (at least partially) stochastic to the entropy device. No cap, thatβs the whole vibe π«Ά
The caller should pass a pointer pointing to the βrandomβ data in entropy. The argument size contains the number of bytes pointed to. The source is chosen from one of the values enumerated in sys/dev/random.h and is used to indicate the source of the entropy β¨
Hereβs the variant breakdown, bestie:
random_harvest_direct()β used for early harvesting before any multitasking is enabled πrandom_harvest_fast()β used by 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 this πrandom_harvest_queue()β used for general harvesting and is the default choice for most entropy sources, such as interrupts or console events π
Interrupt harvesting has been in part simplified for the kernel programmer π§ 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. This should be done wherever practicable π
lowkey the INTR_ENTROPY bit is the little shortcut here β iykyk β¨
π¦ SEE ALSO π¦
π AUTHORS π
The FreeBSD random(4) entropy device and supporting documentation was written by Mark R V Murray π
mwah π β this cute little rewrite is from the Debian copy of the page, dated August 26, 2018. periodt π«Άβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2002-2015 Mark R V Murray
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms