You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avutil/random_seed: add support for gcrypt and OpenSSL as source of randomness
Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
2
configure
vendored
2
configure
vendored
@@ -3892,7 +3892,7 @@ avfilter_deps="avutil"
|
|||||||
avfilter_suggest="libm stdatomic"
|
avfilter_suggest="libm stdatomic"
|
||||||
avformat_deps="avcodec avutil"
|
avformat_deps="avcodec avutil"
|
||||||
avformat_suggest="libm network zlib stdatomic"
|
avformat_suggest="libm network zlib stdatomic"
|
||||||
avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia bcrypt stdatomic"
|
avutil_suggest="clock_gettime ffnvcodec gcrypt libm libdrm libmfx opencl openssl user32 vaapi vulkan videotoolbox corefoundation corevideo coremedia bcrypt stdatomic"
|
||||||
postproc_deps="avutil gpl"
|
postproc_deps="avutil gpl"
|
||||||
postproc_suggest="libm stdatomic"
|
postproc_suggest="libm stdatomic"
|
||||||
swresample_deps="avutil"
|
swresample_deps="avutil"
|
||||||
|
@@ -30,6 +30,11 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <bcrypt.h>
|
#include <bcrypt.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if CONFIG_GCRYPT
|
||||||
|
#include <gcrypt.h>
|
||||||
|
#elif CONFIG_OPENSSL
|
||||||
|
#include <openssl/rand.h>
|
||||||
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@@ -143,6 +148,17 @@ int av_random_bytes(uint8_t* buf, size_t len)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
err = read_random(buf, len, "/dev/urandom");
|
err = read_random(buf, len, "/dev/urandom");
|
||||||
|
if (!err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
#if CONFIG_GCRYPT
|
||||||
|
gcry_randomize(buf, len, GCRY_VERY_STRONG_RANDOM);
|
||||||
|
return 0;
|
||||||
|
#elif CONFIG_OPENSSL
|
||||||
|
if (RAND_bytes(buf, len) == 1)
|
||||||
|
return 0;
|
||||||
|
err = AVERROR_EXTERNAL;
|
||||||
|
#endif
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user