std.internal.entropy

Types 5

A CSPRNG suitable to retrieve cryptographically-secure random data from.

(No actual low-level entropy sources are provided on purpose.)

tryAll = - 1Implements a hunting strategy for finding an entropy source that is available at runtime.
none = 0Always fail.
charDevURandom = 1`/dev/urandom`
charDevRandom = 2`/dev/random`
getrandom = 3`getrandom` syscall or wrapper
arc4random = 4`arc4random`
getentropy = 5
cryptGenRandom = 6Windows legacy CryptoAPI
bcryptGenRandom = 7Windows Cryptography API: Next Generation (“BCrypt”)
ok = 0success
unknownError = 1catch-all error
unavailableAn entropy source was unavailable.
unavailableLibraryA dependency providing the entropy source turned out unavailable.
unavailablePlatformThe requested entropy source is not supported on this platform.
readErrorCould not retrieve entropy from the selected source.

Status report returned by getEntropy functions.

Use the isOK helper function to test for success.

Fields
Methods
string toString() const @nogc nothrow pure @safeReturns: A human-readable status message.
private structVoidChunks

A “Chunks” implementation that works with void[].

Fields
void[] _data
size_t _chunkSize
Methods
bool empty() @nogc nothrow pure @safe const
inout(void)[] front() @nogc nothrow pure @safe inout
void popFront() @nogc nothrow pure @safe
Constructors
this(void[] data, size_t chunkSize)
private structSrcFunPair(EntropySource source, alias func)
Fields
src

Functions 9

fnEntropyResult getEntropy(scope void[] buffer) @nogc nothrow @safeRetrieves random data from an applicable system CSPRNG.
fnEntropyResult getEntropy(scope ubyte[] buffer) @nogc nothrow @safeditto
fnEntropyResult getEntropy(scope void * buffer, size_t length) @nogc nothrow @systemditto Retrieves random data from an applicable system CSPRNG.
fnvoid forceEntropySource(EntropySource source) @nogc nothrow @safeManually set the entropy source to use for the current thread.
fnEntropyResult getEntropy(scope void * buffer, size_t length, EntropySource source) @nogc nothrow @systemRetrieves random data from the requested entropy source.
fnbool isOK(const EntropyResult value) @nogc nothrow pure @safeDetermines whether an `EntropyResult` reports the success of an operation.
fnbool isUnavailable(const EntropyResult value) @nogc nothrow pure @safeDetermines whether an `EntropyResult` reports the unvailability of the requested entropy source.
fnvoid crashOnError(const EntropyResult value) @nogc nothrow pure @safe
private fnvoid saveSourceForNextUse(const EntropyResult result) @nogc nothrow @safe

Variables 1

private varEntropySource _entropySource = defaultEntropySource

Templates 1

tmplisValidSupportedSource(SupportedSource)