Add simple S2K parsing to PGPPacket._parse_string_to_key_specifier
authorW. Trevor King <wking@tremily.us>
Fri, 20 Dec 2013 17:59:58 +0000 (09:59 -0800)
committerW. Trevor King <wking@tremily.us>
Fri, 20 Dec 2013 19:46:30 +0000 (11:46 -0800)
From RFC 4880 [1]:

   Octet 0:        0x00
   Octet 1:        hash algorithm

[1]: http://tools.ietf.org/search/rfc4880#section-3.7.1.1

gpg-migrate.py

index 9fa25da84297c34fa7671ac16b6942210bdec497..359ceb4795c42db0736d69640b51408338a58ecc 100755 (executable)
@@ -226,8 +226,14 @@ class PGPPacket (dict):
     def _parse_string_to_key_specifier(self, data):
         self['string-to-key-type'] = self._string_to_key_types[data[0]]
         offset = 1
-        raise NotImplementedError(
-            'string-to-key type {}'.format(self['string-to-key-type']))
+        if self['string-to-key-type'] == 'simple':
+            self['string-to-key-hash-algorithm'] = self._hash_algorithms[
+                data[offset]]
+            offset += 1
+        else:
+            raise NotImplementedError(
+                'string-to-key type {}'.format(self['string-to-key-type']))
+        return offset
 
     def _parse_public_key_packet(self, data):
         self._parse_generic_public_key_packet(data=data)