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.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/crypto/random.c b/src/crypto/random.c
index 691c31f62..14a028fc9 100644
--- a/src/crypto/random.c
+++ b/src/crypto/random.c
@@ -45,7 +45,11 @@ static void generate_system_random_bytes(size_t n, void *result);
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));