1.5 KiB
1.5 KiB
ADR-0046: Explicitly granted random.bytes
Status: Accepted
Date: 2026-11-21
Relates to: ADR-0041
Specs: spec/security.md, spec/evaluation.md
Evidence: docs/evidence/2026-11-21-random-product.md
Context
The standard library had no product entropy API. Reading /dev/urandom or
using an OS RNG inside a Rust builtin would create an unaudited side channel
and would make pure mode non-deterministic without an explicit grant.
Decision
Add one project-mode operation:
resource.request("random.bytes", [count]) -> {ok:true, value:List<Int>}
countis anIntin1..=65536; other values are fatal type errors.- A new
Capabilities::random: boolgrant is required (--allow-random). Un-granted calls arepermission.denied;pure/strictrefuse. - Bytes come from the
getrandomcrate's OS entropy source; a source failure is a fatalhost.error. - The operation returns a
List<Int>of 0–255 values. It does not expose aMemoryhandle or raw pointer. stdlib/random.mq.mdexposes字节(n)and整数(上限).整数combines eight bytes and takes a modulus; it is not claimed to be unbiased rejection sampling.- No new builtin or
HostOpis added.
Consequences
- Entropy is opt-in per run and unavailable in pure/strict.
- The API is byte-list based, so callers can build their own distributions in
.mq.md; a cryptographically audited RNG API is out of scope. - A future unbiased integer helper or secure token API needs its own ADR.