gpg: allow parsing multiple keys
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user