fillEntropy

fnEntropyStatus fillEntropy(scope ubyte[] buffer) @trusted nothrow @nogc

Fills the entire buffer with cryptographically secure random bytes.

Requests larger than the backend's count type are split, and Linux interruptions and short reads are retried. No bytes are retained after the call. The caller must provide exclusive access to the buffer while it is being filled. This function is not an async-signal-safe API.

Linux requires the libc getrandom binding and a kernel implementing getrandom(2) (3.17+); it may block during early boot until initialized. FreeBSD's arc4random_buf has no recoverable failure return.

Parameters

bufferwritable bytes to fill; empty (including null) is a no-op.

Returns

success only when every byte is filled, or an error. On error,

the buffer may be partially overwritten; discard its entire contents. Unsupported platforms return EntropyError.Code.UNSUPPORTED_PLATFORM for nonempty requests.