net-ssh 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,14 @@
1
+ === 2.0.4 / 27 Aug 2008
2
+
3
+ * Added Connection::Session#closed? and Transport::Session#closed? [Jamis Buck]
4
+
5
+ * Numeric host names in .ssh/config are now parsed correct [Yanko Ivanov]
6
+
7
+ * Make sure the error raised when a public key file is malformed is more informative than a MethodMissing error [Jamis Buck]
8
+
9
+ * Cipher#reset is now called after Cipher#final, with the last n bytes used as the next initialization vector [Jamis Buck]
10
+
11
+
1
12
  === 2.0.3 / 27 Jun 2008
2
13
 
3
14
  * Make Net::SSH::Version comparable [Brian Candler]
@@ -160,7 +160,7 @@ module Net; module SSH
160
160
  # Converts an ssh_config pattern into a regex for matching against
161
161
  # host names.
162
162
  def pattern2regex(pattern)
163
- pattern = "^" + pattern.gsub(/\./, "\\.").
163
+ pattern = "^" + pattern.to_s.gsub(/\./, "\\.").
164
164
  gsub(/\?/, '.').
165
165
  gsub(/\*/, '.*') + "$"
166
166
  Regexp.new(pattern, true)
@@ -81,6 +81,15 @@ module Net; module SSH; module Connection
81
81
  transport.host
82
82
  end
83
83
 
84
+ # Returns true if the underlying transport has been closed. Note that
85
+ # this can be a little misleading, since if the remote server has
86
+ # closed the connection, the local end will still think it is open
87
+ # until the next operation on the socket. Nevertheless, this method can
88
+ # be useful if you just want to know if _you_ have closed the connection.
89
+ def closed?
90
+ transport.closed?
91
+ end
92
+
84
93
  # Closes the session gracefully, blocking until all channels have
85
94
  # successfully closed, and then closes the underlying transport layer
86
95
  # connection.
@@ -74,6 +74,8 @@ module Net; module SSH
74
74
  data = File.read(File.expand_path(filename))
75
75
  type, blob = data.split(/ /)
76
76
 
77
+ raise Net::SSH::Exception, "public key at #{filename} is not valid" if blob.nil?
78
+
77
79
  blob = blob.unpack("m*").first
78
80
  reader = Net::SSH::Buffer.new(blob)
79
81
  reader.read_key or raise OpenSSL::PKey::PKeyError, "not a public key #{filename.inspect}"
@@ -10,6 +10,11 @@ module Net; module SSH; module Transport
10
10
  8
11
11
  end
12
12
 
13
+ # Returns an arbitrary integer.
14
+ def iv_len
15
+ 4
16
+ end
17
+
13
18
  # Does nothing. Returns self.
14
19
  def encrypt
15
20
  self
@@ -134,7 +134,7 @@ module Net; module SSH; module Transport
134
134
  unencrypted_data = [packet_length, padding_length, payload, padding].pack("NCA*A*")
135
135
  mac = client.hmac.digest([client.sequence_number, unencrypted_data].pack("NA*"))
136
136
 
137
- encrypted_data = client.cipher.update(unencrypted_data) << client.cipher.final
137
+ encrypted_data = client.update_cipher(unencrypted_data) << client.final_cipher
138
138
  message = encrypted_data + mac
139
139
 
140
140
  debug { "queueing packet nr #{client.sequence_number} type #{payload[0]} len #{packet_length}" }
@@ -187,7 +187,7 @@ module Net; module SSH; module Transport
187
187
  data = read_available(minimum)
188
188
 
189
189
  # decipher it
190
- @packet = Net::SSH::Buffer.new(server.cipher.update(data))
190
+ @packet = Net::SSH::Buffer.new(server.update_cipher(data))
191
191
  @packet_length = @packet.read_long
192
192
  end
193
193
 
@@ -199,14 +199,14 @@ module Net; module SSH; module Transport
199
199
  if need > 0
200
200
  # read the remainder of the packet and decrypt it.
201
201
  data = read_available(need)
202
- @packet.append(server.cipher.update(data))
202
+ @packet.append(server.update_cipher(data))
203
203
  end
204
204
 
205
205
  # get the hmac from the tail of the packet (if one exists), and
206
206
  # then validate it.
207
207
  real_hmac = read_available(server.hmac.mac_length) || ""
208
208
 
209
- @packet.append(server.cipher.final)
209
+ @packet.append(server.final_cipher)
210
210
  padding_length = @packet.read_byte
211
211
 
212
212
  payload = @packet.read(@packet_length - padding_length - 1)
@@ -93,6 +93,11 @@ module Net; module SSH; module Transport
93
93
  end
94
94
  end
95
95
 
96
+ # Returns true if the underlying socket has been closed.
97
+ def closed?
98
+ socket.closed?
99
+ end
100
+
96
101
  # Cleans up (see PacketStream#cleanup) and closes the underlying socket.
97
102
  def close
98
103
  socket.cleanup
@@ -16,9 +16,6 @@ module Net; module SSH; module Transport
16
16
  # The next packet sequence number for this socket endpoint.
17
17
  attr_reader :sequence_number
18
18
 
19
- # The cipher algorithm in use for this socket endpoint.
20
- attr_reader :cipher
21
-
22
19
  # The hmac algorithm in use for this endpoint.
23
20
  attr_reader :hmac
24
21
 
@@ -55,6 +52,8 @@ module Net; module SSH; module Transport
55
52
  @hmac = HMAC.get("none")
56
53
  @compression = nil
57
54
  @compressor = @decompressor = nil
55
+ @next_iv = nil
56
+ @cipher_needs_reset = false
58
57
  end
59
58
 
60
59
  # A convenience method for quickly setting multiple values in a single
@@ -66,6 +65,27 @@ module Net; module SSH; module Transport
66
65
  reset!
67
66
  end
68
67
 
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
+ def update_cipher(data)
80
+ @next_iv = data[-cipher.iv_len..-1]
81
+ cipher.update(data)
82
+ end
83
+
84
+ def final_cipher
85
+ @cipher_needs_reset
86
+ cipher.final
87
+ end
88
+
69
89
  # Increments the counters. The sequence number is incremented (and remapped
70
90
  # so it always fits in a 32-bit integer). The number of packets and blocks
71
91
  # are also incremented.
@@ -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 = 3
54
+ TINY = 4
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,14 @@
1
1
 
2
- # Gem::Specification for Net-ssh-2.0.3
2
+ # Gem::Specification for Net-ssh-2.0.4
3
3
  # Originally generated by Echoe
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = %q{net-ssh}
7
- s.version = "2.0.3"
7
+ s.version = "2.0.4"
8
8
 
9
9
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
10
  s.authors = ["Jamis Buck"]
11
- s.date = %q{2008-06-27}
11
+ s.date = %q{2008-08-27}
12
12
  s.description = %q{a pure-Ruby implementation of the SSH2 client protocol}
13
13
  s.email = %q{jamis@jamisbuck.org}
14
14
  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"]
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.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-27 00:00:00 -06:00
12
+ date: 2008-08-27 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies: []
15
15