handle an error case
authorRudolf Polzer <divverent@alientrap.org>
Thu, 5 Aug 2010 07:51:07 +0000 (09:51 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Thu, 5 Aug 2010 07:51:07 +0000 (09:51 +0200)
d0_bignum-gmp.c

index 5f0babc..4e8a11b 100644 (file)
@@ -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");