summaryrefslogtreecommitdiff
path: root/libavutil/random_seed.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-12 14:15:33 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-10-12 14:15:33 +0200
commit43cce41267a7aa71946911e87b4dfce48183bb25 (patch)
tree65005ccffc4a671a46163fc3e47b5f1c40b9e12d /libavutil/random_seed.c
parentcaa7e24eb1d47a0dfeb9783909bce7df6d3f5482 (diff)
parent0a75d1da23b8659ec49391469bb592da12760077 (diff)
downloadffmpeg-43cce41267a7aa71946911e87b4dfce48183bb25.tar.gz
Merge commit '0a75d1da23b8659ec49391469bb592da12760077'
* commit '0a75d1da23b8659ec49391469bb592da12760077': options_table: refs option is not snow-only random_seed: Support using CryptGenRandom on windows doc: update the faq entry about custom I/O Conflicts: doc/faq.texi libavcodec/options_table.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/random_seed.c')
-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 49c122001a..c674704615 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>
@@ -102,6 +106,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))