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
F132003462: D52232.diff
Sun, Oct 12, 9:04 PM
Unknown Object (File)
Fri, Oct 3, 6:14 PM
Unknown Object (File)
Thu, Oct 2, 3:41 PM
Unknown Object (File)
Wed, Oct 1, 6:57 AM
Unknown Object (File)
Mon, Sep 29, 3:08 PM
Unknown Object (File)
Sun, Sep 28, 2:17 PM
Unknown Object (File)
Sat, Sep 27, 5:36 PM
Unknown Object (File)
Fri, Sep 26, 1:54 PM
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 Not Applicable
Unit
Tests Not Applicable

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.