Fixed Windows Crypto API rand call on uninitialized machines. (#10)

* Modified CAPI call to avoid error when no key container is present for the user.
This commit is contained in:
Christian Paquin 2016-09-29 10:51:59 -04:00 committed by Douglas Stebila
parent 5521fe8c8d
commit 8b7139a20b

View File

@ -65,8 +65,8 @@ static OQS_RAND_urandom_chacha20_ctx *OQS_RAND_urandom_chacha20_ctx_new() {
goto err;
}
#if defined(WINDOWS)
if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0) ||
!CryptGenRandom(hCryptProv, 32, rand_ctx->key)) {
if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) ||
!CryptGenRandom(hCryptProv, 32, rand_ctx->key)) {
goto err;
}
#else