aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/random.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/random.c')
-rw-r--r--src/crypto/random.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/crypto/random.c b/src/crypto/random.c
index cd46a1362..9e1a70a2d 100644
--- a/src/crypto/random.c
+++ b/src/crypto/random.c
@@ -42,10 +42,15 @@ static void generate_system_random_bytes(size_t n, void *result);
#include <windows.h>
#include <wincrypt.h>
+#include <stdio.h>
static void generate_system_random_bytes(size_t n, void *result) {
HCRYPTPROV prov;
+#ifdef NDEBUG
+#define must_succeed(x) do if (!(x)) { fprintf(stderr, "Failed: " #x); _exit(1); } while (0)
+#else
#define must_succeed(x) do if (!(x)) abort(); while (0)
+#endif
must_succeed(CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT));
must_succeed(CryptGenRandom(prov, (DWORD)n, result));
must_succeed(CryptReleaseContext(prov, 0));