From b016b8bd800cd6171366317e3a3db7a6d5b80243 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Thu, 5 Aug 2010 09:51:07 +0200 Subject: [PATCH] handle an error case --- d0_bignum-gmp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/d0_bignum-gmp.c b/d0_bignum-gmp.c index 5f0babc..4e8a11b 100644 --- a/d0_bignum-gmp.c +++ b/d0_bignum-gmp.c @@ -54,9 +54,18 @@ void d0_bignum_INITIALIZE(void) { if(!CryptGenRandom(hCryptProv, sizeof(buf), (PBYTE) &buf[0])) fprintf(stderr, "WARNING: could not initialize random number generator (CryptGenRandom failed)\n"); + CryptReleaseContext(hCryptProv, 0); } else + { + if(CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_NEWKEYSET)) + { + if(!CryptGenRandom(hCryptProv, sizeof(buf), (PBYTE) &buf[0])) + fprintf(stderr, "WARNING: could not initialize random number generator (CryptGenRandom failed)\n"); + CryptReleaseContext(hCryptProv, 0); + } fprintf(stderr, "WARNING: could not initialize random number generator (CryptAcquireContext failed)\n"); + } } #else f = fopen("/dev/urandom", "rb"); -- 2.39.2