From: W. Trevor King Date: Mon, 23 Dec 2013 23:01:12 +0000 (-0800) Subject: Parse signature MPIs in PGPPacket._parse_signature_packet X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=383c3a730b293cc1f80955b9d3a1745d61b98ee0;p=gpg-migrate.git Parse signature MPIs in PGPPacket._parse_signature_packet And serialize these MPIs in _serialize_signature_packet. We need the parsed integers to verify signatures. --- diff --git a/gpg-migrate.py b/gpg-migrate.py index 1359729..e1f44cd 100755 --- a/gpg-migrate.py +++ b/gpg-migrate.py @@ -742,7 +742,11 @@ class PGPPacket (dict): offset += unhashed_count self['signed-hash-word'] = data[offset: offset + 2] offset += 2 - self['signature'] = data[offset:] + self['signature'] = [] + while offset < len(data): + o, mpi = self._parse_multiprecision_integer(data=data[offset:]) + offset += o + self['signature'].append(mpi) if self['signature-type'] == 'standalone': self['target'] = None elif self['signature-type'].endswith(' user id and public-key packet'): @@ -1057,7 +1061,10 @@ class PGPPacket (dict): digest, signature = self.key.sign( data=signed_data, hash_algorithm=self['hash-algorithm'], signature_algorithm=self['public-key-algorithm']) - chunks.extend([digest[:2], signature]) + chunks.append(digest[:2]) + chunks.extend( + self._serialize_multiprecision_integer(integer=integer) + for integer in signature) return b''.join(chunks) def _serialize_signature_creation_time_signature_subpacket(