Add PGPPacket.copy and pull out PGPPacket._serialize_body
authorW. Trevor King <wking@tremily.us>
Mon, 23 Dec 2013 19:55:56 +0000 (11:55 -0800)
committerW. Trevor King <wking@tremily.us>
Mon, 23 Dec 2013 21:41:06 +0000 (13:41 -0800)
commitc7ee05593feeddedba66749632ad80999b6c3778
tree2b2a900932c8225f239d0845486d82e85c13ec32
parent9550c5f054820de258ddafebb9397aea9b42411b
Add PGPPacket.copy and pull out PGPPacket._serialize_body

Use these with _serialize_signature_packet_target to compute key
fingerprints in _parse_generic_public_key_packet.  I'd previously been
hashing over the whole (sub)key packet, but RFC 4880 says the hash
should just be over the public-key part of the packet, even for secret
keys [1]:

  A V4 fingerprint is the 160-bit SHA-1 hash of the octet 0x99,
  followed by the two-octet packet length, followed by the entire
  Public-Key packet starting with the version field.

I've added the fingerprint_target stuff so I don't hash the
secret-key-specific fields.

[1]: http://tools.ietf.org/search/rfc4880#section-12.2
gpg-migrate.py