gpg: allow parsing multiple keys

nistp521
Roman Zeyde 8 years ago
parent 024b5f131f
commit f4dd1eacdd

@ -286,15 +286,13 @@ def collect_packets(packets, types_to_collect):
return result
def parse_public_key(stream):
def parse_public_keys(stream):
"""Parse GPG public key into hierarchy of packets."""
packets = list(parse_packets(stream))
packets = collect_packets(packets, {'signature'})
packets = collect_packets(packets, {'user_id', 'user_attribute'})
packets = collect_packets(packets, {'subkey'})
if len(packets) != 1:
raise ValueError('Unexpected packet structure: %r', packets)
return packets[0]
return packets
HASH_ALGORITHMS = {

@ -111,4 +111,5 @@ def public_key_path(request):
def test_gpg_files(public_key_path): # pylint: disable=redefined-outer-name
with open(public_key_path, 'rb') as f:
decode.parse_public_key(f)
keys = decode.parse_public_keys(f)
assert len(keys) > 0

Loading…
Cancel
Save