diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-05-30 00:59:54 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-05-30 00:59:57 +0200 |
commit | 2e15f07cfddd0bfdc049d94c68b0198d086956b7 (patch) | |
tree | c0f4050abb6063a1a537967ea980c9266b2db433 | |
parent | f24d92badadc365f90b5737d6b0234779b6c33bf (diff) | |
parent | b2f0f37d242f1194fe1f886557cf6cefdf98caf6 (diff) | |
download | ffmpeg-2e15f07cfddd0bfdc049d94c68b0198d086956b7.tar.gz |
Merge commit 'b2f0f37d242f1194fe1f886557cf6cefdf98caf6'
* commit 'b2f0f37d242f1194fe1f886557cf6cefdf98caf6':
rtmpdh: Generate the whole private exponent using av_get_random_seed() with nettle/gmp
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/rtmpdh.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/libavformat/rtmpdh.c b/libavformat/rtmpdh.c index 96e4cd1fbc..1190fdca0f 100644 --- a/libavformat/rtmpdh.c +++ b/libavformat/rtmpdh.c @@ -81,13 +81,15 @@ ret = 1; \ } while (0) #define bn_modexp(bn, y, q, p) mpz_powm(bn, y, q, p) -#define bn_random(bn, num_bits) \ - do { \ - gmp_randstate_t rs; \ - gmp_randinit_mt(rs); \ - gmp_randseed_ui(rs, av_get_random_seed()); \ - mpz_urandomb(bn, rs, num_bits); \ - gmp_randclear(rs); \ +#define bn_random(bn, num_bits) \ + do { \ + int bits = num_bits; \ + mpz_set_ui(bn, 0); \ + for (bits = num_bits; bits > 0; bits -= 32) { \ + mpz_mul_2exp(bn, bn, 32); \ + mpz_add_ui(bn, bn, av_get_random_seed()); \ + } \ + mpz_fdiv_r_2exp(bn, bn, num_bits); \ } while (0) #elif CONFIG_GCRYPT #define bn_new(bn) bn = gcry_mpi_new(1) |