Add signature verification to PGPPacket and PGPKey
From RFC 4880 [1]:
With RSA signatures, the hash value is encoded using PKCS#1 encoding
type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This
requires inserting the hash value as an octet string into an ASN.1
structure. The object identifier for the type of hash being used is
included in the structure. The hexadecimal representations for the
currently defined hash algorithms are as follows: ...
Rather than coding all these object identifiers in myself, I'm
piggybacking on PyCrypto [2,3,4] which already sets up
per-hash-algarithm OIDs. However, older versions of PyCrypto attached
the OIDs to the PyCrypto-specific hash implementations, and we're
using hashlib's implementations. Since
59018ff (Hash: Remove "oid"
attributes; add "name" attribute, 2013-02-17, released in PyCrypto
v2.7a1), PyCrypto has been able to handle hashlib hashes, so you'll
need a fairly modern installation to work with this script.
[1]: https://tools.ietf.org/html/rfc4880#section-5.2.2
[2]: http://www.pycrypto.org/
[3]: https://www.dlitz.net/software/pycrypto/
[4]: https://github.com/dlitz/pycrypto/