diff options
author | Hans Nilsson <[email protected]> | 2017-09-12 13:06:13 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2017-09-12 13:06:13 +0200 |
commit | ada0b0b9c760553430af8e812852dab7f8a501e5 (patch) | |
tree | ff851ee8377ae2ccff8a78248b11993f97b44bd8 | |
parent | c22e19bf3b5f735fb9007c07cfd6251a61d3d492 (diff) | |
parent | b6fc9a3964a564ac857838243d8e06ccdb904d5e (diff) | |
download | otp-ada0b0b9c760553430af8e812852dab7f8a501e5.tar.gz otp-ada0b0b9c760553430af8e812852dab7f8a501e5.tar.bz2 otp-ada0b0b9c760553430af8e812852dab7f8a501e5.zip |
Merge branch 'maint'
-rw-r--r-- | lib/public_key/src/pubkey_ssh.erl | 4 | ||||
-rw-r--r-- | lib/public_key/test/erl_make_certs.erl | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/public_key/src/pubkey_ssh.erl b/lib/public_key/src/pubkey_ssh.erl index 9bda76d670..75c1880655 100644 --- a/lib/public_key/src/pubkey_ssh.erl +++ b/lib/public_key/src/pubkey_ssh.erl @@ -79,7 +79,9 @@ dh_gex_group(Min, N, Max, undefined) -> dh_gex_group(Min, N, Max, Groups) -> case select_by_keylen(Min-10, N, Max+10, Groups) of {ok,{Sz,GPs}} -> - {ok, {Sz,lists:nth(crypto:rand_uniform(1, 1+length(GPs)), GPs)}}; + Rnd = rand:uniform( length(GPs) ), + %% 1 =< Rnd =< length(GPs) + {ok, {Sz, lists:nth(Rnd,GPs)}}; Other -> Other end. diff --git a/lib/public_key/test/erl_make_certs.erl b/lib/public_key/test/erl_make_certs.erl index e4118bab0d..e772ea1734 100644 --- a/lib/public_key/test/erl_make_certs.erl +++ b/lib/public_key/test/erl_make_certs.erl @@ -178,8 +178,9 @@ make_tbs(SubjectKey, Opts) -> _ -> subject(proplists:get_value(subject, Opts),false) end, - - {#'OTPTBSCertificate'{serialNumber = trunc(random:uniform()*100000000)*10000 + 1, + Rnd = rand:uniform( 1000000000000 ), + %% 1 =< Rnd < 1000000000001 + {#'OTPTBSCertificate'{serialNumber = Rnd, signature = SignAlgo, issuer = Issuer, validity = validity(Opts), @@ -466,7 +467,8 @@ odd_rand(Size) -> odd_rand(Min, Max). odd_rand(Min,Max) -> - Rand = crypto:rand_uniform(Min,Max), + %% Odd random number N such that Min =< N =< Max + Rand = (Min-1) + rand:uniform(Max-Min), % Min =< Rand < Max case Rand rem 2 of 0 -> Rand + 1; |