Q258000 workaround, like crypto++
This commit is contained in:
@@ -99,18 +99,22 @@ static unsigned long rng_ansic(unsigned char *buf, unsigned long len,
|
|||||||
static unsigned long rng_win32(unsigned char *buf, unsigned long len,
|
static unsigned long rng_win32(unsigned char *buf, unsigned long len,
|
||||||
void (*callback)(void))
|
void (*callback)(void))
|
||||||
{
|
{
|
||||||
HCRYPTPROV hProv = 0;
|
// work around Q258000
|
||||||
if (!CryptAcquireContext(&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL,
|
static HCRYPTPROV hProv = 0;
|
||||||
(CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET)) &&
|
if (!hProv)
|
||||||
!CryptAcquireContext (&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL,
|
{
|
||||||
CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET | CRYPT_NEWKEYSET))
|
if (!CryptAcquireContext(&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL,
|
||||||
return 0;
|
(CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET)) &&
|
||||||
|
!CryptAcquireContext (&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL,
|
||||||
|
CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET | CRYPT_NEWKEYSET))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (CryptGenRandom(hProv, len, buf) == TRUE) {
|
if (CryptGenRandom(hProv, len, buf) == TRUE) {
|
||||||
CryptReleaseContext(hProv, 0);
|
// CryptReleaseContext(hProv, 0);
|
||||||
return len;
|
return len;
|
||||||
} else {
|
} else {
|
||||||
CryptReleaseContext(hProv, 0);
|
// CryptReleaseContext(hProv, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user