From 77c05fce0c9beded03ed92b6f3f28f8088052a3d Mon Sep 17 00:00:00 2001 From: Aaron Zauner Date: Wed, 15 Jun 2016 21:50:33 +0800 Subject: [PATCH] document why RtlGenRandom is used --- src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c b/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c index f9277ae5..5b000446 100644 --- a/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +++ b/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c @@ -25,6 +25,12 @@ #include "utils.h" #ifdef _WIN32 +/* `RtlGenRandom` is used over `CryptGenRandom` on Microsoft Windows based systems: + * - `CryptGenRandom` requires pulling in `CryptoAPI` which causes unnecessary + * memory overhead if no other Cryptography functionally is required. + * - `RtlGenRandom` is thus called directly instead. A detailed explaination + * can be found here: https://blogs.msdn.microsoft.com/michael_howard/2005/01/14/cryptographically-secure-random-number-on-windows-without-using-cryptoapi/ + */ # include # define RtlGenRandom SystemFunction036 # if defined(__cplusplus)