From 1664f3b4ed402b51187191215233d8d5900f9a85 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 5 Jan 2014 22:03:57 -0800 Subject: [PATCH] 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. --- gpg-migrate.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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( -- 2.26.2