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

   Octet  0:        0x03
   Octet  1:        hash algorithm
   Octets 2-9:      8-octet salt value
   Octet  10:       count, a one-octet, coded value

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

gpg-migrate.py

index 9be8e8668f6c9eb13503717033b16ae9f38b1778..7fea58d141e630aeebbdc958da1e8d562b09228a 100755 (executable)
@@ -236,6 +236,14 @@ class PGPPacket (dict):
             offset += 1
             self['string-to-key-salt'] = data[offset: offset + 8]
             offset += 8
+        elif self['string-to-key-type'] == 'iterated and 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
+            self['string-to-key-coded-count'] = data[offset]
+            offset += 1
         else:
             raise NotImplementedError(
                 'string-to-key type {}'.format(self['string-to-key-type']))