diff mbox series

[FFmpeg-devel] avutil/random_seed: add support for GnuTLS as source of randomness

Message ID 20230706183452.1697-1-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel] avutil/random_seed: add support for GnuTLS as source of randomness | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

James Almer July 6, 2023, 6:34 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 configure               | 2 +-
 libavutil/random_seed.c | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/configure b/configure
index d6e78297fe..56e2b85f97 100755
--- a/configure
+++ b/configure
@@ -3892,7 +3892,7 @@  avfilter_deps="avutil"
 avfilter_suggest="libm stdatomic"
 avformat_deps="avcodec avutil"
 avformat_suggest="libm network zlib stdatomic"
-avutil_suggest="clock_gettime ffnvcodec gcrypt libm libdrm libmfx opencl openssl user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia bcrypt stdatomic"
+avutil_suggest="clock_gettime ffnvcodec gcrypt gnutls libm libdrm libmfx opencl openssl user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia bcrypt stdatomic"
 postproc_deps="avutil gpl"
 postproc_suggest="libm stdatomic"
 swresample_deps="avutil"
diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c
index 2980e565e0..e02431898e 100644
--- a/libavutil/random_seed.c
+++ b/libavutil/random_seed.c
@@ -34,6 +34,8 @@ 
 #include <gcrypt.h>
 #elif CONFIG_OPENSSL
 #include <openssl/rand.h>
+#elif CONFIG_GNUTLS
+#include <gnutls/crypto.h>
 #endif
 #include <fcntl.h>
 #include <math.h>
@@ -158,6 +160,10 @@  int av_random_bytes(uint8_t* buf, size_t len)
     if (RAND_bytes(buf, len) == 1)
         return 0;
     err = AVERROR_EXTERNAL;
+#elif CONFIG_GNUTLS
+    err = gnutls_rnd(GNUTLS_RND_KEY, buf, len);
+    if (!err)
+        return 0;
 #endif
 
     return err;