diff options
author | Hans Nilsson <[email protected]> | 2017-05-16 11:57:59 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2017-05-16 11:57:59 +0200 |
commit | bff3ab2c2562dc0874d4ae9738dce78d1eb73bac (patch) | |
tree | b97359a6df70671de90ea15ef30789cdecaf4d01 /lib | |
parent | c3a3a455f15bbdadff40063a8ab3a17eb5cda4e9 (diff) | |
parent | 77371ab686d408e13dc8549085c0fdb9a5b30733 (diff) | |
download | otp-bff3ab2c2562dc0874d4ae9738dce78d1eb73bac.tar.gz otp-bff3ab2c2562dc0874d4ae9738dce78d1eb73bac.tar.bz2 otp-bff3ab2c2562dc0874d4ae9738dce78d1eb73bac.zip |
Merge branch 'hans/ssh/ssh_file_user_key_checks_ec_size/OTP-14410'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ssh/src/ssh_file.erl | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/ssh/src/ssh_file.erl b/lib/ssh/src/ssh_file.erl index 6692432fcf..33792da38f 100644 --- a/lib/ssh/src/ssh_file.erl +++ b/lib/ssh/src/ssh_file.erl @@ -75,10 +75,7 @@ host_key(Algorithm, Opts) -> Password = proplists:get_value(identity_pass_phrase(Algorithm), Opts, ignore), case decode(File, Password) of {ok,Key} -> - case ssh_transport:valid_key_sha_alg(Key,Algorithm) of - true -> {ok,Key}; - false -> {error,bad_keytype_in_file} - end; + check_key_type(Key, Algorithm); {error,DecodeError} -> {error,DecodeError} end. @@ -104,10 +101,20 @@ is_host_key(Key, PeerName, Algorithm, Opts) -> user_key(Algorithm, Opts) -> File = file_name(user, identity_key_filename(Algorithm), Opts), Password = proplists:get_value(identity_pass_phrase(Algorithm), Opts, ignore), - decode(File, Password). + case decode(File, Password) of + {ok, Key} -> + check_key_type(Key, Algorithm); + Error -> + Error + end. %% Internal functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +check_key_type(Key, Algorithm) -> + case ssh_transport:valid_key_sha_alg(Key,Algorithm) of + true -> {ok,Key}; + false -> {error,bad_keytype_in_file} + end. file_base_name('ssh-rsa' ) -> "ssh_host_rsa_key"; file_base_name('rsa-sha2-256' ) -> "ssh_host_rsa_key"; |