Skip to main content

Module entropy

Module entropy 

Source
Expand description

Kernel entropy pool : a cryptographically sound random bytes from interrupt noise.

Collects entropy from:

  • keyboard IRQ timing + scancode data
  • timer tick jitter (low bits of TSC)
  • storage (AHCI) IRQ timing
  • RDRAND when available (as seed material)

The pool uses a tweaked Threefish-like mixing over 128 bytes (4×4 u64s) for efficient diffusion. Output is extracted by hashing the pool state through a compression round : no built-in hash dependency needed.

Constants§

ENTROPY_HIGH_WATER 🔒
Entropy threshold in bytes before we consider the pool “initialised”.
POOL_WORDS 🔒
Number of 64-bit words in the entropy pool (16 = 128 bytes).

Statics§

ENTROPY_CTR 🔒
Estimated entropy count (in bytes). Saturates at POOL_WORDS * 8.
POOL 🔒
The entropy pool : a 128‑byte array of 16 u64s.
POOL_IDX 🔒
Index where the next sample will be mixed in.

Functions§

add_entropy
Feed a 64‑bit sample into the entropy pool (called from interrupt handlers).
extract_block 🔒
Extract 8 bytes from the pool by folding all words together.
fill_random
Fill a byte buffer with random bytes from the entropy pool.
is_ready
Check whether the entropy pool has accumulated enough entropy (at least ENTROPY_HIGH_WATER bytes). Used by GRND_NONBLOCK.
rdrand64 🔒
BUG TODO : RDRAND helper (used during boot seeding).
seed_from_rdrand
One-time boot‑time seed of the pool from RDRAND (if available).
twist 🔒
Non‑linear twist: multiplicative inverse in GF(2⁶⁴) masked by a prime, then XORed with a rotation of itself.