aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2012-10-11 14:30:23 +0300
committerMartin Storsjö <martin@martin.st>2012-10-11 18:49:34 +0300
commit1093383d6cf7112d54b849e29c739e957d157b25 (patch)
tree9a96c38da6489a1978af4216822f84d4fc1fcd43 /libavutil
parent26b3fde6a78f711ba510573eacbc92671a923b2d (diff)
downloadffmpeg-1093383d6cf7112d54b849e29c739e957d157b25.tar.gz
random_seed: Support using CryptGenRandom on windows
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/random_seed.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c
index 8ee4cb716e..ec9caa74b7 100644
--- a/libavutil/random_seed.c
+++ b/libavutil/random_seed.c
@@ -23,6 +23,10 @@
#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>
@@ -82,6 +86,17 @@ 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))