mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-08 06:09:50 +00:00
avutil/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. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
a56580b117
commit
aedbf1640c
2 changed files with 13 additions and 12 deletions
|
|
@ -26,9 +26,9 @@
|
|||
#if HAVE_IO_H
|
||||
#include <io.h>
|
||||
#endif
|
||||
#if HAVE_WINCRYPT
|
||||
#if HAVE_BCRYPT
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
#include <bcrypt.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
|
|
@ -121,13 +121,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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue