SystemEntropyStream

Reads any desired amount of random entropy from a system-specific cryptographic random number generator. On Windows, this loads ADVAPI32.DLL and uses RtlGenRandom. On Posix, this uses '/dev/random'.

Optionally, you can use open() and close() to control the lifetime of SystemEntropyStream's system handles (ie, loading/uloading ADVAPI32.DLL and opening/closing '/dev/random'). But this is not normally necessary since SystemEntropyStream automatically opens them upon reading and closes upon module destruction.

The speed and cryptographic security of this is dependent on your operating system. This may be perfectly suitable for many cryptographic-grade random number generation needs, but it's primary inteded for seeding/reseeding cryptographic psuedo-random number generators, such as Hash_DRBG or HMAC_DRBG, which are likely to be faster and no less secure than using an entropy source directly.

Members

Manifest constants

isUniformRandomStream
enum isUniformRandomStream;

Mark this as a Rng Stream

Properties

isOpen
bool isOpen [@property getter]

Check whether SystemEntropyStream is currently connected to with the system-specific entropy generator.

Static functions

close
void close()

Manually release the handle/connection to the system-specific entropy generator.

open
void open()

Establishes a handle/connection to the system-specific entropy generator. Does nothing if already open.

read
void read(ubyte[] buf)

Fills the buffer with entropy from the system-specific entropy generator. Automatically opens SystemEntropyStream if it's closed.

Meta