Add hashlib hash names to PGPPacket._hashlib_name
authorW. Trevor King <wking@tremily.us>
Sat, 21 Dec 2013 18:14:54 +0000 (10:14 -0800)
committerW. Trevor King <wking@tremily.us>
Mon, 23 Dec 2013 21:41:05 +0000 (13:41 -0800)
The string-to-key algorithm is going to use hashlib for hashing, so
map the OpenPGP-based names to hashlib names for easy lookup.

gpg-migrate.py

index 844e21c22ef90bf1b4dda44455fc481fc7799488..393d4603cb8d72f141339b45172b50bbba44431d 100755 (executable)
@@ -173,6 +173,16 @@ class PGPPacket (dict):
         110: 'private',
         }
 
+    _hashlib_name = {  # map OpenPGP-based names to hashlib names
+        'md5': 'md5',
+        'sha-1': 'sha1',
+        'ripe-md/160': 'ripemd160',
+        'sha256': 'sha256',
+        'sha384': 'sha384',
+        'sha512': 'sha512',
+        'sha224': 'sha224',
+        }
+
     _string_to_key_types = {
         0: 'simple',
         1: 'salted',