Parse signature MPIs in PGPPacket._parse_signature_packet
authorW. Trevor King <wking@tremily.us>
Mon, 23 Dec 2013 23:01:12 +0000 (15:01 -0800)
committerW. Trevor King <wking@tremily.us>
Mon, 23 Dec 2013 23:07:59 +0000 (15:07 -0800)
And serialize these MPIs in _serialize_signature_packet.  We need the
parsed integers to verify signatures.

gpg-migrate.py

index 13597292ada4e23f1531dd5ee9fdb4ea66171c1c..e1f44cd520e6b699bf30cc04a777b46aadbecb23 100755 (executable)
@@ -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(