Skip to content

soc: apple: sep: credit the enclave RNG at 900, as a policy - #2996

Draft
Alyx-ML wants to merge 1 commit into
aurora-silicon:mainfrom
Alyx-ML:aurora/sep-hwrng-quality
Draft

Alyx-ML wants to merge 1 commit into
aurora-silicon:mainfrom
Alyx-ML:aurora/sep-hwrng-quality

Conversation

@Alyx-ML

@Alyx-ML Alyx-ML commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Part of the #2755 split. Draft until it has a run on a Mac (the last Evidence line says which). RyanTheTide asked for this to be separate and stated as policy.

Summary

-pub(crate) const QUALITY: c_ushort = 1024;   # every bit counted as fully random
+pub(crate) const QUALITY: c_ushort = 900;    # no public analysis of the source: less than full credit

This is a policy choice, not a fix for a known weakness. 900 is what omap-rng, stm32-rng, mtk-rng
and others declare under the same policy. rng_quality in sysfs can set it back to 1024. If you
would rather trust the SEP by default, close this; nothing depends on it.

Evidence

  • Checked in drivers/char/hw_random/core.c: quality is clamped at registration and scales the
    credit in hwrng_fillfn(). Build: passed, Apple build and KUnit, SEP source checks.
  • Needed before merging: a boot on a Mac, where rng_quality in sysfs reads 900.

Merge Danger

Door: two-way

Blast Radius: entropy accounting

The core picks the source with the highest quality, so another source declaring more than 900
would now be chosen over the SEP.

The SEP hwrng registers with quality 1024. That tells the hwrng core
that every bit read is fully random, so the core credits all of it to
the kernel's entropy pool.

This change is a policy choice, not a fix for a known weakness. Nothing
shows that the enclave's output is weaker than 1024 claims. Nothing
public shows that it is as strong either: there is no analysis of its
noise source, or of how its firmware conditions the output before it
reaches the mailbox. The policy proposed here is that a source with no
such analysis does not get full credit by default. 900 is the value
most SoC TRNG drivers declare under that policy, without a measurement
of their own (omap-rng, stm32-rng, mtk-rng and others).

What changes: the pool is credited 900/1024 of the bits the SEP gives.
The device still feeds the pool at the same rate, and is still chosen
as the current hwrng when it is the only one. An administrator who
trusts the source can set rng_quality back to 1024 through sysfs. If
the maintainers prefer to trust the SEP by default, this patch can be
dropped; nothing else depends on it.

Checked by reading drivers/char/hw_random/core.c: quality is clamped to
min(default_quality, 1024, quality) at registration and scales the
credit in hwrng_fillfn(). The kernel Rust code was not compiled here.

Signed-off-by: Alyx-ML <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor

@Alyx-ML checking open drafts today. To come out of draft, this still needs:

  • A test run at the current head on a Mac with the hardware it touches, then mark it ready for review.

If it's no longer needed, say so here and we'll close it. Otherwise it stays open as a draft until these are done.

@Alyx-ML

Alyx-ML commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for checking. This is still needed, and it merges cleanly with main. It stays a draft
until someone with a Mac runs the test under "Needed before merging" in the description.

Assisted-by: LLM (Claude:Opus 5.5)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants