forked from net-ssh/net-ssh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ssh-ed25519 to HostKeys algorithms
- Loading branch information
Showing
10 changed files
with
77 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
require 'net/ssh/transport/hmac' | ||
require 'net/ssh/transport/kex' | ||
require 'net/ssh/transport/server_version' | ||
require 'net/ssh/authentication/ed25519_loader' | ||
|
||
module Net; module SSH; module Transport | ||
|
||
|
@@ -42,12 +43,15 @@ class Algorithms | |
hmac-sha2-512-96 none), | ||
|
||
:compression => %w(none [email protected] zlib), | ||
:language => %w() | ||
:language => %w() | ||
} | ||
if defined?(OpenSSL::PKey::EC) | ||
ALGORITHMS[:host_key] += %w(ecdsa-sha2-nistp256 | ||
ecdsa-sha2-nistp384 | ||
ecdsa-sha2-nistp521) | ||
if Net::SSH::Authentication::ED25519Loader::LOADED | ||
ALGORITHMS[:host_key] += %w(ssh-ed25519) | ||
end | ||
ALGORITHMS[:kex] += %w(ecdh-sha2-nistp256 | ||
ecdh-sha2-nistp384 | ||
ecdh-sha2-nistp521) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ def test_allowed_packets | |
end | ||
|
||
def test_constructor_should_build_default_list_of_preferred_algorithms | ||
assert_equal %w(ssh-rsa ssh-dss [email protected] [email protected])+ec_host_keys, algorithms[:host_key] | ||
assert_equal %w(ssh-rsa ssh-dss [email protected] [email protected])+ec_ed_host_keys, algorithms[:host_key] | ||
assert_equal %w(diffie-hellman-group-exchange-sha1 diffie-hellman-group1-sha1 diffie-hellman-group14-sha1 diffie-hellman-group-exchange-sha256)+ec_kex, algorithms[:kex] | ||
assert_equal %w(aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc aes256-cbc [email protected] idea-cbc none arcfour128 arcfour256 arcfour aes128-ctr aes192-ctr aes256-ctr cast128-ctr blowfish-ctr 3des-ctr), algorithms[:encryption] | ||
if defined?(OpenSSL::Digest::SHA256) | ||
|
@@ -36,12 +36,20 @@ def test_constructor_should_set_client_and_server_prefs_identically | |
end | ||
|
||
def test_constructor_with_preferred_host_key_type_should_put_preferred_host_key_type_first | ||
assert_equal %w(ssh-dss ssh-rsa [email protected] [email protected])+ec_host_keys, algorithms(:host_key => "ssh-dss", :append_all_supported_algorithms => true)[:host_key] | ||
assert_equal %w(ssh-dss ssh-rsa [email protected] [email protected])+ec_ed_host_keys, algorithms(:host_key => "ssh-dss", :append_all_supported_algorithms => true)[:host_key] | ||
end | ||
|
||
def test_constructor_with_known_hosts_reporting_known_host_key_should_use_that_host_key_type | ||
Net::SSH::KnownHosts.expects(:search_for).with("net.ssh.test,127.0.0.1", {}).returns([stub("key", :ssh_type => "ssh-dss")]) | ||
assert_equal %w(ssh-dss ssh-rsa [email protected] [email protected] )+ec_host_keys, algorithms[:host_key] | ||
assert_equal %w(ssh-dss ssh-rsa [email protected] [email protected] )+ec_ed_host_keys, algorithms[:host_key] | ||
end | ||
|
||
def ed_host_keys | ||
if Net::SSH::Authentication::ED25519Loader::LOADED | ||
%w(ssh-ed25519) | ||
else | ||
[] | ||
end | ||
end | ||
|
||
def ec_host_keys | ||
|
@@ -52,8 +60,12 @@ def ec_host_keys | |
end | ||
end | ||
|
||
def ec_ed_host_keys | ||
ec_host_keys + ed_host_keys | ||
end | ||
|
||
def test_constructor_with_unrecognized_host_key_type_should_return_whats_supported | ||
assert_equal %w(ssh-rsa ssh-dss [email protected] [email protected] )+ec_host_keys, algorithms(:host_key => "bogus ssh-rsa",:append_all_supported_algorithms => true)[:host_key] | ||
assert_equal %w(ssh-rsa ssh-dss [email protected] [email protected] )+ec_ed_host_keys, algorithms(:host_key => "bogus ssh-rsa",:append_all_supported_algorithms => true)[:host_key] | ||
end | ||
|
||
def ec_kex | ||
|
@@ -95,7 +107,7 @@ def test_constructor_with_multiple_preferred_hmac_should_put_all_preferred_hmac_ | |
end | ||
|
||
def test_constructor_with_unrecognized_hmac_should_ignore_those | ||
assert_equal %w(hmac-md5-96 hmac-sha1 hmac-md5 hmac-sha1-96 hmac-ripemd160 [email protected] hmac-sha2-256 hmac-sha2-512 hmac-sha2-256-96 hmac-sha2-512-96 none), | ||
assert_equal %w(hmac-md5-96 hmac-sha1 hmac-md5 hmac-sha1-96 hmac-ripemd160 [email protected] hmac-sha2-256 hmac-sha2-512 hmac-sha2-256-96 hmac-sha2-512-96 none), | ||
algorithms(:hmac => "hmac-md5-96", :append_all_supported_algorithms => true)[:hmac] | ||
end | ||
|
||
|
@@ -294,7 +306,7 @@ def assert_kexinit(buffer, options={}) | |
assert_equal KEXINIT, buffer.type | ||
assert_equal 16, buffer.read(16).length | ||
assert_equal options[:kex] || (%w(diffie-hellman-group-exchange-sha1 diffie-hellman-group1-sha1 diffie-hellman-group14-sha1 diffie-hellman-group-exchange-sha256)+ec_kex).join(','), buffer.read_string | ||
assert_equal options[:host_key] || (%w(ssh-rsa ssh-dss [email protected] [email protected])+ec_host_keys).join(','), buffer.read_string | ||
assert_equal options[:host_key] || (%w(ssh-rsa ssh-dss [email protected] [email protected])+ec_ed_host_keys).join(','), buffer.read_string | ||
assert_equal options[:encryption_client] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,[email protected],idea-cbc,none,arcfour128,arcfour256,arcfour,aes128-ctr,aes192-ctr,aes256-ctr,cast128-ctr,blowfish-ctr,3des-ctr", buffer.read_string | ||
assert_equal options[:encryption_server] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,[email protected],idea-cbc,none,arcfour128,arcfour256,arcfour,aes128-ctr,aes192-ctr,aes256-ctr,cast128-ctr,blowfish-ctr,3des-ctr", buffer.read_string | ||
assert_equal options[:hmac_client] || "hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96,hmac-ripemd160,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha2-256-96,hmac-sha2-512-96,none", buffer.read_string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters