#if HAVE_UNISTD_H
#include <unistd.h>
#endif
+#if HAVE_CRYPTGENRANDOM
+#include <windows.h>
+#include <wincrypt.h>
+#endif
#include <fcntl.h>
#include <math.h>
#include <time.h>
clock_t last_t = 0;
static uint64_t i = 0;
static uint32_t buffer[512] = {0};
- unsigned char digest[32];
+ unsigned char digest[20];
uint64_t last_i = i;
av_assert0(sizeof(tmp) >= av_sha_size);
av_sha_init(sha, 160);
av_sha_update(sha, (uint8_t*)buffer, sizeof(buffer));
av_sha_final(sha, digest);
- return AV_RB32(digest) + AV_RB32(digest+32);
+ return AV_RB32(digest) + AV_RB32(digest+16);
}
uint32_t av_get_random_seed(void)
{
uint32_t seed;
+#if HAVE_CRYPTGENRANDOM
+ HCRYPTPROV provider;
+ if (CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL,
+ CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
+ BOOL ret = CryptGenRandom(provider, sizeof(seed), (PBYTE) &seed);
+ CryptReleaseContext(provider, 0);
+ if (ret)
+ return seed;
+ }
+#endif
+
if (read_random(&seed, "/dev/urandom") == sizeof(seed))
return seed;
if (read_random(&seed, "/dev/random") == sizeof(seed))