selfrando
selfrando copied to clipboard
Seed the ChaCha20 RNG using the Windows kernel RNG
Recent Windows versions provide an undocumented kernel random number source at \Device\CNG
(which works similarly to Linux's /dev/urandom
). We can read random bytes from this device using the 0x390008
ioctl code. We should use this source to seed our own ChaCha20 RNG.
I would suggest instead you use the documented way to access the cryptographic random data provided by the operating system: BCryptGenRandom.
If you need to run pre-Windows Vista, you can use CryptGenRandom.
That way you're not using the undocumented way.