diff options
author | Siri Hansen <[email protected]> | 2017-05-19 15:27:46 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2017-05-19 15:27:46 +0200 |
commit | 52ace0d2c565a67e587159780114792c55244312 (patch) | |
tree | 1b21b16cc9c14cf78f4c9ed30f302bd8165a8736 /lib/ssh/src/ssh_file.erl | |
parent | 7ff352ef8a5393a017ce493ba1a1fc3be54be245 (diff) | |
parent | a237426d43b73d931739d9acb86a17513b44ed3e (diff) | |
download | otp-52ace0d2c565a67e587159780114792c55244312.tar.gz otp-52ace0d2c565a67e587159780114792c55244312.tar.bz2 otp-52ace0d2c565a67e587159780114792c55244312.zip |
Merge branch 'master' into jv-gen-server-exits
Diffstat (limited to 'lib/ssh/src/ssh_file.erl')
-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"; |