aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>2012-08-16 22:27:15 +0200
committerMartin Storsjö <martin@martin.st>2012-08-17 23:51:53 +0300
commit8337b5db967ecadab4bb65c272cb47d350ecb83b (patch)
treeaa0f9c51f96baa4ceb30a00f3edffe1b049ac5a0 /libavformat
parenta2dd4f7780f5b968067d3db728ac64ae444eedab (diff)
downloadffmpeg-8337b5db967ecadab4bb65c272cb47d350ecb83b.tar.gz
rtmpdh: Do not generate the same private key every time when using libnettle
Replace mpz_random by mpz_urandomb with a random state initialization in order to improve the randomness. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/rtmpdh.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libavformat/rtmpdh.c b/libavformat/rtmpdh.c
index 92bce7a0bc..38c2f3df63 100644
--- a/libavformat/rtmpdh.c
+++ b/libavformat/rtmpdh.c
@@ -28,6 +28,7 @@
#include "config.h"
#include "rtmpdh.h"
+#include "libavutil/random_seed.h"
#define P1024 \
"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
@@ -78,7 +79,14 @@
ret = (mpz_set_str(bn, buf, 16) == 0); \
} while (0)
#define bn_modexp(bn, y, q, p) mpz_powm(bn, y, q, p)
-#define bn_random(bn, num_bytes) mpz_random(bn, num_bytes);
+#define bn_random(bn, num_bytes) \
+ do { \
+ gmp_randstate_t rs; \
+ gmp_randinit_mt(rs); \
+ gmp_randseed_ui(rs, av_get_random_seed()); \
+ mpz_urandomb(bn, rs, num_bytes); \
+ gmp_randclear(rs); \
+ } while (0)
#elif CONFIG_GCRYPT
#define bn_new(bn) bn = gcry_mpi_new(1)
#define bn_free(bn) gcry_mpi_release(bn)