Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* simplified Partial Body Lengths packet support algorithm.

  • Loading branch information...
commit ac6948f3453d1bca6f7667e94b9dad6a43f89dff 1 parent e3eaf7e
@nahi authored
Showing with 25 additions and 24 deletions.
  1. +25 −24 lib/pgp/packet/packet.rb
View
49 lib/pgp/packet/packet.rb
@@ -29,6 +29,7 @@ class Packet
extend Support::ModuleSupport
TAGS = {
+ -1 => "Partial",
0 => "Reserved",
1 => "Public-Key Encrypted Session Key Packet",
2 => "Signature Packet",
@@ -87,19 +88,19 @@ def dump
end
def self.load(port)
- loadport = wrap_port(port)
packets = []
continue = false
+ newheader = false
+ tag = nil
+ loadport = wrap_port(port)
while !loadport.eof?
if continue
- lengthdefined, partial = load_length_new(loadport)
- else
- newheader, tag, lengthdefined, partial = load_header(loadport)
- end
- if partial and continue
- raise "Partial Body Lengths packet not supported"
+ lengthdefined, continue = load_length_new(loadport)
+ packet = Partial.loader(loadport, lengthdefined)
+ packets << packet
+ next
end
- continue = partial
+ newheader, tag, lengthdefined, continue = load_header(loadport)
initpos = loadport.readlength
unless TAG_LOADER.key?(tag)
raise "Not supported: #{tag}"
@@ -121,31 +122,31 @@ def self.scan(port, io = STDOUT)
dumpport = IndentDumpPort.for(io)
end
continue = false
+ newheader = false
+ tag = nil
loadport = wrap_port(port)
while !loadport.eof?
initpos = nil
begin
if continue
- lengthdefined, partial = load_length_new(loadport)
- else
- newheader, tag, lengthdefined, partial = load_header(loadport)
- end
- newtag = newheader ? "New" : "Old"
- if partial
+ lengthdefined, continue = load_length_new(loadport)
+ newtag = newheader ? "New" : "Old"
if continue
- dumpport.puts "#{newtag}(partial continue): - (tag #{tag})(#{lengthdefined} bytes)"
- loadport.read(lengthdefined)
- next
+ newtag += '(partial continue)'
else
- newtag += '(partial start)'
- end
- else
- if continue
- newtag += '(partial end)'
+ newtag += '(partial end )'
end
+ dumpport.puts "#{newtag}: - (tag #{tag})(#{lengthdefined} bytes)"
+ Partial.scanner(dumpport, loadport, lengthdefined)
+ next
+ end
+ newheader, tag, lengthdefined, continue = load_header(loadport)
+ newtag = newheader ? "New" : "Old"
+ if continue
+ newtag += '(partial start )'
end
- continue = partial
- dumpport.puts "#{newtag}: #{taglabel(tag)}(tag #{tag})(#{lengthdefined} bytes)"
+ dumpport.puts "#{newtag}: #{taglabel(tag)}(tag #{tag})" +
+ "(#{lengthdefined} bytes)"
initpos = loadport.readlength
dumpport.indent(4) do
unless TAG_SCANNER.key?(tag)
Please sign in to comment.
Something went wrong with that request. Please try again.