1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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>
This commit is contained in:
Steve Lhomme 2018-04-03 11:44:25 +02:00 committed by Martin Storsjö
parent 347aa8f723
commit abf806f7f1
2 changed files with 14 additions and 12 deletions

7
configure vendored
View File

@ -1703,12 +1703,12 @@ SYSTEM_FUNCS="
" "
SYSTEM_LIBRARIES=" SYSTEM_LIBRARIES="
bcrypt
sdl sdl
vaapi_1 vaapi_1
vaapi_drm vaapi_drm
vaapi_x11 vaapi_x11
vdpau_x11 vdpau_x11
wincrypt
" "
TOOLCHAIN_FEATURES=" TOOLCHAIN_FEATURES="
@ -2610,7 +2610,7 @@ avdevice_extralibs="libm_extralibs"
avformat_extralibs="libm_extralibs" avformat_extralibs="libm_extralibs"
avfilter_extralibs="pthreads_extralibs libm_extralibs" avfilter_extralibs="pthreads_extralibs libm_extralibs"
avresample_extralibs="libm_extralibs" avresample_extralibs="libm_extralibs"
avutil_extralibs="clock_gettime_extralibs cuda_extralibs cuvid_extralibs d3d11va_extralibs libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs wincrypt_extralibs" avutil_extralibs="bcrypt_extralibs clock_gettime_extralibs cuda_extralibs cuvid_extralibs d3d11va_extralibs libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs"
swscale_extralibs="libm_extralibs" swscale_extralibs="libm_extralibs"
# programs # programs
@ -4579,9 +4579,10 @@ check_header windows.h
# so we also check that atomics actually work here # so we also check that atomics actually work here
check_builtin stdatomic stdatomic.h "atomic_int foo; atomic_store(&foo, 0)" check_builtin stdatomic stdatomic.h "atomic_int foo; atomic_store(&foo, 0)"
check_lib bcrypt "windows.h bcrypt.h" BCryptGenRandom -lbcrypt &&
check_cpp_condition bcrypt bcrypt.h "defined BCRYPT_RNG_ALGORITHM"
check_lib ole32 "windows.h" CoTaskMemFree -lole32 check_lib ole32 "windows.h" CoTaskMemFree -lole32
check_lib shell32 "windows.h shellapi.h" CommandLineToArgvW -lshell32 check_lib shell32 "windows.h shellapi.h" CommandLineToArgvW -lshell32
check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom -ladvapi32
check_lib psapi "windows.h psapi.h" GetProcessMemoryInfo -lpsapi check_lib psapi "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss

View File

@ -23,9 +23,9 @@
#if HAVE_UNISTD_H #if HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#if HAVE_WINCRYPT #if HAVE_BCRYPT
#include <windows.h> #include <windows.h>
#include <wincrypt.h> #include <bcrypt.h>
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#include <math.h> #include <math.h>
@ -96,13 +96,14 @@ uint32_t av_get_random_seed(void)
{ {
uint32_t seed; uint32_t seed;
#if HAVE_WINCRYPT #if HAVE_BCRYPT
HCRYPTPROV provider; BCRYPT_ALG_HANDLE algo_handle;
if (CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL, NTSTATUS ret = BCryptOpenAlgorithmProvider(&algo_handle, BCRYPT_RNG_ALGORITHM,
CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { MS_PRIMITIVE_PROVIDER, 0);
BOOL ret = CryptGenRandom(provider, sizeof(seed), (PBYTE) &seed); if (BCRYPT_SUCCESS(ret)) {
CryptReleaseContext(provider, 0); NTSTATUS ret = BCryptGenRandom(algo_handle, (UCHAR*)&seed, sizeof(seed), 0);
if (ret) BCryptCloseAlgorithmProvider(algo_handle, 0);
if (BCRYPT_SUCCESS(ret))
return seed; return seed;
} }
#endif #endif