net-ssh 2.0.11 → 2.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,25 @@
1
+
2
+
3
+ === 2.0.13 / 17 Aug 2009
4
+
5
+ * Added fix for hanging in ServerVersion#negotiate! when using SOCKS5 proxy (GH-9) [Gerald Talton]
6
+
7
+ * Added support for specifying a list of hosts in .ssh/config, with tests (GH-6) [ckoehler, Delano Mandelbaum]
8
+
9
+ * Added tests for arcfour128/256/512 lengths, encryption, and decryption [Delano Mandelbaum]
10
+
11
+ * Skip packet stream tests for arcfour128/256/512 [Delano Mandelbaum]
12
+
13
+ * Fix for OpenSSL cipher key length because it always returns 16, even when 32 byte keys are required, e.g. for arcfour256 and arcfour512 ciphers [Karl Varga]
14
+
15
+
16
+ === 2.0.12 / 08 Jun 2009
17
+
18
+ * Applied patch for arcfour128 and arcfour256 support [Denis Bernard]
19
+
20
+ * Use unbuffered reads when negotiating the protocol version [Steven Hazel]
21
+
22
+
1
23
  === 2.0.11 / 24 Feb 2009
2
24
 
3
25
  * Add :key_data option for specifying raw private keys in PEM format [Alex Holems, Andrew Babkin]
data/Manifest CHANGED
@@ -1,4 +1,10 @@
1
1
  CHANGELOG.rdoc
2
+ Manifest
3
+ README.rdoc
4
+ Rakefile
5
+ Rudyfile
6
+ THANKS.rdoc
7
+ lib/net/ssh.rb
2
8
  lib/net/ssh/authentication/agent.rb
3
9
  lib/net/ssh/authentication/constants.rb
4
10
  lib/net/ssh/authentication/key_manager.rb
@@ -28,6 +34,7 @@ lib/net/ssh/proxy/socks4.rb
28
34
  lib/net/ssh/proxy/socks5.rb
29
35
  lib/net/ssh/ruby_compat.rb
30
36
  lib/net/ssh/service/forward.rb
37
+ lib/net/ssh/test.rb
31
38
  lib/net/ssh/test/channel.rb
32
39
  lib/net/ssh/test/extensions.rb
33
40
  lib/net/ssh/test/kex.rb
@@ -36,21 +43,20 @@ lib/net/ssh/test/packet.rb
36
43
  lib/net/ssh/test/remote_packet.rb
37
44
  lib/net/ssh/test/script.rb
38
45
  lib/net/ssh/test/socket.rb
39
- lib/net/ssh/test.rb
40
46
  lib/net/ssh/transport/algorithms.rb
41
47
  lib/net/ssh/transport/cipher_factory.rb
42
48
  lib/net/ssh/transport/constants.rb
49
+ lib/net/ssh/transport/hmac.rb
43
50
  lib/net/ssh/transport/hmac/abstract.rb
44
51
  lib/net/ssh/transport/hmac/md5.rb
45
52
  lib/net/ssh/transport/hmac/md5_96.rb
46
53
  lib/net/ssh/transport/hmac/none.rb
47
54
  lib/net/ssh/transport/hmac/sha1.rb
48
55
  lib/net/ssh/transport/hmac/sha1_96.rb
49
- lib/net/ssh/transport/hmac.rb
50
56
  lib/net/ssh/transport/identity_cipher.rb
57
+ lib/net/ssh/transport/kex.rb
51
58
  lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb
52
59
  lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb
53
- lib/net/ssh/transport/kex.rb
54
60
  lib/net/ssh/transport/openssl.rb
55
61
  lib/net/ssh/transport/packet_stream.rb
56
62
  lib/net/ssh/transport/server_version.rb
@@ -60,12 +66,9 @@ lib/net/ssh/verifiers/lenient.rb
60
66
  lib/net/ssh/verifiers/null.rb
61
67
  lib/net/ssh/verifiers/strict.rb
62
68
  lib/net/ssh/version.rb
63
- lib/net/ssh.rb
64
- Manifest
65
69
  net-ssh.gemspec
66
- Rakefile
67
- README.rdoc
68
70
  setup.rb
71
+ support/arcfour_check.rb
69
72
  test/authentication/methods/common.rb
70
73
  test/authentication/methods/test_abstract.rb
71
74
  test/authentication/methods/test_hostbased.rb
@@ -78,6 +81,7 @@ test/authentication/test_session.rb
78
81
  test/common.rb
79
82
  test/configs/eqsign
80
83
  test/configs/exact_match
84
+ test/configs/multihost
81
85
  test/configs/wild_cards
82
86
  test/connection/test_channel.rb
83
87
  test/connection/test_session.rb
@@ -101,4 +105,3 @@ test/transport/test_packet_stream.rb
101
105
  test/transport/test_server_version.rb
102
106
  test/transport/test_session.rb
103
107
  test/transport/test_state.rb
104
- THANKS.rdoc
@@ -80,10 +80,40 @@ Lastly, if you want to run the tests or use any of the Rake tasks, you'll need:
80
80
  * Echoe (for the Rakefile)
81
81
  * Mocha (for the tests)
82
82
 
83
+
83
84
  == INSTALL:
84
85
 
85
86
  * gem install net-ssh (might need sudo privileges)
86
87
 
88
+
89
+ == ARCFOUR SUPPORT:
90
+
91
+ from Karl Varga:
92
+
93
+ Ruby's OpenSSL bindings always return a key length of 16 for RC4 ciphers, which means that when we try to use ARCFOUR256 or higher, Net::SSH generates keys which are consistently too short - 16 bytes as opposed to 32 bytes - resulting in the following error:
94
+
95
+ OpenSSL::CipherError: key length too short
96
+
97
+ My patch simply instructs Net::SSH to build keys of the the proper length, regardless of the required key length reported by OpenSSL.
98
+
99
+ You should also be aware that your OpenSSL C libraries may also contain this bug. I've updated to 0.9.8k, but according to this thread[https://bugzilla.mindrot.org/show_bug.cgi?id=1291], the bug existed as recently as 0.9.8e! I've manually taken a look at my header files and they look ok, which is what makes me think it's a bug in the Ruby implementation.
100
+
101
+ To see your OpenSSL version:
102
+
103
+ $ openssl version
104
+ OpenSSL 0.9.8k 25 Mar 2009
105
+
106
+ After installing this gem, verify that Net::SSH is generating keys of the correct length by running the script <tt>support/arcfour_check.rb</tt>:
107
+
108
+ $ ruby arcfour_support.rb
109
+
110
+ which should produce the following:
111
+
112
+ arcfour128: [16, 8] OpenSSL::Cipher::Cipher
113
+ arcfour256: [32, 8] OpenSSL::Cipher::Cipher
114
+ arcfour512: [64, 8] OpenSSL::Cipher::Cipher
115
+
116
+
87
117
  == LICENSE:
88
118
 
89
119
  (The MIT License)
data/Rakefile CHANGED
@@ -1,26 +1,79 @@
1
- require './lib/net/ssh/version'
1
+ require 'rubygems'
2
+ require 'rake/clean'
3
+ require 'rake/gempackagetask'
4
+ require 'hanna/rdoctask'
5
+ require 'fileutils'
6
+ include FileUtils
7
+
8
+ task :default => :package
9
+
10
+ # CONFIG =============================================================
2
11
 
3
- begin
4
- require 'echoe'
5
- rescue LoadError
6
- abort "You'll need to have `echoe' installed to use Net::SSH's Rakefile"
12
+ # Change the following according to your needs
13
+ README = "README.rdoc"
14
+ CHANGES = "CHANGELOG.rdoc"
15
+ THANKS = 'THANKS.rdoc'
16
+
17
+ # Files and directories to be deleted when you run "rake clean"
18
+ CLEAN.include [ 'pkg', '*.gem', '.config', 'doc']
19
+
20
+ # Virginia assumes your project and gemspec have the same name
21
+ name = 'net-ssh'
22
+ load "#{name}.gemspec"
23
+ version = @spec.version
24
+
25
+ # That's it! The following defaults should allow you to get started
26
+ # on other things.
27
+
28
+
29
+ # TESTS/SPECS =========================================================
30
+
31
+
32
+
33
+ # INSTALL =============================================================
34
+
35
+ Rake::GemPackageTask.new(@spec) do |p|
36
+ p.need_tar = true if RUBY_PLATFORM !~ /mswin/
37
+ end
38
+
39
+ task :release => [ :rdoc, :package ]
40
+ task :install => [ :rdoc, :package ] do
41
+ sh %{sudo gem install pkg/#{name}-#{version}.gem}
42
+ end
43
+ task :uninstall => [ :clean ] do
44
+ sh %{sudo gem uninstall #{name}}
7
45
  end
8
46
 
9
- version = Net::SSH::Version::STRING.dup
10
- if ENV['SNAPSHOT'].to_i == 1
11
- version << "." << Time.now.utc.strftime("%Y%m%d%H%M%S")
47
+
48
+ # RUBYFORGE RELEASE / PUBLISH TASKS ==================================
49
+
50
+ if @spec.rubyforge_project
51
+ desc 'Publish website to rubyforge'
52
+ task 'publish:rdoc' => 'doc/index.html' do
53
+ sh "scp -rp doc/* rubyforge.org:/var/www/gforge-projects/#{name}/ssh/v2/api/"
54
+ end
55
+
56
+ desc 'Public release to rubyforge'
57
+ task 'publish:gem' => [:package] do |t|
58
+ sh <<-end
59
+ rubyforge add_release -o Any -a #{CHANGES} -f -n #{README} #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.gem &&
60
+ rubyforge add_file -o Any -a #{CHANGES} -f -n #{README} #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.tgz
61
+ end
62
+ end
12
63
  end
13
64
 
14
- Echoe.new('net-ssh', version) do |p|
15
- p.changelog = "CHANGELOG.rdoc"
16
65
 
17
- p.author = "Jamis Buck"
18
- p.email = "jamis@jamisbuck.org"
19
- p.summary = "a pure-Ruby implementation of the SSH2 client protocol"
20
- p.url = "http://net-ssh.rubyforge.org/ssh"
21
66
 
22
- p.need_zip = true
23
- p.include_rakefile = true
67
+ # RUBY DOCS TASK ==================================
24
68
 
25
- p.rdoc_pattern = /^(lib|README.rdoc|CHANGELOG.rdoc|THANKS.rdoc)/
69
+ Rake::RDocTask.new do |t|
70
+ t.rdoc_dir = 'doc'
71
+ t.title = @spec.summary
72
+ t.options << '--line-numbers' << '-A cattr_accessor=object'
73
+ t.options << '--charset' << 'utf-8'
74
+ t.rdoc_files.include(README)
75
+ t.rdoc_files.include(CHANGES)
76
+ t.rdoc_files.include(THANKS)
77
+ t.rdoc_files.include('lib/**/*.rb')
26
78
  end
79
+
@@ -0,0 +1,110 @@
1
+ # Rudyfile
2
+ #
3
+ # This configuration is used to test installing
4
+ # and running net-ssh on a clean machine.
5
+ #
6
+ # Usage:
7
+ #
8
+ # $ rudy -vv startup
9
+ # $ rudy -vv testsuite
10
+ # $ rudy -vv shutdown
11
+ #
12
+ # Requires: Rudy 0.9 (http://code.google.com/p/rudy/)
13
+ #
14
+
15
+ defaults do
16
+ color true
17
+ environment :test
18
+ role :netssh
19
+ end
20
+
21
+ machines do
22
+ region :'us-east-1' do
23
+ ami 'ami-e348af8a' # Alestic Debian 5.0, 32-bit (US)
24
+ end
25
+ env :test do
26
+ role :netssh do
27
+ user :root
28
+ end
29
+ end
30
+ end
31
+
32
+ commands do
33
+ allow :apt_get, "apt-get", :y, :q
34
+ allow :gem_install, "/usr/bin/gem", "install", :n, '/usr/bin', :y, :V, "--no-rdoc", "--no-ri"
35
+ allow :gem_sources, "/usr/bin/gem", "sources"
36
+ allow :gem_uninstall, "/usr/bin/gem", "uninstall", :V
37
+ allow :update_rubygems
38
+ allow :rm
39
+ end
40
+
41
+ routines do
42
+
43
+ testsuite do
44
+ before :sysupdate, :installdeps, :install_gem
45
+
46
+ remote :root do
47
+ directory_upload 'test', '/tmp/'
48
+ cd '/tmp'
49
+ ruby :I, 'lib/', :I, 'test/', :r, 'rubygems', 'test/test_all.rb'
50
+ end
51
+
52
+ after :install_rubyforge, :install_github
53
+ end
54
+
55
+ install_rubyforge do
56
+ remote :root do
57
+ gem_install 'net-ssh', '--version', '2.0.7'
58
+ gem_install 'net-ssh'
59
+ end
60
+ end
61
+
62
+ install_github do
63
+ remote :root do
64
+ gem_sources :a, "http://gems.github.com"
65
+ gem_install 'net-ssh-net-ssh'
66
+ end
67
+ end
68
+
69
+ install_gem do
70
+ before :package_gem
71
+ remote :root do
72
+ disable_safe_mode
73
+ file_upload "pkg/net-ssh-*.gem", "/tmp/"
74
+ gem_install "/tmp/net-ssh-*.gem"
75
+ end
76
+ end
77
+
78
+ package_gem do
79
+ local do
80
+ rm :r, :f, 'pkg'
81
+ rake 'package'
82
+ end
83
+ end
84
+
85
+ remove do
86
+ remote :root do
87
+ gem_uninstall 'net-ssh'
88
+ end
89
+ end
90
+
91
+ installdeps do
92
+ remote :root do
93
+ gem_install "rye", "test-unit", "mocha"
94
+ rye 'authorize-local'
95
+ end
96
+ end
97
+
98
+ sysupdate do
99
+ remote :root do
100
+ apt_get "update"
101
+ apt_get "install", "build-essential", "git-core"
102
+ apt_get "install", "ruby1.8-dev", "rdoc", "libzlib-ruby", "rubygems"
103
+ mkdir :p, "/var/lib/gems/1.8/bin" # Doesn't get created, but causes Rubygems to fail
104
+ gem_install "builder", "session"
105
+ gem_install 'rubygems-update', "-v=1.3.4" # circular issue with 1.3.5 and hoe
106
+ update_rubygems
107
+ end
108
+ end
109
+ end
110
+
@@ -57,11 +57,12 @@ module Net; module SSH
57
57
  def load(file, host, settings={})
58
58
  file = File.expand_path(file)
59
59
  return settings unless File.readable?(file)
60
-
61
- in_match = false
60
+
61
+ matched_host = nil
62
+ multi_host = []
62
63
  IO.foreach(file) do |line|
63
64
  next if line =~ /^\s*(?:#.*)?$/
64
-
65
+
65
66
  if line =~ /^\s*(\S+)\s*=(.*)$/
66
67
  key, value = $1, $2
67
68
  else
@@ -82,8 +83,11 @@ module Net; module SSH
82
83
  end
83
84
 
84
85
  if key == 'host'
85
- in_match = (host =~ pattern2regex(value))
86
- elsif in_match
86
+ # Support "Host host1,host2,hostN".
87
+ # See http://github.com/net-ssh/net-ssh/issues#issue/6
88
+ multi_host = value.split(/,\s+/)
89
+ matched_host = multi_host.select { |h| host =~ pattern2regex(h) }.first
90
+ elsif !matched_host.nil?
87
91
  if key == 'identityfile'
88
92
  settings[key] ||= []
89
93
  settings[key] << value
@@ -92,7 +96,7 @@ module Net; module SSH
92
96
  end
93
97
  end
94
98
  end
95
-
99
+
96
100
  return settings
97
101
  end
98
102
 
@@ -94,11 +94,24 @@ module Net
94
94
 
95
95
  packet << [port].pack("n")
96
96
  socket.send packet, 0
97
-
98
- version, reply, = socket.recv(4).unpack("C*")
99
- len = socket.recv(1).getbyte(0)
100
- socket.recv(len + 2)
101
-
97
+
98
+ version, reply, = socket.recv(2).unpack("C*")
99
+ socket.recv(1)
100
+ address_type = socket.recv(1).getbyte(0)
101
+ case address_type
102
+ when 1
103
+ socket.recv(4) # get four bytes for IPv4 address
104
+ when 3
105
+ len = socket.recv(1).getbyte(0)
106
+ hostname = socket.recv(len)
107
+ when 4
108
+ ipv6addr hostname = socket.recv(16)
109
+ else
110
+ socket.close
111
+ raise ConnectionError, "Illegal response type"
112
+ end
113
+ portnum = socket.recv(2)
114
+
102
115
  unless reply == SUCCESS
103
116
  socket.close
104
117
  raise ConnectError, "#{reply}"
@@ -27,7 +27,7 @@ module Net; module SSH; module Transport
27
27
  diffie-hellman-group1-sha1),
28
28
  :encryption => %w(aes128-cbc 3des-cbc blowfish-cbc cast128-cbc
29
29
  aes192-cbc aes256-cbc rijndael-cbc@lysator.liu.se
30
- idea-cbc none),
30
+ idea-cbc none arcfour128 arcfour256),
31
31
  :hmac => %w(hmac-sha1 hmac-md5 hmac-sha1-96 hmac-md5-96 none),
32
32
  :compression => %w(none zlib@openssh.com zlib),
33
33
  :language => %w()
@@ -15,9 +15,20 @@ module Net; module SSH; module Transport
15
15
  "idea-cbc" => "idea-cbc",
16
16
  "cast128-cbc" => "cast-cbc",
17
17
  "rijndael-cbc@lysator.liu.se" => "aes-256-cbc",
18
+ "arcfour128" => "rc4",
19
+ "arcfour256" => "rc4",
20
+ "arcfour512" => "rc4",
18
21
  "none" => "none"
19
22
  }
20
-
23
+
24
+ # Ruby's OpenSSL bindings always return a key length of 16 for RC4 ciphers
25
+ # resulting in the error: OpenSSL::CipherError: key length too short.
26
+ # The following ciphers will override this key length.
27
+ KEY_LEN_OVERRIDE = {
28
+ "arcfour256" => 32,
29
+ "arcfour512" => 64
30
+ }
31
+
21
32
  # Returns true if the underlying OpenSSL library supports the given cipher,
22
33
  # and false otherwise.
23
34
  def self.supported?(name)
@@ -39,8 +50,11 @@ module Net; module SSH; module Transport
39
50
  cipher.send(options[:encrypt] ? :encrypt : :decrypt)
40
51
 
41
52
  cipher.padding = 0
42
- cipher.iv = make_key(cipher.iv_len, options[:iv], options)
43
- cipher.key = make_key(cipher.key_len, options[:key], options)
53
+ cipher.iv = make_key(cipher.iv_len, options[:iv], options) if ossl_name != "rc4"
54
+ key_len = KEY_LEN_OVERRIDE[name] || cipher.key_len
55
+ cipher.key_len = key_len
56
+ cipher.key = make_key(key_len, options[:key], options)
57
+ cipher.update(" " * 1536) if ossl_name == "rc4"
44
58
 
45
59
  return cipher
46
60
  end
@@ -54,7 +68,10 @@ module Net; module SSH; module Transport
54
68
  return [0, 0] if ossl_name.nil? || ossl_name == "none"
55
69
 
56
70
  cipher = OpenSSL::Cipher::Cipher.new(ossl_name)
57
- return [cipher.key_len, cipher.block_size]
71
+ key_len = KEY_LEN_OVERRIDE[name] || cipher.key_len
72
+ cipher.key_len = key_len
73
+
74
+ return [key_len, ossl_name=="rc4" ? 8 : cipher.block_size]
58
75
  end
59
76
 
60
77
  private
@@ -62,10 +79,10 @@ module Net; module SSH; module Transport
62
79
  # Generate a key value in accordance with the SSH2 specification.
63
80
  def self.make_key(bytes, start, options={})
64
81
  k = start[0, bytes]
65
-
66
- digester = options[:digester]
67
- shared = options[:shared]
68
- hash = options[:hash]
82
+
83
+ digester = options[:digester] or raise 'No digester supplied'
84
+ shared = options[:shared] or raise 'No shared secret supplied'
85
+ hash = options[:hash] or raise 'No hash supplied'
69
86
 
70
87
  while k.length < bytes
71
88
  step = digester.digest(shared + hash + k)
@@ -118,14 +118,14 @@ module Net; module SSH; module Transport
118
118
  actual_length = 4 + payload.length + 1
119
119
 
120
120
  # compute the padding length
121
- padding_length = client.cipher.block_size - (actual_length % client.cipher.block_size)
122
- padding_length += client.cipher.block_size if padding_length < 4
121
+ padding_length = client.block_size - (actual_length % client.block_size)
122
+ padding_length += client.block_size if padding_length < 4
123
123
 
124
124
  # compute the packet length (sans the length field itself)
125
125
  packet_length = payload.length + padding_length + 1
126
126
 
127
127
  if packet_length < 16
128
- padding_length += client.cipher.block_size
128
+ padding_length += client.block_size
129
129
  packet_length = payload.length + padding_length + 1
130
130
  end
131
131
 
@@ -182,7 +182,7 @@ module Net; module SSH; module Transport
182
182
  # new Packet object.
183
183
  def poll_next_packet
184
184
  if @packet.nil?
185
- minimum = server.cipher.block_size < 4 ? 4 : server.cipher.block_size
185
+ minimum = server.block_size < 4 ? 4 : server.block_size
186
186
  return nil if available < minimum
187
187
  data = read_available(minimum)
188
188
 
@@ -191,8 +191,8 @@ module Net; module SSH; module Transport
191
191
  @packet_length = @packet.read_long
192
192
  end
193
193
 
194
- need = @packet_length + 4 - server.cipher.block_size
195
- raise Net::SSH::Exception, "padding error, need #{need} block #{server.cipher.block_size}" if need % server.cipher.block_size != 0
194
+ need = @packet_length + 4 - server.block_size
195
+ raise Net::SSH::Exception, "padding error, need #{need} block #{server.block_size}" if need % server.block_size != 0
196
196
 
197
197
  return nil if available < need + server.hmac.mac_length
198
198
 
@@ -41,8 +41,17 @@ module Net; module SSH; module Transport
41
41
  info { "negotiating protocol version" }
42
42
 
43
43
  loop do
44
- @version = socket.readline
45
- break if @version.nil? || @version.match(/^SSH-/)
44
+ @version = ""
45
+ loop do
46
+ b = socket.recv(1)
47
+
48
+ if b.nil?
49
+ raise Net::SSH::Disconnect, "connection closed by remote host"
50
+ end
51
+ @version << b
52
+ break if b == "\n"
53
+ end
54
+ break if @version.match(/^SSH-/)
46
55
  @header << @version
47
56
  end
48
57
 
@@ -55,6 +64,7 @@ module Net; module SSH; module Transport
55
64
 
56
65
  debug { "local is `#{PROTO_VERSION}'" }
57
66
  socket.write "#{PROTO_VERSION}\r\n"
67
+ socket.flush
58
68
  end
59
69
  end
60
- end; end; end
70
+ end; end; end
@@ -34,6 +34,9 @@ module Net; module SSH; module Transport
34
34
  # The cipher algorithm in use for this socket endpoint.
35
35
  attr_reader :cipher
36
36
 
37
+ # The block size for the cipher
38
+ attr_reader :block_size
39
+
37
40
  # The role that this state plays (either :client or :server)
38
41
  attr_reader :role
39
42
 
@@ -56,6 +59,7 @@ module Net; module SSH; module Transport
56
59
  @role = role
57
60
  @sequence_number = @packets = @blocks = 0
58
61
  @cipher = CipherFactory.get("none")
62
+ @block_size = 8
59
63
  @hmac = HMAC.get("none")
60
64
  @compression = nil
61
65
  @compressor = @decompressor = nil
@@ -89,7 +93,7 @@ module Net; module SSH; module Transport
89
93
  def increment(packet_length)
90
94
  @sequence_number = (@sequence_number + 1) & 0xFFFFFFFF
91
95
  @packets += 1
92
- @blocks += (packet_length + 4) / cipher.block_size
96
+ @blocks += (packet_length + 4) / @block_size
93
97
  end
94
98
 
95
99
  # The compressor object to use when compressing data. This takes into account
@@ -135,22 +139,23 @@ module Net; module SSH; module Transport
135
139
 
136
140
  @max_packets ||= 1 << 31
137
141
 
142
+ @block_size = cipher.name == "RC4" ? 8 : cipher.block_size
143
+
138
144
  if max_blocks.nil?
139
145
  # cargo-culted from openssh. the idea is that "the 2^(blocksize*2)
140
146
  # limit is too expensive for 3DES, blowfish, etc., so enforce a 1GB
141
147
  # limit for small blocksizes."
142
-
143
- if cipher.block_size >= 16
144
- @max_blocks = 1 << (cipher.block_size * 2)
148
+ if @block_size >= 16
149
+ @max_blocks = 1 << (@block_size * 2)
145
150
  else
146
- @max_blocks = (1 << 30) / cipher.block_size
151
+ @max_blocks = (1 << 30) / @block_size
147
152
  end
148
153
 
149
154
  # if a limit on the # of bytes has been given, convert that into a
150
155
  # minimum number of blocks processed.
151
156
 
152
157
  if rekey_limit
153
- @max_blocks = [@max_blocks, rekey_limit / cipher.block_size].min
158
+ @max_blocks = [@max_blocks, rekey_limit / @block_size].min
154
159
  end
155
160
  end
156
161
 
@@ -51,7 +51,7 @@ module Net; module SSH
51
51
  MINOR = 0
52
52
 
53
53
  # The tiny component of this version of the Net::SSH library
54
- TINY = 11
54
+ TINY = 13
55
55
 
56
56
  # The current version of the Net::SSH library as a Version instance
57
57
  CURRENT = new(MAJOR, MINOR, TINY)
@@ -1,33 +1,131 @@
1
- Gem::Specification.new do |s|
2
- s.name = %q{net-ssh}
3
- s.version = "2.0.11"
4
-
5
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
- s.authors = ["Jamis Buck"]
7
- s.date = %q{2009-02-24}
8
- s.description = %q{a pure-Ruby implementation of the SSH2 client protocol}
9
- s.email = %q{jamis@jamisbuck.org}
10
- s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/net/ssh/authentication/agent.rb", "lib/net/ssh/authentication/constants.rb", "lib/net/ssh/authentication/key_manager.rb", "lib/net/ssh/authentication/methods/abstract.rb", "lib/net/ssh/authentication/methods/hostbased.rb", "lib/net/ssh/authentication/methods/keyboard_interactive.rb", "lib/net/ssh/authentication/methods/password.rb", "lib/net/ssh/authentication/methods/publickey.rb", "lib/net/ssh/authentication/pageant.rb", "lib/net/ssh/authentication/session.rb", "lib/net/ssh/buffer.rb", "lib/net/ssh/buffered_io.rb", "lib/net/ssh/config.rb", "lib/net/ssh/connection/channel.rb", "lib/net/ssh/connection/constants.rb", "lib/net/ssh/connection/session.rb", "lib/net/ssh/connection/term.rb", "lib/net/ssh/errors.rb", "lib/net/ssh/key_factory.rb", "lib/net/ssh/known_hosts.rb", "lib/net/ssh/loggable.rb", "lib/net/ssh/packet.rb", "lib/net/ssh/prompt.rb", "lib/net/ssh/proxy/errors.rb", "lib/net/ssh/proxy/http.rb", "lib/net/ssh/proxy/socks4.rb", "lib/net/ssh/proxy/socks5.rb", "lib/net/ssh/ruby_compat.rb", "lib/net/ssh/service/forward.rb", "lib/net/ssh/test/channel.rb", "lib/net/ssh/test/extensions.rb", "lib/net/ssh/test/kex.rb", "lib/net/ssh/test/local_packet.rb", "lib/net/ssh/test/packet.rb", "lib/net/ssh/test/remote_packet.rb", "lib/net/ssh/test/script.rb", "lib/net/ssh/test/socket.rb", "lib/net/ssh/test.rb", "lib/net/ssh/transport/algorithms.rb", "lib/net/ssh/transport/cipher_factory.rb", "lib/net/ssh/transport/constants.rb", "lib/net/ssh/transport/hmac/abstract.rb", "lib/net/ssh/transport/hmac/md5.rb", "lib/net/ssh/transport/hmac/md5_96.rb", "lib/net/ssh/transport/hmac/none.rb", "lib/net/ssh/transport/hmac/sha1.rb", "lib/net/ssh/transport/hmac/sha1_96.rb", "lib/net/ssh/transport/hmac.rb", "lib/net/ssh/transport/identity_cipher.rb", "lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb", "lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb", "lib/net/ssh/transport/kex.rb", "lib/net/ssh/transport/openssl.rb", "lib/net/ssh/transport/packet_stream.rb", "lib/net/ssh/transport/server_version.rb", "lib/net/ssh/transport/session.rb", "lib/net/ssh/transport/state.rb", "lib/net/ssh/verifiers/lenient.rb", "lib/net/ssh/verifiers/null.rb", "lib/net/ssh/verifiers/strict.rb", "lib/net/ssh/version.rb", "lib/net/ssh.rb", "README.rdoc", "THANKS.rdoc"]
11
- s.files = ["CHANGELOG.rdoc", "lib/net/ssh/authentication/agent.rb", "lib/net/ssh/authentication/constants.rb", "lib/net/ssh/authentication/key_manager.rb", "lib/net/ssh/authentication/methods/abstract.rb", "lib/net/ssh/authentication/methods/hostbased.rb", "lib/net/ssh/authentication/methods/keyboard_interactive.rb", "lib/net/ssh/authentication/methods/password.rb", "lib/net/ssh/authentication/methods/publickey.rb", "lib/net/ssh/authentication/pageant.rb", "lib/net/ssh/authentication/session.rb", "lib/net/ssh/buffer.rb", "lib/net/ssh/buffered_io.rb", "lib/net/ssh/config.rb", "lib/net/ssh/connection/channel.rb", "lib/net/ssh/connection/constants.rb", "lib/net/ssh/connection/session.rb", "lib/net/ssh/connection/term.rb", "lib/net/ssh/errors.rb", "lib/net/ssh/key_factory.rb", "lib/net/ssh/known_hosts.rb", "lib/net/ssh/loggable.rb", "lib/net/ssh/packet.rb", "lib/net/ssh/prompt.rb", "lib/net/ssh/proxy/errors.rb", "lib/net/ssh/proxy/http.rb", "lib/net/ssh/proxy/socks4.rb", "lib/net/ssh/proxy/socks5.rb", "lib/net/ssh/ruby_compat.rb", "lib/net/ssh/service/forward.rb", "lib/net/ssh/test/channel.rb", "lib/net/ssh/test/extensions.rb", "lib/net/ssh/test/kex.rb", "lib/net/ssh/test/local_packet.rb", "lib/net/ssh/test/packet.rb", "lib/net/ssh/test/remote_packet.rb", "lib/net/ssh/test/script.rb", "lib/net/ssh/test/socket.rb", "lib/net/ssh/test.rb", "lib/net/ssh/transport/algorithms.rb", "lib/net/ssh/transport/cipher_factory.rb", "lib/net/ssh/transport/constants.rb", "lib/net/ssh/transport/hmac/abstract.rb", "lib/net/ssh/transport/hmac/md5.rb", "lib/net/ssh/transport/hmac/md5_96.rb", "lib/net/ssh/transport/hmac/none.rb", "lib/net/ssh/transport/hmac/sha1.rb", "lib/net/ssh/transport/hmac/sha1_96.rb", "lib/net/ssh/transport/hmac.rb", "lib/net/ssh/transport/identity_cipher.rb", "lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb", "lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb", "lib/net/ssh/transport/kex.rb", "lib/net/ssh/transport/openssl.rb", "lib/net/ssh/transport/packet_stream.rb", "lib/net/ssh/transport/server_version.rb", "lib/net/ssh/transport/session.rb", "lib/net/ssh/transport/state.rb", "lib/net/ssh/verifiers/lenient.rb", "lib/net/ssh/verifiers/null.rb", "lib/net/ssh/verifiers/strict.rb", "lib/net/ssh/version.rb", "lib/net/ssh.rb", "Manifest", "net-ssh.gemspec", "Rakefile", "README.rdoc", "setup.rb", "test/authentication/methods/common.rb", "test/authentication/methods/test_abstract.rb", "test/authentication/methods/test_hostbased.rb", "test/authentication/methods/test_keyboard_interactive.rb", "test/authentication/methods/test_password.rb", "test/authentication/methods/test_publickey.rb", "test/authentication/test_agent.rb", "test/authentication/test_key_manager.rb", "test/authentication/test_session.rb", "test/common.rb", "test/configs/eqsign", "test/configs/exact_match", "test/configs/wild_cards", "test/connection/test_channel.rb", "test/connection/test_session.rb", "test/test_all.rb", "test/test_buffer.rb", "test/test_buffered_io.rb", "test/test_config.rb", "test/test_key_factory.rb", "test/transport/hmac/test_md5.rb", "test/transport/hmac/test_md5_96.rb", "test/transport/hmac/test_none.rb", "test/transport/hmac/test_sha1.rb", "test/transport/hmac/test_sha1_96.rb", "test/transport/kex/test_diffie_hellman_group1_sha1.rb", "test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb", "test/transport/test_algorithms.rb", "test/transport/test_cipher_factory.rb", "test/transport/test_hmac.rb", "test/transport/test_identity_cipher.rb", "test/transport/test_packet_stream.rb", "test/transport/test_server_version.rb", "test/transport/test_session.rb", "test/transport/test_state.rb", "THANKS.rdoc"]
1
+ @spec = Gem::Specification.new do |s|
2
+ s.name = "net-ssh"
3
+ s.rubyforge_project = 'net-ssh'
4
+ s.version = "2.0.13"
5
+ s.summary = "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol."
6
+ s.description = s.summary
7
+ s.authors = ["Jamis Buck", "Delano Mandelbaum"]
8
+ s.email = ["net-ssh@solutious.com", "net-ssh@solutious.com"]
9
+ s.homepage = "http://rubyforge.org/projects/net-ssh/"
10
+
11
+ s.extra_rdoc_files = %w[README.rdoc THANKS.rdoc CHANGELOG.rdoc]
12
12
  s.has_rdoc = true
13
- s.homepage = %q{http://net-ssh.rubyforge.org/ssh}
14
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Net-ssh", "--main", "README.rdoc"]
15
- s.require_paths = ["lib"]
16
- s.rubyforge_project = %q{net-ssh}
17
- s.rubygems_version = %q{1.2.0}
18
- s.summary = %q{a pure-Ruby implementation of the SSH2 client protocol}
19
- s.test_files = ["test/test_all.rb"]
20
-
21
- if s.respond_to? :specification_version then
22
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
- s.specification_version = 2
13
+ s.rdoc_options = ["--line-numbers", "--title", s.summary, "--main", "README.rdoc"]
14
+ s.require_paths = %w[lib]
15
+ s.rubygems_version = '1.3.2'
16
+
17
+ s.executables = %w[]
18
+
19
+ # = MANIFEST =
20
+ s.files = %w(
21
+ CHANGELOG.rdoc
22
+ Manifest
23
+ README.rdoc
24
+ Rakefile
25
+ Rudyfile
26
+ THANKS.rdoc
27
+ lib/net/ssh.rb
28
+ lib/net/ssh/authentication/agent.rb
29
+ lib/net/ssh/authentication/constants.rb
30
+ lib/net/ssh/authentication/key_manager.rb
31
+ lib/net/ssh/authentication/methods/abstract.rb
32
+ lib/net/ssh/authentication/methods/hostbased.rb
33
+ lib/net/ssh/authentication/methods/keyboard_interactive.rb
34
+ lib/net/ssh/authentication/methods/password.rb
35
+ lib/net/ssh/authentication/methods/publickey.rb
36
+ lib/net/ssh/authentication/pageant.rb
37
+ lib/net/ssh/authentication/session.rb
38
+ lib/net/ssh/buffer.rb
39
+ lib/net/ssh/buffered_io.rb
40
+ lib/net/ssh/config.rb
41
+ lib/net/ssh/connection/channel.rb
42
+ lib/net/ssh/connection/constants.rb
43
+ lib/net/ssh/connection/session.rb
44
+ lib/net/ssh/connection/term.rb
45
+ lib/net/ssh/errors.rb
46
+ lib/net/ssh/key_factory.rb
47
+ lib/net/ssh/known_hosts.rb
48
+ lib/net/ssh/loggable.rb
49
+ lib/net/ssh/packet.rb
50
+ lib/net/ssh/prompt.rb
51
+ lib/net/ssh/proxy/errors.rb
52
+ lib/net/ssh/proxy/http.rb
53
+ lib/net/ssh/proxy/socks4.rb
54
+ lib/net/ssh/proxy/socks5.rb
55
+ lib/net/ssh/ruby_compat.rb
56
+ lib/net/ssh/service/forward.rb
57
+ lib/net/ssh/test.rb
58
+ lib/net/ssh/test/channel.rb
59
+ lib/net/ssh/test/extensions.rb
60
+ lib/net/ssh/test/kex.rb
61
+ lib/net/ssh/test/local_packet.rb
62
+ lib/net/ssh/test/packet.rb
63
+ lib/net/ssh/test/remote_packet.rb
64
+ lib/net/ssh/test/script.rb
65
+ lib/net/ssh/test/socket.rb
66
+ lib/net/ssh/transport/algorithms.rb
67
+ lib/net/ssh/transport/cipher_factory.rb
68
+ lib/net/ssh/transport/constants.rb
69
+ lib/net/ssh/transport/hmac.rb
70
+ lib/net/ssh/transport/hmac/abstract.rb
71
+ lib/net/ssh/transport/hmac/md5.rb
72
+ lib/net/ssh/transport/hmac/md5_96.rb
73
+ lib/net/ssh/transport/hmac/none.rb
74
+ lib/net/ssh/transport/hmac/sha1.rb
75
+ lib/net/ssh/transport/hmac/sha1_96.rb
76
+ lib/net/ssh/transport/identity_cipher.rb
77
+ lib/net/ssh/transport/kex.rb
78
+ lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb
79
+ lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb
80
+ lib/net/ssh/transport/openssl.rb
81
+ lib/net/ssh/transport/packet_stream.rb
82
+ lib/net/ssh/transport/server_version.rb
83
+ lib/net/ssh/transport/session.rb
84
+ lib/net/ssh/transport/state.rb
85
+ lib/net/ssh/verifiers/lenient.rb
86
+ lib/net/ssh/verifiers/null.rb
87
+ lib/net/ssh/verifiers/strict.rb
88
+ lib/net/ssh/version.rb
89
+ net-ssh.gemspec
90
+ setup.rb
91
+ support/arcfour_check.rb
92
+ test/authentication/methods/common.rb
93
+ test/authentication/methods/test_abstract.rb
94
+ test/authentication/methods/test_hostbased.rb
95
+ test/authentication/methods/test_keyboard_interactive.rb
96
+ test/authentication/methods/test_password.rb
97
+ test/authentication/methods/test_publickey.rb
98
+ test/authentication/test_agent.rb
99
+ test/authentication/test_key_manager.rb
100
+ test/authentication/test_session.rb
101
+ test/common.rb
102
+ test/configs/eqsign
103
+ test/configs/exact_match
104
+ test/configs/multihost
105
+ test/configs/wild_cards
106
+ test/connection/test_channel.rb
107
+ test/connection/test_session.rb
108
+ test/test_all.rb
109
+ test/test_buffer.rb
110
+ test/test_buffered_io.rb
111
+ test/test_config.rb
112
+ test/test_key_factory.rb
113
+ test/transport/hmac/test_md5.rb
114
+ test/transport/hmac/test_md5_96.rb
115
+ test/transport/hmac/test_none.rb
116
+ test/transport/hmac/test_sha1.rb
117
+ test/transport/hmac/test_sha1_96.rb
118
+ test/transport/kex/test_diffie_hellman_group1_sha1.rb
119
+ test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb
120
+ test/transport/test_algorithms.rb
121
+ test/transport/test_cipher_factory.rb
122
+ test/transport/test_hmac.rb
123
+ test/transport/test_identity_cipher.rb
124
+ test/transport/test_packet_stream.rb
125
+ test/transport/test_server_version.rb
126
+ test/transport/test_session.rb
127
+ test/transport/test_state.rb
128
+ )
24
129
 
25
- if current_version >= 3 then
26
- s.add_development_dependency(%q<echoe>, [">= 0"])
27
- else
28
- s.add_dependency(%q<echoe>, [">= 0"])
29
- end
30
- else
31
- s.add_dependency(%q<echoe>, [">= 0"])
32
- end
130
+
33
131
  end
@@ -0,0 +1,20 @@
1
+
2
+ require 'net/ssh'
3
+
4
+ # ARCFOUR CHECK
5
+ #
6
+ # Usage:
7
+ # $ ruby support/arcfour_check.rb
8
+ #
9
+ # Expected Output:
10
+ # arcfour128: [16, 8] OpenSSL::Cipher::Cipher
11
+ # arcfour256: [32, 8] OpenSSL::Cipher::Cipher
12
+ # arcfour512: [64, 8] OpenSSL::Cipher::Cipher
13
+
14
+ [['arcfour128', 16], ['arcfour256', 32], ['arcfour512', 64]].each do |cipher|
15
+ print "#{cipher[0]}: "
16
+ a = Net::SSH::Transport::CipherFactory.get_lengths(cipher[0])
17
+ b = Net::SSH::Transport::CipherFactory.get(cipher[0], :key => ([].fill('x', 0, cipher[1]).join))
18
+ puts "#{a} #{b.class}"
19
+ end
20
+
@@ -1,4 +1,5 @@
1
1
  $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2
+ gem "test-unit" # http://rubyforge.org/pipermail/test-unit-tracker/2009-July/000075.html
2
3
  require 'test/unit'
3
4
  require 'mocha'
4
5
  require 'net/ssh/buffer'
@@ -0,0 +1,4 @@
1
+ Host other.host, test.host
2
+ Compression yes
3
+ Port 1980
4
+ RekeyLimit 2G
@@ -1,3 +1,5 @@
1
+ # $ ruby -Ilib -Itest -rrubygems test/test_all.rb
2
+ # $ ruby -Ilib -Itest -rrubygems test/transport/test_server_version.rb
1
3
  Dir.chdir(File.dirname(__FILE__)) do
2
4
  test_files = Dir['**/test_*.rb']
3
5
  test_files = test_files.select { |f| f =~ Regexp.new(ENV['ONLY']) } if ENV['ONLY']
@@ -37,7 +37,22 @@ class TestConfig < Test::Unit::TestCase
37
37
  assert_equal %w(~/.ssh/id_dsa), config[:keys]
38
38
  assert !config.key?(:rekey_limit)
39
39
  end
40
-
40
+
41
+ def test_load_with_multiple_hosts
42
+ config = Net::SSH::Config.load(config(:multihost), "test.host")
43
+ assert config['compression']
44
+ assert_equal '2G', config['rekeylimit']
45
+ assert_equal 1980, config['port']
46
+ end
47
+
48
+ def test_load_with_multiple_hosts_and_config_should_match_for_both
49
+ aconfig = Net::SSH::Config.load(config(:multihost), "test.host")
50
+ bconfig = Net::SSH::Config.load(config(:multihost), "other.host")
51
+ assert_equal aconfig['port'], bconfig['port']
52
+ assert_equal aconfig['compression'], bconfig['compression']
53
+ assert_equal aconfig['rekeylimit'], bconfig['rekeylimit']
54
+ end
55
+
41
56
  def test_load_should_parse_equal_sign_delimiters
42
57
  config = Net::SSH::Config.load(config(:eqsign), "test.test")
43
58
  assert config['compression']
@@ -19,7 +19,7 @@ module Transport
19
19
  def test_constructor_should_build_default_list_of_preferred_algorithms
20
20
  assert_equal %w(ssh-rsa ssh-dss), algorithms[:host_key]
21
21
  assert_equal %w(diffie-hellman-group-exchange-sha1 diffie-hellman-group1-sha1), algorithms[:kex]
22
- assert_equal %w(aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc aes256-cbc rijndael-cbc@lysator.liu.se idea-cbc none), algorithms[:encryption]
22
+ assert_equal %w(aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc aes256-cbc rijndael-cbc@lysator.liu.se idea-cbc none arcfour128 arcfour256), algorithms[:encryption]
23
23
  assert_equal %w(hmac-sha1 hmac-md5 hmac-sha1-96 hmac-md5-96 none), algorithms[:hmac]
24
24
  assert_equal %w(none zlib@openssh.com zlib), algorithms[:compression]
25
25
  assert_equal %w(), algorithms[:language]
@@ -54,11 +54,11 @@ module Transport
54
54
  end
55
55
 
56
56
  def test_constructor_with_preferred_encryption_should_put_preferred_encryption_first
57
- assert_equal %w(aes256-cbc aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc rijndael-cbc@lysator.liu.se idea-cbc none), algorithms(:encryption => "aes256-cbc")[:encryption]
57
+ assert_equal %w(aes256-cbc aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc rijndael-cbc@lysator.liu.se idea-cbc none arcfour128 arcfour256), algorithms(:encryption => "aes256-cbc")[:encryption]
58
58
  end
59
59
 
60
60
  def test_constructor_with_multiple_preferred_encryption_should_put_all_preferred_encryption_first
61
- assert_equal %w(aes256-cbc 3des-cbc idea-cbc aes128-cbc blowfish-cbc cast128-cbc aes192-cbc rijndael-cbc@lysator.liu.se none), algorithms(:encryption => %w(aes256-cbc 3des-cbc idea-cbc))[:encryption]
61
+ assert_equal %w(aes256-cbc 3des-cbc idea-cbc aes128-cbc blowfish-cbc cast128-cbc aes192-cbc rijndael-cbc@lysator.liu.se none arcfour128 arcfour256), algorithms(:encryption => %w(aes256-cbc 3des-cbc idea-cbc))[:encryption]
62
62
  end
63
63
 
64
64
  def test_constructor_with_unrecognized_encryption_should_raise_exception
@@ -268,8 +268,8 @@ module Transport
268
268
  assert_equal 16, buffer.read(16).length
269
269
  assert_equal options[:kex] || "diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1", buffer.read_string
270
270
  assert_equal options[:host_key] || "ssh-rsa,ssh-dss", buffer.read_string
271
- assert_equal options[:encryption_client] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc,none", buffer.read_string
272
- assert_equal options[:encryption_server] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc,none", buffer.read_string
271
+ assert_equal options[:encryption_client] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc,none,arcfour128,arcfour256", buffer.read_string
272
+ assert_equal options[:encryption_server] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc,none,arcfour128,arcfour256", buffer.read_string
273
273
  assert_equal options[:hmac_client] || "hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96,none", buffer.read_string
274
274
  assert_equal options[:hmac_server] || "hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96,none", buffer.read_string
275
275
  assert_equal options[:compression_client] || "none,zlib@openssh.com,zlib", buffer.read_string
@@ -47,6 +47,18 @@ module Transport
47
47
  assert_equal [32,16], factory.get_lengths("aes256-cbc")
48
48
  end
49
49
 
50
+ def test_lengths_for_arcfour128
51
+ assert_equal [16,8], factory.get_lengths("arcfour128")
52
+ end
53
+
54
+ def test_lengths_for_arcfour256
55
+ assert_equal [32,8], factory.get_lengths("arcfour256")
56
+ end
57
+
58
+ def test_lengths_for_arcfour512
59
+ assert_equal [64,8], factory.get_lengths("arcfour512")
60
+ end
61
+
50
62
  BLOWFISH = "\210\021\200\315\240_\026$\352\204g\233\244\242x\332e\370\001\327\224Nv@9_\323\037\252kb\037\036\237\375]\343/y\037\237\312Q\f7]\347Y\005\275%\377\0010$G\272\250B\265Nd\375\342\372\025r6}+Y\213y\n\237\267\\\374^\346BdJ$\353\220Ik\023<\236&H\277=\225"
51
63
 
52
64
  def test_blowfish_cbc_for_encryption
@@ -128,7 +140,37 @@ module Transport
128
140
  def test_aes256_cbc_for_decryption
129
141
  assert_equal TEXT, decrypt("aes256-cbc", AES256)
130
142
  end
143
+
144
+ ARCFOUR128 = "\n\x90\xED*\xD4\xBE\xCBg5\xA5\a\xEC]\x97\xB7L\x06)6\x12FL\x90@\xF4Sqxqh\r\x11\x1Aq \xC8\xE6v\xC6\x12\xD9<A\xDAZ\xFE\x7F\x88\x19f.\x06\xA7\xFE:\xFF\x93\x9B\x8D\xA0\\\x9E\xCA\x03\x15\xE1\xE2\f\xC0\b\xA2C\xE1\xBD\xB6\x13D\xD1\xB4'g\x89\xDC\xEB\f\x19Z)U"
145
+
146
+ def test_arcfour128_for_encryption
147
+ assert_equal ARCFOUR128, encrypt("arcfour128")
148
+ end
149
+
150
+ def test_arcfour128_for_decryption
151
+ assert_equal TEXT, decrypt("arcfour128", ARCFOUR128)
152
+ end
153
+
154
+ ARCFOUR256 = "|g\xCCw\xF5\xC1y\xEB\xF0\v\xF7\x83\x14\x03\xC8\xAB\xE8\xC2\xFCY\xDC,\xB8\xD4dVa\x8B\x18%\xA4S\x00\xE0at\x86\xE8\xA6W\xAB\xD2\x9D\xA8\xDE[g\aZy.\xFB\xFC\x82c\x04h\f\xBFYq\xB7U\x80\x0EG\x91\x88\xDF\xA3\xA2\xFA(\xEC\xDB\xA4\xE7\xFE)\x12u\xAF\x0EZ\xA0\xBA\x97\n\xFC"
131
155
 
156
+ def test_arcfour256_for_encryption
157
+ assert_equal ARCFOUR256, encrypt("arcfour256")
158
+ end
159
+
160
+ def test_arcfour256_for_decryption
161
+ assert_equal TEXT, decrypt("arcfour256", ARCFOUR256)
162
+ end
163
+
164
+ ARCFOUR512 = "|8\"v\xE7\xE3\b\xA8\x19\x9Aa\xB6Vv\x00\x11\x8A$C\xB6xE\xEF\xF1j\x90\xA8\xFA\x10\xE4\xA1b8\xF6\x04\xF2+\xC0\xD1(8\xEBT]\xB0\xF3/\xD9\xE0@\x83\a\x93\x9D\xCA\x04RXS\xB7A\x0Fj\x94\bE\xEB\x84j\xB4\xDF\nU\xF7\x83o\n\xE8\xF9\x01{jH\xEE\xCDQym\x9E"
165
+
166
+ def test_arcfour512_for_encryption
167
+ assert_equal ARCFOUR512, encrypt("arcfour512")
168
+ end
169
+
170
+ def test_arcfour512_for_decryption
171
+ assert_equal TEXT, decrypt("arcfour512", ARCFOUR512)
172
+ end
173
+
132
174
  def test_none_for_encryption
133
175
  assert_equal TEXT, encrypt("none").strip
134
176
  end
@@ -136,7 +178,7 @@ module Transport
136
178
  def test_none_for_decryption
137
179
  assert_equal TEXT, decrypt("none", TEXT)
138
180
  end
139
-
181
+
140
182
  private
141
183
 
142
184
  TEXT = "But soft! What light through yonder window breaks? It is the east, and Juliet is the sun!"
@@ -371,12 +371,18 @@ module Transport
371
371
 
372
372
  ciphers.each do |cipher_name|
373
373
  next unless Net::SSH::Transport::CipherFactory.supported?(cipher_name)
374
-
374
+
375
+ # TODO: How are the expected packets generated?
376
+ if cipher_name =~ /arcfour/
377
+ puts "Skipping packet stream test for #{cipher_name}"
378
+ next
379
+ end
380
+
375
381
  hmacs.each do |hmac_name|
376
382
  [false, :standard].each do |compress|
377
383
  cipher_method_name = cipher_name.gsub(/\W/, "_")
378
384
  hmac_method_name = hmac_name.gsub(/\W/, "_")
379
-
385
+
380
386
  define_method("test_next_packet_with_#{cipher_method_name}_and_#{hmac_method_name}_and_#{compress}_compression") do
381
387
  cipher = Net::SSH::Transport::CipherFactory.get(cipher_name, :key => "ABC", :iv => "abc", :shared => "123", :digester => OpenSSL::Digest::SHA1, :hash => "^&*", :decrypt => true)
382
388
  hmac = Net::SSH::Transport::HMAC.get(hmac_name, "{}|")
@@ -29,19 +29,30 @@ module Transport
29
29
  end
30
30
 
31
31
  def test_header_lines_should_be_accumulated
32
- s = subject(socket(true, "Welcome\r\n", "Another line\r\n", "SSH-2.0-Testing_1.0\r\n"))
32
+ s = subject(socket(true, "Welcome\r\nAnother line\r\nSSH-2.0-Testing_1.0\r\n"))
33
33
  assert_equal "Welcome\r\nAnother line\r\n", s.header
34
34
  assert_equal "SSH-2.0-Testing_1.0", s.version
35
35
  end
36
36
 
37
+ def test_server_disconnect_should_raise_exception
38
+ assert_raises(Net::SSH::Disconnect) { subject(socket(false, "SSH-2.0-Aborting")) }
39
+ end
40
+
37
41
  private
38
42
 
39
- def socket(good, *lines)
43
+ def socket(good, version_header)
40
44
  socket = mock("socket")
41
- socket.expects(:readline).times(lines.length).returns(*lines)
45
+
46
+ data = version_header.split('')
47
+ recv_times = data.length
48
+ if data[-1] != "\n"
49
+ recv_times += 1
50
+ end
51
+ socket.expects(:recv).with(1).times(recv_times).returns(*data).then.returns(nil)
42
52
 
43
53
  if good
44
54
  socket.expects(:write).with("#{Net::SSH::Transport::ServerVersion::PROTO_VERSION}\r\n")
55
+ socket.expects(:flush)
45
56
  else
46
57
  socket.expects(:write).never
47
58
  end
@@ -54,4 +65,4 @@ module Transport
54
65
  end
55
66
  end
56
67
 
57
- end
68
+ end
metadata CHANGED
@@ -1,101 +1,39 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.11
4
+ version: 2.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck
8
+ - Delano Mandelbaum
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2009-02-24 00:00:00 -07:00
13
+ date: 2009-08-17 00:00:00 -04:00
13
14
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: echoe
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
25
- description: a pure-Ruby implementation of the SSH2 client protocol
26
- email: jamis@jamisbuck.org
15
+ dependencies: []
16
+
17
+ description: "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol."
18
+ email:
19
+ - net-ssh@solutious.com
20
+ - net-ssh@solutious.com
27
21
  executables: []
28
22
 
29
23
  extensions: []
30
24
 
31
25
  extra_rdoc_files:
32
- - CHANGELOG.rdoc
33
- - lib/net/ssh/authentication/agent.rb
34
- - lib/net/ssh/authentication/constants.rb
35
- - lib/net/ssh/authentication/key_manager.rb
36
- - lib/net/ssh/authentication/methods/abstract.rb
37
- - lib/net/ssh/authentication/methods/hostbased.rb
38
- - lib/net/ssh/authentication/methods/keyboard_interactive.rb
39
- - lib/net/ssh/authentication/methods/password.rb
40
- - lib/net/ssh/authentication/methods/publickey.rb
41
- - lib/net/ssh/authentication/pageant.rb
42
- - lib/net/ssh/authentication/session.rb
43
- - lib/net/ssh/buffer.rb
44
- - lib/net/ssh/buffered_io.rb
45
- - lib/net/ssh/config.rb
46
- - lib/net/ssh/connection/channel.rb
47
- - lib/net/ssh/connection/constants.rb
48
- - lib/net/ssh/connection/session.rb
49
- - lib/net/ssh/connection/term.rb
50
- - lib/net/ssh/errors.rb
51
- - lib/net/ssh/key_factory.rb
52
- - lib/net/ssh/known_hosts.rb
53
- - lib/net/ssh/loggable.rb
54
- - lib/net/ssh/packet.rb
55
- - lib/net/ssh/prompt.rb
56
- - lib/net/ssh/proxy/errors.rb
57
- - lib/net/ssh/proxy/http.rb
58
- - lib/net/ssh/proxy/socks4.rb
59
- - lib/net/ssh/proxy/socks5.rb
60
- - lib/net/ssh/ruby_compat.rb
61
- - lib/net/ssh/service/forward.rb
62
- - lib/net/ssh/test/channel.rb
63
- - lib/net/ssh/test/extensions.rb
64
- - lib/net/ssh/test/kex.rb
65
- - lib/net/ssh/test/local_packet.rb
66
- - lib/net/ssh/test/packet.rb
67
- - lib/net/ssh/test/remote_packet.rb
68
- - lib/net/ssh/test/script.rb
69
- - lib/net/ssh/test/socket.rb
70
- - lib/net/ssh/test.rb
71
- - lib/net/ssh/transport/algorithms.rb
72
- - lib/net/ssh/transport/cipher_factory.rb
73
- - lib/net/ssh/transport/constants.rb
74
- - lib/net/ssh/transport/hmac/abstract.rb
75
- - lib/net/ssh/transport/hmac/md5.rb
76
- - lib/net/ssh/transport/hmac/md5_96.rb
77
- - lib/net/ssh/transport/hmac/none.rb
78
- - lib/net/ssh/transport/hmac/sha1.rb
79
- - lib/net/ssh/transport/hmac/sha1_96.rb
80
- - lib/net/ssh/transport/hmac.rb
81
- - lib/net/ssh/transport/identity_cipher.rb
82
- - lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb
83
- - lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb
84
- - lib/net/ssh/transport/kex.rb
85
- - lib/net/ssh/transport/openssl.rb
86
- - lib/net/ssh/transport/packet_stream.rb
87
- - lib/net/ssh/transport/server_version.rb
88
- - lib/net/ssh/transport/session.rb
89
- - lib/net/ssh/transport/state.rb
90
- - lib/net/ssh/verifiers/lenient.rb
91
- - lib/net/ssh/verifiers/null.rb
92
- - lib/net/ssh/verifiers/strict.rb
93
- - lib/net/ssh/version.rb
94
- - lib/net/ssh.rb
95
26
  - README.rdoc
96
27
  - THANKS.rdoc
28
+ - CHANGELOG.rdoc
97
29
  files:
98
30
  - CHANGELOG.rdoc
31
+ - Manifest
32
+ - README.rdoc
33
+ - Rakefile
34
+ - Rudyfile
35
+ - THANKS.rdoc
36
+ - lib/net/ssh.rb
99
37
  - lib/net/ssh/authentication/agent.rb
100
38
  - lib/net/ssh/authentication/constants.rb
101
39
  - lib/net/ssh/authentication/key_manager.rb
@@ -125,6 +63,7 @@ files:
125
63
  - lib/net/ssh/proxy/socks5.rb
126
64
  - lib/net/ssh/ruby_compat.rb
127
65
  - lib/net/ssh/service/forward.rb
66
+ - lib/net/ssh/test.rb
128
67
  - lib/net/ssh/test/channel.rb
129
68
  - lib/net/ssh/test/extensions.rb
130
69
  - lib/net/ssh/test/kex.rb
@@ -133,21 +72,20 @@ files:
133
72
  - lib/net/ssh/test/remote_packet.rb
134
73
  - lib/net/ssh/test/script.rb
135
74
  - lib/net/ssh/test/socket.rb
136
- - lib/net/ssh/test.rb
137
75
  - lib/net/ssh/transport/algorithms.rb
138
76
  - lib/net/ssh/transport/cipher_factory.rb
139
77
  - lib/net/ssh/transport/constants.rb
78
+ - lib/net/ssh/transport/hmac.rb
140
79
  - lib/net/ssh/transport/hmac/abstract.rb
141
80
  - lib/net/ssh/transport/hmac/md5.rb
142
81
  - lib/net/ssh/transport/hmac/md5_96.rb
143
82
  - lib/net/ssh/transport/hmac/none.rb
144
83
  - lib/net/ssh/transport/hmac/sha1.rb
145
84
  - lib/net/ssh/transport/hmac/sha1_96.rb
146
- - lib/net/ssh/transport/hmac.rb
147
85
  - lib/net/ssh/transport/identity_cipher.rb
86
+ - lib/net/ssh/transport/kex.rb
148
87
  - lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb
149
88
  - lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb
150
- - lib/net/ssh/transport/kex.rb
151
89
  - lib/net/ssh/transport/openssl.rb
152
90
  - lib/net/ssh/transport/packet_stream.rb
153
91
  - lib/net/ssh/transport/server_version.rb
@@ -157,12 +95,9 @@ files:
157
95
  - lib/net/ssh/verifiers/null.rb
158
96
  - lib/net/ssh/verifiers/strict.rb
159
97
  - lib/net/ssh/version.rb
160
- - lib/net/ssh.rb
161
- - Manifest
162
98
  - net-ssh.gemspec
163
- - Rakefile
164
- - README.rdoc
165
99
  - setup.rb
100
+ - support/arcfour_check.rb
166
101
  - test/authentication/methods/common.rb
167
102
  - test/authentication/methods/test_abstract.rb
168
103
  - test/authentication/methods/test_hostbased.rb
@@ -175,6 +110,7 @@ files:
175
110
  - test/common.rb
176
111
  - test/configs/eqsign
177
112
  - test/configs/exact_match
113
+ - test/configs/multihost
178
114
  - test/configs/wild_cards
179
115
  - test/connection/test_channel.rb
180
116
  - test/connection/test_session.rb
@@ -198,15 +134,15 @@ files:
198
134
  - test/transport/test_server_version.rb
199
135
  - test/transport/test_session.rb
200
136
  - test/transport/test_state.rb
201
- - THANKS.rdoc
202
137
  has_rdoc: true
203
- homepage: http://net-ssh.rubyforge.org/ssh
138
+ homepage: http://rubyforge.org/projects/net-ssh/
139
+ licenses: []
140
+
204
141
  post_install_message:
205
142
  rdoc_options:
206
143
  - --line-numbers
207
- - --inline-source
208
144
  - --title
209
- - Net-ssh
145
+ - "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol."
210
146
  - --main
211
147
  - README.rdoc
212
148
  require_paths:
@@ -221,14 +157,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
157
  requirements:
222
158
  - - ">="
223
159
  - !ruby/object:Gem::Version
224
- version: "1.2"
160
+ version: "0"
225
161
  version:
226
162
  requirements: []
227
163
 
228
164
  rubyforge_project: net-ssh
229
- rubygems_version: 1.2.0
165
+ rubygems_version: 1.3.2
230
166
  signing_key:
231
- specification_version: 2
232
- summary: a pure-Ruby implementation of the SSH2 client protocol
233
- test_files:
234
- - test/test_all.rb
167
+ specification_version: 3
168
+ summary: "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol."
169
+ test_files: []
170
+