net-ssh 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,14 @@
1
+ === 2.0.5 / 6 December 2008
2
+
3
+ * Make the Pageant interface comply with more of the Socket interface to avoid related errors [Jamis Buck]
4
+
5
+ * Don't busy-wait on session close for remaining channels to close [Will Bryant]
6
+
7
+ * Ruby 1.9 compatibility [Jamis Buck]
8
+
9
+ * Fix Cipher#final to correctly flag a need for a cipher reset [Jamis Buck]
10
+
11
+
1
12
  === 2.0.4 / 27 Aug 2008
2
13
 
3
14
  * Added Connection::Session#closed? and Transport::Session#closed? [Jamis Buck]
@@ -156,6 +156,13 @@ module Net; module SSH; module Authentication
156
156
  @pos = 0
157
157
  end
158
158
 
159
+ # Conceptually asks if the socket is closed. As with #close,
160
+ # this doesn't really do anything significant, but merely
161
+ # complies with the Socket interface.
162
+ def closed?
163
+ @res.nil? && @pos.zero?
164
+ end
165
+
159
166
  # Reads +n+ bytes from the cached result of the last query. If +n+
160
167
  # is +nil+, returns all remaining data from the last query.
161
168
  def read(n = nil)
@@ -1,3 +1,4 @@
1
+ require 'net/ssh/ruby_compat'
1
2
  require 'net/ssh/transport/openssl'
2
3
 
3
4
  module Net; module SSH
@@ -203,7 +204,7 @@ module Net; module SSH
203
204
  # the end of the buffer.
204
205
  def read_byte
205
206
  b = read(1) or return nil
206
- b[0]
207
+ b.getbyte(0)
207
208
  end
208
209
 
209
210
  # Read and return an SSH2-encoded string. The string starts with a long
@@ -96,7 +96,7 @@ module Net; module SSH; module Connection
96
96
  def close
97
97
  info { "closing remaining channels (#{channels.length} open)" }
98
98
  channels.each { |id, channel| channel.close }
99
- loop(0) { channels.any? }
99
+ loop { channels.any? }
100
100
  transport.close
101
101
  end
102
102
 
@@ -178,7 +178,7 @@ module Net; module SSH; module Connection
178
178
  return false unless preprocess(&block)
179
179
 
180
180
  r = listeners.keys
181
- w = r.select { |w| w.respond_to?(:pending_write?) && w.pending_write? }
181
+ w = r.select { |w2| w2.respond_to?(:pending_write?) && w2.pending_write? }
182
182
  readers, writers, = IO.select(r, w, nil, wait)
183
183
 
184
184
  postprocess(readers, writers)
@@ -302,17 +302,17 @@ module Net; module SSH; module Connection
302
302
  channel.exec(command) do |ch, success|
303
303
  raise "could not execute command: #{command.inspect}" unless success
304
304
 
305
- channel.on_data do |ch, data|
305
+ channel.on_data do |ch2, data|
306
306
  if block
307
- block.call(ch, :stdout, data)
307
+ block.call(ch2, :stdout, data)
308
308
  else
309
309
  $stdout.print(data)
310
310
  end
311
311
  end
312
312
 
313
- channel.on_extended_data do |ch, type, data|
313
+ channel.on_extended_data do |ch2, type, data|
314
314
  if block
315
- block.call(ch, :stderr, data)
315
+ block.call(ch2, :stderr, data)
316
316
  else
317
317
  $stderr.print(data)
318
318
  end
@@ -1,4 +1,5 @@
1
1
  require 'socket'
2
+ require 'net/ssh/ruby_compat'
2
3
  require 'net/ssh/proxy/errors'
3
4
 
4
5
  module Net
@@ -95,7 +96,7 @@ module Net
95
96
  socket.send packet, 0
96
97
 
97
98
  version, reply, = socket.recv(4).unpack("C*")
98
- len = socket.recv(1)[0]
99
+ len = socket.recv(1).getbyte(0)
99
100
  socket.recv(len + 2)
100
101
 
101
102
  unless reply == SUCCESS
@@ -64,12 +64,12 @@ module Net; module SSH; module Service
64
64
 
65
65
  @local_forwarded_ports[[local_port, bind_address]] = socket
66
66
 
67
- session.listen_to(socket) do |socket|
68
- client = socket.accept
67
+ session.listen_to(socket) do |server|
68
+ client = server.accept
69
69
  debug { "received connection on #{bind_address}:#{local_port}" }
70
70
 
71
- channel = session.open_channel("direct-tcpip", :string, remote_host, :long, remote_port, :string, bind_address, :long, local_port) do |channel|
72
- channel.info { "direct channel established" }
71
+ channel = session.open_channel("direct-tcpip", :string, remote_host, :long, remote_port, :string, bind_address, :long, local_port) do |achannel|
72
+ achannel.info { "direct channel established" }
73
73
  end
74
74
 
75
75
  prepare_client(client, channel, :local)
@@ -177,12 +177,12 @@ module Net; module SSH; module Service
177
177
  return if @agent_forwarded
178
178
  @agent_forwarded = true
179
179
 
180
- channel.send_channel_request("auth-agent-req@openssh.com") do |channel, success|
180
+ channel.send_channel_request("auth-agent-req@openssh.com") do |achannel, success|
181
181
  if success
182
182
  debug { "authentication agent forwarding is active" }
183
183
  else
184
- channel.send_channel_request("auth-agent-req") do |channel, success|
185
- if success
184
+ achannel.send_channel_request("auth-agent-req") do |a2channel, success2|
185
+ if success2
186
186
  debug { "authentication agent forwarding is active" }
187
187
  else
188
188
  error { "could not establish forwarding of authentication agent" }
@@ -18,6 +18,14 @@ module Net; module SSH; module Transport
18
18
  "none" => "none"
19
19
  }
20
20
 
21
+ # Returns true if the underlying OpenSSL library supports the given cipher,
22
+ # and false otherwise.
23
+ def self.supported?(name)
24
+ ossl_name = SSH_TO_OSSL[name] or raise NotImplementedError, "unimplemented cipher `#{name}'"
25
+ return true if ossl_name == "none"
26
+ return OpenSSL::Cipher.ciphers.include?(ossl_name)
27
+ end
28
+
21
29
  # Retrieves a new instance of the named algorithm. The new instance
22
30
  # will be initialized using an iv and key generated from the given
23
31
  # iv, key, shared, hash and digester values. Additionally, the
@@ -6,29 +6,53 @@ module Net; module SSH; module Transport; module HMAC
6
6
  class Abstract
7
7
 
8
8
  class <<self
9
- %w(key_length mac_length digest_class).each do |attribute|
10
- define_method(attribute) do |*v|
11
- # satisfy ruby -w
12
- if !instance_variables.include?("@#{attribute}")
13
- instance_variable_set("@#{attribute}", nil)
14
- end
15
-
16
- if v.empty?
17
- v = instance_variable_get("@#{attribute}")
18
- if v.nil? && superclass.respond_to?(attribute)
19
- v = superclass.send(attribute)
20
- instance_variable_set("@#{attribute}", v)
21
- end
22
- v
23
- else
24
- instance_variable_set("@#{attribute}", v.first)
25
- end
9
+ def key_length(*v)
10
+ @key_length = nil if !defined?(@key_length)
11
+ if v.empty?
12
+ @key_length = superclass.key_length if @key_length.nil? && superclass.respond_to?(:key_length)
13
+ return @key_length
14
+ elsif v.length == 1
15
+ @key_length = v.first
16
+ else
17
+ raise ArgumentError, "wrong number of arguments (#{v.length} for 1)"
26
18
  end
27
19
  end
20
+
21
+ def mac_length(*v)
22
+ @mac_length = nil if !defined?(@mac_length)
23
+ if v.empty?
24
+ @mac_length = superclass.mac_length if @mac_length.nil? && superclass.respond_to?(:mac_length)
25
+ return @mac_length
26
+ elsif v.length == 1
27
+ @mac_length = v.first
28
+ else
29
+ raise ArgumentError, "wrong number of arguments (#{v.length} for 1)"
30
+ end
31
+ end
32
+
33
+ def digest_class(*v)
34
+ @digest_class = nil if !defined?(@digest_class)
35
+ if v.empty?
36
+ @digest_class = superclass.digest_class if @digest_class.nil? && superclass.respond_to?(:digest_class)
37
+ return @digest_class
38
+ elsif v.length == 1
39
+ @digest_class = v.first
40
+ else
41
+ raise ArgumentError, "wrong number of arguments (#{v.length} for 1)"
42
+ end
43
+ end
44
+ end
45
+
46
+ def key_length
47
+ self.class.key_length
48
+ end
49
+
50
+ def mac_length
51
+ self.class.mac_length
28
52
  end
29
53
 
30
- %w(key_length mac_length digest_class).each do |attribute|
31
- define_method(attribute) { self.class.send(attribute) }
54
+ def digest_class
55
+ self.class.digest_class
32
56
  end
33
57
 
34
58
  # The key in use for this instance.
@@ -39,6 +39,16 @@ module Net; module SSH; module Transport
39
39
  def name
40
40
  "identity"
41
41
  end
42
+
43
+ # Does nothing. Returns nil.
44
+ def iv=(v)
45
+ nil
46
+ end
47
+
48
+ # Does nothing. Returns self.
49
+ def reset
50
+ self
51
+ end
42
52
  end
43
53
  end
44
54
 
@@ -15,7 +15,7 @@ module OpenSSL
15
15
  return [0].pack("N")
16
16
  else
17
17
  buf = to_s(2)
18
- if buf[0][7] == 1
18
+ if buf.getbyte(0)[7] == 1
19
19
  return [buf.length+1, 0, buf].pack("NCA*")
20
20
  else
21
21
  return [buf.length, buf].pack("NA*")
@@ -137,7 +137,7 @@ module Net; module SSH; module Transport
137
137
  encrypted_data = client.update_cipher(unencrypted_data) << client.final_cipher
138
138
  message = encrypted_data + mac
139
139
 
140
- debug { "queueing packet nr #{client.sequence_number} type #{payload[0]} len #{packet_length}" }
140
+ debug { "queueing packet nr #{client.sequence_number} type #{payload.getbyte(0)} len #{packet_length}" }
141
141
  enqueue(message)
142
142
 
143
143
  client.increment(packet_length)
@@ -169,8 +169,8 @@ module Net; module SSH; module Transport
169
169
  # the states and generally prepares the object for use as a packet stream.
170
170
  def initialize_ssh
171
171
  @hints = {}
172
- @server = State.new(self)
173
- @client = State.new(self)
172
+ @server = State.new(self, :server)
173
+ @client = State.new(self, :client)
174
174
  @packet = nil
175
175
  initialize_buffered_io
176
176
  end
@@ -218,7 +218,7 @@ module Net; module SSH; module Transport
218
218
  # try to decompress the payload, in case compression is active
219
219
  payload = server.decompress(payload)
220
220
 
221
- debug { "received packet nr #{server.sequence_number} type #{payload[0]} len #{@packet_length}" }
221
+ debug { "received packet nr #{server.sequence_number} type #{payload.getbyte(0)} len #{@packet_length}" }
222
222
 
223
223
  server.increment(@packet_length)
224
224
  @packet = nil
@@ -31,6 +31,12 @@ module Net; module SSH; module Transport
31
31
  # The number of data blocks processed since the last call to #reset!
32
32
  attr_reader :blocks
33
33
 
34
+ # The cipher algorithm in use for this socket endpoint.
35
+ attr_reader :cipher
36
+
37
+ # The role that this state plays (either :client or :server)
38
+ attr_reader :role
39
+
34
40
  # The maximum number of packets that this endpoint wants to process before
35
41
  # needing a rekey.
36
42
  attr_accessor :max_packets
@@ -45,15 +51,15 @@ module Net; module SSH; module Transport
45
51
 
46
52
  # Creates a new state object, belonging to the given socket. Initializes
47
53
  # the algorithms to "none".
48
- def initialize(socket)
54
+ def initialize(socket, role)
49
55
  @socket = socket
56
+ @role = role
50
57
  @sequence_number = @packets = @blocks = 0
51
58
  @cipher = CipherFactory.get("none")
52
59
  @hmac = HMAC.get("none")
53
60
  @compression = nil
54
61
  @compressor = @decompressor = nil
55
- @next_iv = nil
56
- @cipher_needs_reset = false
62
+ @next_iv = ""
57
63
  end
58
64
 
59
65
  # A convenience method for quickly setting multiple values in a single
@@ -65,25 +71,16 @@ module Net; module SSH; module Transport
65
71
  reset!
66
72
  end
67
73
 
68
- # The cipher algorithm in use for this socket endpoint.
69
- def cipher
70
- if @cipher_needs_reset
71
- @cipher.reset
72
- @cipher.iv = @next_iv
73
- @cipher_needs_reset = false
74
- end
75
-
76
- @cipher
77
- end
78
-
79
74
  def update_cipher(data)
80
- @next_iv = data[-cipher.iv_len..-1]
81
- cipher.update(data)
75
+ result = cipher.update(data)
76
+ update_next_iv(role == :client ? result : data)
77
+ return result
82
78
  end
83
79
 
84
80
  def final_cipher
85
- @cipher_needs_reset
86
- cipher.final
81
+ result = cipher.final
82
+ update_next_iv(role == :client ? result : "", true)
83
+ return result
87
84
  end
88
85
 
89
86
  # Increments the counters. The sequence number is incremented (and remapped
@@ -185,6 +182,20 @@ module Net; module SSH; module Transport
185
182
  max_packets && packets > max_packets ||
186
183
  max_blocks && blocks > max_blocks
187
184
  end
185
+
186
+ private
187
+
188
+ def update_next_iv(data, reset=false)
189
+ @next_iv << data
190
+ @next_iv = @next_iv[-cipher.iv_len..-1]
191
+
192
+ if reset
193
+ cipher.reset
194
+ cipher.iv = @next_iv
195
+ end
196
+
197
+ return data
198
+ end
188
199
  end
189
200
 
190
201
  end; end; end
@@ -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 = 4
54
+ TINY = 5
55
55
 
56
56
  # The current version of the Net::SSH library as a Version instance
57
57
  CURRENT = new(MAJOR, MINOR, TINY)
@@ -1,14 +1,10 @@
1
-
2
- # Gem::Specification for Net-ssh-2.0.4
3
- # Originally generated by Echoe
4
-
5
1
  Gem::Specification.new do |s|
6
2
  s.name = %q{net-ssh}
7
- s.version = "2.0.4"
3
+ s.version = "2.0.5"
8
4
 
9
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
10
6
  s.authors = ["Jamis Buck"]
11
- s.date = %q{2008-08-27}
7
+ s.date = %q{2008-12-06}
12
8
  s.description = %q{a pure-Ruby implementation of the SSH2 client protocol}
13
9
  s.email = %q{jamis@jamisbuck.org}
14
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/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"]
@@ -27,38 +23,11 @@ Gem::Specification.new do |s|
27
23
  s.specification_version = 2
28
24
 
29
25
  if current_version >= 3 then
26
+ s.add_development_dependency(%q<echoe>, [">= 0"])
30
27
  else
28
+ s.add_dependency(%q<echoe>, [">= 0"])
31
29
  end
32
30
  else
31
+ s.add_dependency(%q<echoe>, [">= 0"])
33
32
  end
34
33
  end
35
-
36
-
37
- # # Original Rakefile source (requires the Echoe gem):
38
- #
39
- # require './lib/net/ssh/version'
40
- #
41
- # begin
42
- # require 'echoe'
43
- # rescue LoadError
44
- # abort "You'll need to have `echoe' installed to use Net::SSH's Rakefile"
45
- # end
46
- #
47
- # version = Net::SSH::Version::STRING.dup
48
- # if ENV['SNAPSHOT'].to_i == 1
49
- # version << "." << Time.now.utc.strftime("%Y%m%d%H%M%S")
50
- # end
51
- #
52
- # Echoe.new('net-ssh', version) do |p|
53
- # p.changelog = "CHANGELOG.rdoc"
54
- #
55
- # p.author = "Jamis Buck"
56
- # p.email = "jamis@jamisbuck.org"
57
- # p.summary = "a pure-Ruby implementation of the SSH2 client protocol"
58
- # p.url = "http://net-ssh.rubyforge.org/ssh"
59
- #
60
- # p.need_zip = true
61
- # p.include_rakefile = true
62
- #
63
- # p.rdoc_pattern = /^(lib|README.rdoc|CHANGELOG.rdoc|THANKS.rdoc)/
64
- # end
@@ -25,11 +25,11 @@ module Authentication; module Methods
25
25
  assert_equal "sig-one", packet.read_string
26
26
  t.return(USERAUTH_FAILURE, :string, "hostbased,password")
27
27
 
28
- t.expect do |t, packet|
29
- assert_equal USERAUTH_REQUEST, packet.type
30
- assert verify_userauth_request_packet(packet, keys.last)
31
- assert_equal "sig-two", packet.read_string
32
- t.return(USERAUTH_FAILURE, :string, "hostbased,password")
28
+ t.expect do |t2, packet2|
29
+ assert_equal USERAUTH_REQUEST, packet2.type
30
+ assert verify_userauth_request_packet(packet2, keys.last)
31
+ assert_equal "sig-two", packet2.read_string
32
+ t2.return(USERAUTH_FAILURE, :string, "hostbased,password")
33
33
  end
34
34
  end
35
35
 
@@ -29,11 +29,11 @@ module Authentication; module Methods
29
29
  transport.expect do |t,packet|
30
30
  assert_equal USERAUTH_REQUEST, packet.type
31
31
  t.return(USERAUTH_INFO_REQUEST, :string, "", :string, "", :string, "", :long, 1, :string, "Password:", :bool, false)
32
- t.expect do |t,packet|
33
- assert_equal USERAUTH_INFO_RESPONSE, packet.type
34
- assert_equal 1, packet.read_long
35
- assert_equal "the-password", packet.read_string
36
- t.return(USERAUTH_FAILURE, :string, "publickey")
32
+ t.expect do |t2,packet2|
33
+ assert_equal USERAUTH_INFO_RESPONSE, packet2.type
34
+ assert_equal 1, packet2.read_long
35
+ assert_equal "the-password", packet2.read_string
36
+ t2.return(USERAUTH_FAILURE, :string, "publickey")
37
37
  end
38
38
  end
39
39
 
@@ -44,9 +44,9 @@ module Authentication; module Methods
44
44
  transport.expect do |t,packet|
45
45
  assert_equal USERAUTH_REQUEST, packet.type
46
46
  t.return(USERAUTH_INFO_REQUEST, :string, "", :string, "", :string, "", :long, 1, :string, "Password:", :bool, false)
47
- t.expect do |t,packet|
48
- assert_equal USERAUTH_INFO_RESPONSE, packet.type
49
- t.return(USERAUTH_SUCCESS)
47
+ t.expect do |t2,packet2|
48
+ assert_equal USERAUTH_INFO_RESPONSE, packet2.type
49
+ t2.return(USERAUTH_SUCCESS)
50
50
  end
51
51
  end
52
52
 
@@ -57,12 +57,12 @@ module Authentication; module Methods
57
57
  transport.expect do |t,packet|
58
58
  assert_equal USERAUTH_REQUEST, packet.type
59
59
  t.return(USERAUTH_INFO_REQUEST, :string, "", :string, "", :string, "", :long, 2, :string, "Password:", :bool, false, :string, "Again:", :bool, false)
60
- t.expect do |t,packet|
61
- assert_equal USERAUTH_INFO_RESPONSE, packet.type
62
- assert_equal 2, packet.read_long
63
- assert_equal "the-password", packet.read_string
64
- assert_equal "the-password", packet.read_string
65
- t.return(USERAUTH_SUCCESS)
60
+ t.expect do |t2,packet2|
61
+ assert_equal USERAUTH_INFO_RESPONSE, packet2.type
62
+ assert_equal 2, packet2.read_long
63
+ assert_equal "the-password", packet2.read_string
64
+ assert_equal "the-password", packet2.read_string
65
+ t2.return(USERAUTH_SUCCESS)
66
66
  end
67
67
  end
68
68
 
@@ -76,12 +76,12 @@ module Authentication; module Methods
76
76
  transport.expect do |t,packet|
77
77
  assert_equal USERAUTH_REQUEST, packet.type
78
78
  t.return(USERAUTH_INFO_REQUEST, :string, "", :string, "", :string, "", :long, 2, :string, "Name:", :bool, true, :string, "Password:", :bool, false)
79
- t.expect do |t,packet|
80
- assert_equal USERAUTH_INFO_RESPONSE, packet.type
81
- assert_equal 2, packet.read_long
82
- assert_equal "name", packet.read_string
83
- assert_equal "password", packet.read_string
84
- t.return(USERAUTH_SUCCESS)
79
+ t.expect do |t2,packet2|
80
+ assert_equal USERAUTH_INFO_RESPONSE, packet2.type
81
+ assert_equal 2, packet2.read_long
82
+ assert_equal "name", packet2.read_string
83
+ assert_equal "password", packet2.read_string
84
+ t2.return(USERAUTH_SUCCESS)
85
85
  end
86
86
  end
87
87
 
@@ -21,10 +21,10 @@ module Authentication; module Methods
21
21
  assert verify_userauth_request_packet(packet, keys.first, false)
22
22
  t.return(USERAUTH_FAILURE, :string, "hostbased,password")
23
23
 
24
- t.expect do |t, packet|
25
- assert_equal USERAUTH_REQUEST, packet.type
26
- assert verify_userauth_request_packet(packet, keys.last, false)
27
- t.return(USERAUTH_FAILURE, :string, "hostbased,password")
24
+ t.expect do |t2, packet2|
25
+ assert_equal USERAUTH_REQUEST, packet2.type
26
+ assert verify_userauth_request_packet(packet2, keys.last, false)
27
+ t2.return(USERAUTH_FAILURE, :string, "hostbased,password")
28
28
  end
29
29
  end
30
30
 
@@ -40,22 +40,22 @@ module Authentication; module Methods
40
40
  assert verify_userauth_request_packet(packet, keys.first, false)
41
41
  t.return(USERAUTH_PK_OK, :string, keys.first.ssh_type, :string, Net::SSH::Buffer.from(:key, keys.first))
42
42
 
43
- t.expect do |t,packet|
44
- assert_equal USERAUTH_REQUEST, packet.type
45
- assert verify_userauth_request_packet(packet, keys.first, true)
46
- assert_equal "sig-one", packet.read_string
47
- t.return(USERAUTH_FAILURE, :string, "hostbased,password")
48
-
49
- t.expect do |t, packet|
50
- assert_equal USERAUTH_REQUEST, packet.type
51
- assert verify_userauth_request_packet(packet, keys.last, false)
52
- t.return(USERAUTH_PK_OK, :string, keys.last.ssh_type, :string, Net::SSH::Buffer.from(:key, keys.last))
53
-
54
- t.expect do |t,packet|
55
- assert_equal USERAUTH_REQUEST, packet.type
56
- assert verify_userauth_request_packet(packet, keys.last, true)
57
- assert_equal "sig-two", packet.read_string
58
- t.return(USERAUTH_FAILURE, :string, "hostbased,password")
43
+ t.expect do |t2,packet2|
44
+ assert_equal USERAUTH_REQUEST, packet2.type
45
+ assert verify_userauth_request_packet(packet2, keys.first, true)
46
+ assert_equal "sig-one", packet2.read_string
47
+ t2.return(USERAUTH_FAILURE, :string, "hostbased,password")
48
+
49
+ t2.expect do |t3, packet3|
50
+ assert_equal USERAUTH_REQUEST, packet3.type
51
+ assert verify_userauth_request_packet(packet3, keys.last, false)
52
+ t3.return(USERAUTH_PK_OK, :string, keys.last.ssh_type, :string, Net::SSH::Buffer.from(:key, keys.last))
53
+
54
+ t3.expect do |t4,packet4|
55
+ assert_equal USERAUTH_REQUEST, packet4.type
56
+ assert verify_userauth_request_packet(packet4, keys.last, true)
57
+ assert_equal "sig-two", packet4.read_string
58
+ t4.return(USERAUTH_FAILURE, :string, "hostbased,password")
59
59
  end
60
60
  end
61
61
  end
@@ -72,11 +72,11 @@ module Authentication; module Methods
72
72
  assert verify_userauth_request_packet(packet, keys.first, false)
73
73
  t.return(USERAUTH_PK_OK, :string, keys.first.ssh_type, :string, Net::SSH::Buffer.from(:key, keys.first))
74
74
 
75
- t.expect do |t,packet|
76
- assert_equal USERAUTH_REQUEST, packet.type
77
- assert verify_userauth_request_packet(packet, keys.first, true)
78
- assert_equal "sig-one", packet.read_string
79
- t.return(USERAUTH_SUCCESS)
75
+ t.expect do |t2,packet2|
76
+ assert_equal USERAUTH_REQUEST, packet2.type
77
+ assert verify_userauth_request_packet(packet2, keys.first, true)
78
+ assert_equal "sig-one", packet2.read_string
79
+ t2.return(USERAUTH_SUCCESS)
80
80
  end
81
81
  end
82
82
 
@@ -127,10 +127,10 @@ module Connection
127
127
  assert_equal 0, packet[:local_id]
128
128
  assert_equal "hello wo", packet[:data]
129
129
 
130
- t.expect do |t,packet|
131
- assert_equal CHANNEL_DATA, packet.type
132
- assert_equal 0, packet[:local_id]
133
- assert_equal "rld", packet[:data]
130
+ t.expect do |t2,packet2|
131
+ assert_equal CHANNEL_DATA, packet2.type
132
+ assert_equal 0, packet2[:local_id]
133
+ assert_equal "rld", packet2[:data]
134
134
  end
135
135
  end
136
136
 
@@ -420,27 +420,27 @@ module Connection
420
420
  transport.expect do |t, p|
421
421
  assert_equal CHANNEL_OPEN, p.type
422
422
  t.return(CHANNEL_OPEN_CONFIRMATION, :long, p[:remote_id], :long, 0, :long, 0x20000, :long, 0x10000)
423
- t.expect do |t, p2|
423
+ t.expect do |t2, p2|
424
424
  assert_equal CHANNEL_REQUEST, p2.type
425
425
  assert_equal "exec", p2[:request]
426
426
  assert_equal true, p2[:want_reply]
427
427
  assert_equal "ls", p2.read_string
428
428
 
429
- t.return(CHANNEL_SUCCESS, :long, p[:remote_id])
429
+ t2.return(CHANNEL_SUCCESS, :long, p[:remote_id])
430
430
 
431
431
  0.step(data.length-1, 2) do |index|
432
432
  type = data[index]
433
433
  datum = data[index+1]
434
434
 
435
435
  if type == :stdout
436
- t.return(CHANNEL_DATA, :long, p[:remote_id], :string, datum)
436
+ t2.return(CHANNEL_DATA, :long, p[:remote_id], :string, datum)
437
437
  else
438
- t.return(CHANNEL_EXTENDED_DATA, :long, p[:remote_id], :long, 1, :string, datum)
438
+ t2.return(CHANNEL_EXTENDED_DATA, :long, p[:remote_id], :long, 1, :string, datum)
439
439
  end
440
440
  end
441
441
 
442
- t.return(CHANNEL_CLOSE, :long, p[:remote_id])
443
- t.expect { |t,p| assert_equal CHANNEL_CLOSE, p.type }
442
+ t2.return(CHANNEL_CLOSE, :long, p[:remote_id])
443
+ t2.expect { |t3,p3| assert_equal CHANNEL_CLOSE, p3.type }
444
444
  end
445
445
  end
446
446
  end
@@ -66,9 +66,9 @@ module Transport; module Kex
66
66
  assert_equal KEXDH_INIT, buffer.type
67
67
  assert_equal dh.dh.pub_key, buffer.read_bignum
68
68
  t.return(KEXDH_REPLY, :string, b(:key, server_key), :bignum, server_dh_pubkey, :string, b(:string, options[:key_type] || "ssh-rsa", :string, signature))
69
- connection.expect do |t, buffer|
70
- assert_equal NEWKEYS, buffer.type
71
- t.return(NEWKEYS)
69
+ connection.expect do |t2, buffer2|
70
+ assert_equal NEWKEYS, buffer2.type
71
+ t2.return(NEWKEYS)
72
72
  end
73
73
  end
74
74
 
@@ -51,13 +51,13 @@ module Transport; module Kex
51
51
  assert_equal need_bits, buffer.read_long
52
52
  assert_equal 8192, buffer.read_long
53
53
  t.return(KEXDH_GEX_GROUP, :bignum, bn(options[:p] || default_p), :bignum, bn(options[:g] || 2))
54
- t.expect do |t, buffer|
55
- assert_equal KEXDH_GEX_INIT, buffer.type
56
- assert_equal dh.dh.pub_key, buffer.read_bignum
57
- t.return(KEXDH_GEX_REPLY, :string, b(:key, server_key), :bignum, server_dh_pubkey, :string, b(:string, options[:key_type] || "ssh-rsa", :string, signature))
58
- t.expect do |t, buffer|
59
- assert_equal NEWKEYS, buffer.type
60
- t.return(NEWKEYS)
54
+ t.expect do |t2, buffer2|
55
+ assert_equal KEXDH_GEX_INIT, buffer2.type
56
+ assert_equal dh.dh.pub_key, buffer2.read_bignum
57
+ t2.return(KEXDH_GEX_REPLY, :string, b(:key, server_key), :bignum, server_dh_pubkey, :string, b(:string, options[:key_type] || "ssh-rsa", :string, signature))
58
+ t2.expect do |t3, buffer3|
59
+ assert_equal NEWKEYS, buffer3.type
60
+ t3.return(NEWKEYS)
61
61
  end
62
62
  end
63
63
  end
@@ -4,6 +4,10 @@ require 'net/ssh/transport/cipher_factory'
4
4
  module Transport
5
5
 
6
6
  class TestCipherFactory < Test::Unit::TestCase
7
+ def self.if_supported?(name)
8
+ yield if Net::SSH::Transport::CipherFactory.supported?(name)
9
+ end
10
+
7
11
  def test_lengths_for_none
8
12
  assert_equal [0,0], factory.get_lengths("none")
9
13
  assert_equal [0,0], factory.get_lengths("bogus")
@@ -13,8 +17,10 @@ module Transport
13
17
  assert_equal [16,8], factory.get_lengths("blowfish-cbc")
14
18
  end
15
19
 
16
- def test_lengths_for_idea_cbc
17
- assert_equal [16,8], factory.get_lengths("idea-cbc")
20
+ if_supported?("idea-cbc") do
21
+ def test_lengths_for_idea_cbc
22
+ assert_equal [16,8], factory.get_lengths("idea-cbc")
23
+ end
18
24
  end
19
25
 
20
26
  def test_lengths_for_rijndael_cbc
@@ -51,14 +57,16 @@ module Transport
51
57
  assert_equal TEXT, decrypt("blowfish-cbc", BLOWFISH)
52
58
  end
53
59
 
54
- IDEA = "W\234\017G\231\b\357\370H\b\256U]\343M\031k\233]~\023C\363\263\177\262-\261\341$\022\376mv\217\322\b\2763\270H\306\035\343z\313\312\3531\351\t\201\302U\022\360\300\354ul7$z\320O]\360g\024\305\005`V\005\335A\351\312\270c\320D\232\eQH1\340\265\2118\031g*\303v"
60
+ if_supported?("idea-cbc") do
61
+ IDEA = "W\234\017G\231\b\357\370H\b\256U]\343M\031k\233]~\023C\363\263\177\262-\261\341$\022\376mv\217\322\b\2763\270H\306\035\343z\313\312\3531\351\t\201\302U\022\360\300\354ul7$z\320O]\360g\024\305\005`V\005\335A\351\312\270c\320D\232\eQH1\340\265\2118\031g*\303v"
55
62
 
56
- def test_idea_cbc_for_encryption
57
- assert_equal IDEA, encrypt("idea-cbc")
58
- end
63
+ def test_idea_cbc_for_encryption
64
+ assert_equal IDEA, encrypt("idea-cbc")
65
+ end
59
66
 
60
- def test_idea_cbc_for_decryption
61
- assert_equal TEXT, decrypt("idea-cbc", IDEA)
67
+ def test_idea_cbc_for_decryption
68
+ assert_equal TEXT, decrypt("idea-cbc", IDEA)
69
+ end
62
70
  end
63
71
 
64
72
  RIJNDAEL = "$\253\271\255\005Z\354\336&\312\324\221\233\307Mj\315\360\310Fk\241EfN\037\231\213\361{'\310\204\347I\343\271\005\240`\325;\034\346uM>#\241\231C`\374\261\vo\226;Z\302:\b\250\366T\330\\#V\330\340\226\363\374!\bm\266\232\207!\232\347\340\t\307\370\356z\236\343=v\210\206y"
@@ -370,6 +370,8 @@ module Transport
370
370
  hmacs = Net::SSH::Transport::HMAC::MAP.keys
371
371
 
372
372
  ciphers.each do |cipher_name|
373
+ next unless Net::SSH::Transport::CipherFactory.supported?(cipher_name)
374
+
373
375
  hmacs.each do |hmac_name|
374
376
  [false, :standard].each do |compress|
375
377
  cipher_method_name = cipher_name.gsub(/\W/, "_")
@@ -4,7 +4,10 @@ require 'net/ssh/transport/session'
4
4
  # mocha adds #verify to Object, which throws off the host-key-verifier part of
5
5
  # these tests.
6
6
 
7
- Object.send(:undef_method, :verify)
7
+ # can't use .include? because ruby18 uses strings and ruby19 uses symbols :/
8
+ if Object.instance_methods.any? { |v| v.to_sym == :verify }
9
+ Object.send(:undef_method, :verify)
10
+ end
8
11
 
9
12
  module Transport
10
13
 
@@ -166,7 +166,7 @@ module Transport
166
166
  end
167
167
 
168
168
  def state
169
- @state ||= Net::SSH::Transport::State.new(socket)
169
+ @state ||= Net::SSH::Transport::State.new(socket, :test)
170
170
  end
171
171
  end
172
172
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck
@@ -9,10 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-27 00:00:00 -06:00
12
+ date: 2008-12-06 00:00:00 -07:00
13
13
  default_executable:
14
- dependencies: []
15
-
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:
16
25
  description: a pure-Ruby implementation of the SSH2 client protocol
17
26
  email: jamis@jamisbuck.org
18
27
  executables: []
@@ -209,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
218
  requirements:
210
219
  - - ">="
211
220
  - !ruby/object:Gem::Version
212
- version: "0"
221
+ version: "1.2"
213
222
  version:
214
223
  requirements: []
215
224