summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorSteve Lhomme <robux4@ycbcr.xyz>2018-04-03 11:44:25 +0200
committerMartin Storsjö <martin@martin.st>2018-04-19 10:54:26 +0300
commitabf806f7f1601c7e54de7f863bbb816af144a88c (patch)
tree7b4e72aa0d802aef82c2bee2edb4acd487891f94 /libavutil
parent347aa8f72356124ec6b95bf8ebd1faf72db03f8d (diff)
random_seed: use bcrypt instead of the old wincrypt API
Remove the wincrypt API calls since we don't support XP anymore and bcrypt is available since Vista, even on Windows Store builds. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/random_seed.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c
index 089d883916..388cb401ba 100644
--- a/libavutil/random_seed.c
+++ b/libavutil/random_seed.c
@@ -23,9 +23,9 @@
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
-#if HAVE_WINCRYPT
+#if HAVE_BCRYPT
#include <windows.h>
-#include <wincrypt.h>
+#include <bcrypt.h>
#endif
#include <fcntl.h>
#include <math.h>
@@ -96,13 +96,14 @@ uint32_t av_get_random_seed(void)
{
uint32_t seed;
-#if HAVE_WINCRYPT
- 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)
+#if HAVE_BCRYPT
+ BCRYPT_ALG_HANDLE algo_handle;
+ NTSTATUS ret = BCryptOpenAlgorithmProvider(&algo_handle, BCRYPT_RNG_ALGORITHM,
+ MS_PRIMITIVE_PROVIDER, 0);
+ if (BCRYPT_SUCCESS(ret)) {
+ NTSTATUS ret = BCryptGenRandom(algo_handle, (UCHAR*)&seed, sizeof(seed), 0);
+ BCryptCloseAlgorithmProvider(algo_handle, 0);
+ if (BCRYPT_SUCCESS(ret))
return seed;
}
#endif