Merge pull request #30 from np/decode-subpackets

gpg/decode/parse_subpackets: parse subpacket length according to RFC
This commit is contained in:
Roman Zeyde
2016-09-05 20:52:48 +03:00
committed by GitHub

View File

@@ -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