[vlc-commits] [Git][videolan/vlc][master] contrib: rist: use BCryptGenRandom() on Windows to generate random numbers
François Cartegnie (@fcartegnie)
gitlab at videolan.org
Mon Sep 28 06:54:07 UTC 2026
François Cartegnie pushed to branch master at VideoLAN / VLC
Commits:
55236e65 by Steve Lhomme at 2026-09-28T08:20:07+02:00
contrib: rist: use BCryptGenRandom() on Windows to generate random numbers
No need to pull the whole gnutls just for that.
BCryptGenRandom() is available since Vista which is also the minimum supported
but librist.
- - - - -
2 changed files:
- + contrib/src/librist/0001-crypto-use-bcrypt-on-Windows-to-generate-random-numb.patch
- contrib/src/librist/rules.mak
Changes:
=====================================
contrib/src/librist/0001-crypto-use-bcrypt-on-Windows-to-generate-random-numb.patch
=====================================
@@ -0,0 +1,41 @@
+From e21451f5b5053045e129aba2018ec0e05bfb9c33 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Thu, 24 Sep 2026 13:34:33 +0200
+Subject: [PATCH] crypto: use bcrypt on Windows to generate random numbers
+
+No need to link the whole gnutls with it.
+---
+ src/crypto/random.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/src/crypto/random.c b/src/crypto/random.c
+index e964fbb..fbd5e34 100644
+--- a/src/crypto/random.c
++++ b/src/crypto/random.c
+@@ -98,6 +98,12 @@ static void _librist_crypto_random_init(void) {
+ #endif
+ }
+
++#elif defined(_WIN32)
++#include <windows.h>
++#include <bcrypt.h>
++static void _librist_crypto_random_init(void) {
++ return;
++}
+ #elif HAVE_NETTLE
+ #include <gnutls/crypto.h>
+ static void _librist_crypto_random_init(void) {
+@@ -113,6 +119,10 @@ int _librist_crypto_ramdom_get_bytes(uint8_t buf[], size_t buflen) {
+ if (ctr_drbg_seed_ret != 0)
+ return ctr_drbg_seed_ret;
+ ret = mbedtls_ctr_drbg_random(&ctr_drbg_ctx, buf, buflen);
++#elif defined(_WIN32)
++ NTSTATUS nret;
++ nret = BCryptGenRandom(0, buf, buflen, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
++ ret = BCRYPT_SUCCESS(ret) ? 0 : -1;
+ #elif HAVE_NETTLE
+ int i=0;
+ do {
+--
+2.52.0.windows.1
+
=====================================
contrib/src/librist/rules.mak
=====================================
@@ -47,6 +47,7 @@ $(TARBALLS)/librist-$(LIBRIST_VERSION).tar.gz:
librist: librist-$(LIBRIST_VERSION).tar.gz .sum-librist
$(UNPACK)
+ $(APPLY) $(SRC)/librist/0001-crypto-use-bcrypt-on-Windows-to-generate-random-numb.patch
$(MOVE)
.librist: librist crossfile.meson
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/55236e656987ea1b2a7dfe14ffe6b42d371abaef
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/55236e656987ea1b2a7dfe14ffe6b42d371abaef
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list