From: W. Trevor King Date: Mon, 6 Jan 2014 06:03:57 +0000 (-0800) Subject: Add key-binding targets to PGPPacket._parse_signature_packet X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1664f3b4ed402b51187191215233d8d5900f9a85;p=gpg-migrate.git Add key-binding targets to PGPPacket._parse_signature_packet Also adjust the 'user id and public-key packet' targets to always grab the first packet in the list (public or private) instead of always looking in the public packets. This commit assumes that we're loading public packets first, and if a key has any secret packets, then the current packet is a new secret packet. --- diff --git a/gpg-migrate.py b/gpg-migrate.py index 1d139a0..9ecd9ae 100755 --- a/gpg-migrate.py +++ b/gpg-migrate.py @@ -743,12 +743,21 @@ class PGPPacket (dict): o, mpi = self._parse_multiprecision_integer(data=data[offset:]) offset += o self['signature'].append(mpi) + if self.key.secret_packets: + packets = self.key.secret_packets + else: + packets = self.key.public_packets if self['signature-type'] == 'standalone': self['target'] = None elif self['signature-type'].endswith(' user id and public-key packet'): self['target'] = [ - [p for p in self.key.public_packets if p['type'] == 'public-key packet'][-1], - [p for p in self.key.public_packets if p['type'] == 'user id packet'][-1], + packets[0], + [p for p in packets if p['type'] == 'user id packet'][-1], + ] + elif self['signature-type'].endswith('key binding'): + self['target'] = [ + packets[0], + [p for p in packets if p['type'] == 'public-subkey packet'][-1], ] else: raise NotImplementedError(