aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/random.c
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-02-16 14:20:31 +0100
committerRiccardo Spagni <ric@spagni.net>2018-02-16 14:20:31 +0100
commit666a76652bcc82c5f85e1a658eab83b27e9e78a4 (patch)
tree7ef0770f47b0c4a691b4cbe2d9849ecbc8fa202c /src/crypto/random.c
parentMerge pull request #3184 (diff)
parentcall _exit instead of abort in release mode (diff)
downloadmonero-666a76652bcc82c5f85e1a658eab83b27e9e78a4.tar.xz
Merge pull request #3187
851bd057 call _exit instead of abort in release mode (moneromooo-monero)
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 cd46a1362..929377943 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));