diff options
author | Hans Nilsson <[email protected]> | 2015-11-06 10:24:48 +0100 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2015-11-06 10:24:48 +0100 |
commit | a3bc0687a34623824bf980c9ed19eb204dcccf66 (patch) | |
tree | 30cbb844aee7f3aef5cccdff73530a4198d3314a /lib/public_key/priv/convert.escript | |
parent | 0ce885af02b6666d498c408ff0188a5fd22c8575 (diff) | |
parent | 7adbd6ee24fa7f1bb3c26d5106e7e38446405f16 (diff) | |
download | otp-a3bc0687a34623824bf980c9ed19eb204dcccf66.tar.gz otp-a3bc0687a34623824bf980c9ed19eb204dcccf66.tar.bz2 otp-a3bc0687a34623824bf980c9ed19eb204dcccf66.zip |
Merge branch 'hans/ssh/random_modulus/OTP-13054' into maint
* hans/ssh/random_modulus/OTP-13054:
ssh: correct a bad doc xref
public_key: renamed priv/ssh_moduli -> priv/moduli
ssh, public_key: updates after doc review
ssh: changes after doc review
ssh: extend 'dh_gex_limits' to server side
ssh: option dh_gex_groups with tag ssh_moduli_file
ssh, public_key: random selection of diffie-hellman moduli
Diffstat (limited to 'lib/public_key/priv/convert.escript')
-rwxr-xr-x | lib/public_key/priv/convert.escript | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/public_key/priv/convert.escript b/lib/public_key/priv/convert.escript new file mode 100755 index 0000000000..c7ea48c686 --- /dev/null +++ b/lib/public_key/priv/convert.escript @@ -0,0 +1,50 @@ +#!/usr/bin/env escript +%% -*- erlang -*- + +main([InFile,OutFile]) -> + {ok,In} = file:open(InFile,read), + {ok,Out} = file:open(OutFile,write), + write_file(Out, read_file(In)), + file:close(In), + file:close(Out). + +write_file(D, {ok,Ms}) -> + io:format(D,'-define(dh_default_groups,~n ~p~n ).~n',[Ms]). + +one_line(Line, Acc) when is_binary(Line) -> + one_line(binary_to_list(Line), Acc); +one_line("#"++_, Acc) -> + Acc; +one_line(Line, Acc) when is_list(Line) -> + try + [_Time,_Type,_Tests,_Tries,Size,G,P] = string:tokens(Line," \r\n"), + [{list_to_integer(Size), + {list_to_integer(G), list_to_integer(P,16)} + } | Acc] + catch + _:_ -> io:format("*** skip line ~p",[Line]), + Acc + end. + + +collect_per_size(L) -> + lists:foldr( + fun({Sz,GP}, [{Sz,GPs}|Acc]) -> [{Sz,[GP|GPs]}|Acc]; + ({Sz,GP}, Acc) -> [{Sz,[GP]}|Acc] + end, [], lists:sort(L)). + + +read_file(D) -> + read_file(D, []). + +read_file(D, Acc) -> + case io:get_line(D,"") of + {error,Error} -> + {error,Error}; + eof -> + {ok, collect_per_size(Acc)}; + Data -> + read_file(D, one_line(Data,Acc)) + end. + + |