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.

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

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

Functions 9

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

Variables 1

varEntropySource _entropySource

Templates 1

tmplisValidSupportedSource(SupportedSource)