Page MenuHomeFreeBSD

random: Allow pure entropy sources to provide a min-entropy estimate
ClosedPublic

Authored by markj on Aug 28 2025, 9:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jan 12, 11:51 PM
Unknown Object (File)
Sat, Jan 10, 6:49 AM
Unknown Object (File)
Wed, Dec 17, 10:01 AM
Unknown Object (File)
Dec 4 2025, 9:12 PM
Unknown Object (File)
Nov 28 2025, 7:20 AM
Unknown Object (File)
Oct 26 2025, 7:23 AM
Unknown Object (File)
Oct 13 2025, 9:29 AM
Unknown Object (File)
Oct 13 2025, 9:29 AM
Subscribers

Details

Summary

The current implementation of the NIST health tests assumes a
min-entropy estimate of one bit per sample, which is quite conservative.
For so-called "pure" sources (e.g., virtio-random, TPM) it might be nice
to support larger estimates so that the tests catch failed devices more
quickly.

Thus:

  • let each pure random source provide an estimate, so that downstreams can override defaults if they want to;
  • increase the default estimate for pure sources;
  • for pure sources initialize the state machine at source registration time.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 66623
Build 63506: arc lint + arc unit

Event Timeline

markj requested review of this revision.Aug 28 2025, 9:48 PM
cem added a subscriber: cem.

8 bits per byte might be high for some sources... I'm not sure. It's probably fine for the relatively simplistic tests in the health test?

sys/dev/random/randomdev.h
106

This might also be interesting to Fortuna/etc for boot time min entropy estimation / initial seeding.

This revision is now accepted and ready to land.Aug 29 2025, 1:39 AM
In D52232#1193086, @cem wrote:

8 bits per byte might be high for some sources... I'm not sure. It's probably fine for the relatively simplistic tests in the health test?

Well, 8 bits per sample, but yes this might turn out to be excessive. Perhaps I should include a tunable to override that value.

Well, 8 bits per sample, but yes this might turn out to be excessive. Perhaps I should include a tunable to override that value.

I guess I wouldn't expect any source to provide only one byte per sample, so that's only ~2 bits per byte at word-size input, which is not super high.

In D52232#1193347, @cem wrote:

Well, 8 bits per sample, but yes this might turn out to be excessive. Perhaps I should include a tunable to override that value.

I guess I wouldn't expect any source to provide only one byte per sample, so that's only ~2 bits per byte at word-size input, which is not super high.

Yeah, I'm not aware of any devices that provide only the bare minimum, but since the API permits it I still need to be conservative.