From b6df49a6bcde83c5eeed27853dd92d2bddaa27ff Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 22 Dec 2013 14:02:11 -0800 Subject: [PATCH] Add PGPPacket.key pointing back up to the PGPKey This allows us to do stuff like caching passphrases on a key-wide level, instead of asking for the passphrase for each packet. The actuall caching commit is coming next, this commit just lands the framework. --- gpg-migrate.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gpg-migrate.py b/gpg-migrate.py index aae79c7..4290551 100755 --- a/gpg-migrate.py +++ b/gpg-migrate.py @@ -271,6 +271,10 @@ class PGPPacket (dict): _clean_type_regex = _re.compile('\W+') + def __init__(self, key=None): + super(PGPPacket, self).__init__() + self.key = key + def _clean_type(self, type=None): if type is None: type = self['type'] @@ -727,7 +731,7 @@ class PGPPacket (dict): subpacket['features'].add('modification detection') def _parse_embedded_signature_signature_subpacket(self, data, subpacket): - subpacket['embedded'] = PGPPacket() + subpacket['embedded'] = PGPPacket(key=self.key) subpacket['embedded']._parse_signature_packet(data=data) def _parse_user_id_packet(self, data): @@ -1016,7 +1020,7 @@ class PGPKey (object): def _packets_from_bytes(self, data): offset = 0 while offset < len(data): - packet = PGPPacket() + packet = PGPPacket(key=self) offset += packet.from_bytes(data=data[offset:]) yield packet -- 2.26.2