selfrando icon indicating copy to clipboard operation
selfrando copied to clipboard

Seed the ChaCha20 RNG using the Windows kernel RNG

Open ahomescu opened this issue 7 years ago • 1 comments

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.

ahomescu avatar Jun 05 '17 20:06 ahomescu

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.

JackTrapper avatar Apr 20 '21 16:04 JackTrapper