Add salted S2K parsing to PGPPacket._parse_string_to_key_specifier
authorW. Trevor King <wking@tremily.us>
Fri, 20 Dec 2013 18:02:41 +0000 (10:02 -0800)
committerW. Trevor King <wking@tremily.us>
Fri, 20 Dec 2013 19:46:30 +0000 (11:46 -0800)
From RFC 4880 [1]:

   Octet  0:        0x01
   Octet  1:        hash algorithm
   Octets 2-9:      8-octet salt value

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

gpg-migrate.py

index 359ceb4795c42db0736d69640b51408338a58ecc..9be8e8668f6c9eb13503717033b16ae9f38b1778 100755 (executable)
@@ -230,6 +230,12 @@ class PGPPacket (dict):
             self['string-to-key-hash-algorithm'] = self._hash_algorithms[
                 data[offset]]
             offset += 1
+        elif self['string-to-key-type'] == 'salted':
+            self['string-to-key-hash-algorithm'] = self._hash_algorithms[
+                data[offset]]
+            offset += 1
+            self['string-to-key-salt'] = data[offset: offset + 8]
+            offset += 8
         else:
             raise NotImplementedError(
                 'string-to-key type {}'.format(self['string-to-key-type']))