gpg/decode/parse_subpackets: parse subpacket length according to RFC

nistp521
Nicolas Pouillard 8 years ago
parent 73bdf417e4
commit adcbe6e7b2
No known key found for this signature in database
GPG Key ID: E40E0C223EFD00E5

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