Handles the decompression and dencryption of incoming packets.

Methods
Attributes
[W] buffers A handle to the buffer factory to use when creating buffers
[W] log A handle to the logger instance to use for writing log messages
Public Class methods
new( ciphers, hmacs, decompressors )

Create a new IncomingPacketStream.

     # File lib/net/ssh/transport/packet-stream.rb, line 132
132:         def initialize( ciphers, hmacs, decompressors )
133:           super( ciphers, hmacs )
134:           @decompressor = decompressors.fetch( "none" )
135:           @mutex = Mutex.new
136:         end
Public Instance methods
get()

Retrieve the next packet from the string, after (possibly) decrypting and decompressing it. The packet is returned as a reader buffer.

     # File lib/net/ssh/transport/packet-stream.rb, line 146
146:         def get
147:           @mutex.synchronize do
148:             # get the first block of data
149:             if @log.debug?
150:               @log.debug "reading #{@cipher.block_size} bytes from socket..."
151:             end
152: 
153:             data = read( @cipher.block_size )
154: 
155:             # decipher it
156:             reader = @buffers.reader( @cipher.update( data ) )
157: 
158:             # determine the packet length and how many bytes remain to be read
159:             packet_length = reader.read_long
160:             remaining_to_read = packet_length + 4 - @cipher.block_size
161:             if @log.debug?
162:               @log.debug "packet length(#{packet_length}) " +
163:                 "remaining(#{remaining_to_read})"
164:             end
165: 
166:             # read the remainder of the packet and decrypt it.
167:             data = read( remaining_to_read )
168: 
169:             reader.append @cipher.update( data )
170:             reader.append @cipher.final
171: 
172:             padding_length = reader.read_byte
173: 
174:             payload = reader.read( packet_length - padding_length - 1 )
175:             padding = reader.read( padding_length ) if padding_length > 0
176: 
177:             # get the hmac from the tail of the packet (if one exists), and
178:             # then validate it.
179:             hmac = @hmac.mac_length > 0 ? @socket.recv( @hmac.mac_length ) : ""
180: 
181:             my_computed_hmac = compute_hmac( reader.content )
182:             raise Net::SSH::Exception,
183:               "corrupted mac detected" if hmac != my_computed_hmac
184: 
185:             # decompress the payload
186:             payload = @decompressor.decompress( payload )
187: 
188:             increment_sequence_number
189: 
190:             buffer = @buffers.reader( payload )
191:             @log.debug "received: #{buffer.content.inspect}" if @log.debug?
192: 
193:             return buffer
194:           end
195:         end
set_algorithms( cipher, mac, decompressor )

Set the cipher, mac, and decompressor algorithms to the given values.

     # File lib/net/ssh/transport/packet-stream.rb, line 139
139:         def set_algorithms( cipher, mac, decompressor )
140:           super( cipher, mac )
141:           @decompressor = decompressor
142:         end

[Validate]