#include "random.h"
-static pa_bool_t has_whined = FALSE;
+static bool has_whined = false;
static const char * const devices[] = { "/dev/urandom", "/dev/random", NULL };
#ifdef OS_IS_WIN32
int ret = -1;
+ HCRYPTPROV hCryptProv = 0;
+
pa_assert(ret_data);
pa_assert(length > 0);
- HCRYPTPROV hCryptProv = NULL;
-
if (CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
- if(CryptGenRandom(hCryptProv, length, ret_data))
+ if (CryptGenRandom(hCryptProv, length, ret_data))
ret = 0;
CryptReleaseContext(hCryptProv, 0);
}
if (!has_whined) {
pa_log_warn("Failed to get proper entropy. Falling back to seeding with current time.");
- has_whined = TRUE;
+ has_whined = true;
}
seed = (unsigned int) time(NULL);
if (!has_whined) {
pa_log_warn("Failed to get proper entropy. Falling back to unsecure pseudo RNG.");
- has_whined = TRUE;
+ has_whined = true;
}
for (p = ret_data, l = length; l > 0; p++, l--)