Merge pull request #30 from np/decode-subpackets

gpg/decode/parse_subpackets: parse subpacket length according to RFC
nistp521
Roman Zeyde 8 years ago committed by GitHub
commit 0c4e67c837

@ -25,10 +25,17 @@ def parse_subpackets(s):
while True:
try:
subpacket_len = s.readfmt('B')
first = s.readfmt('B')
except EOFError:
break
if first < 192:
subpacket_len = first
elif first < 255:
subpacket_len = ((first - 192) << 8) + s.readfmt('B') + 192
else: # first == 255
subpacket_len = s.readfmt('>L')
subpackets.append(s.read(subpacket_len))
return subpackets

Loading…
Cancel
Save