Merge branch 'win_vlc_rand' into 'master'

Simplify vlc_rand_bytes on Windows

See merge request videolan/vlc!5366
This commit is contained in:
Steve Lhomme 2024-05-08 16:39:23 +00:00
commit 76a5bf2177
1 changed files with 4 additions and 8 deletions

View File

@ -27,15 +27,11 @@
#include <windows.h>
#include <bcrypt.h>
#include <assert.h>
void vlc_rand_bytes (void *buf, size_t len)
{
BCRYPT_ALG_HANDLE algo_handle;
NTSTATUS ret = BCryptOpenAlgorithmProvider(&algo_handle, BCRYPT_RNG_ALGORITHM,
MS_PRIMITIVE_PROVIDER, 0);
if (BCRYPT_SUCCESS(ret))
{
BCryptGenRandom(algo_handle, buf, len, 0);
BCryptCloseAlgorithmProvider(algo_handle, 0);
}
NTSTATUS ret;
ret = BCryptGenRandom(0, buf, len, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
assert(BCRYPT_SUCCESS(ret));
}