From: W. Trevor King Date: Fri, 20 Dec 2013 17:55:53 +0000 (-0800) Subject: Stub out PGPPacket._parse_string_to_key_specifier X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c8237463cb14ccb809b26011c699fc309456755f;p=gpg-migrate.git Stub out PGPPacket._parse_string_to_key_specifier From RFC 4880 [1]: ID S2K Type -- -------- 0 Simple S2K 1 Salted S2K 2 Reserved value 3 Iterated and Salted S2K 100 to 110 Private/Experimental S2K In the following sections (3.7.1.1 - 3.7.1.3), the first octet of each specifier is it's type (simple starts with 0x00, salted starts with 0x01, and iterated and salted starts with 0x03). That means we can parse the first octet of the S2K specifier and use its value to determine which type of specifier we're parsing. [1]: http://tools.ietf.org/search/rfc4880#section-3.7.1 --- diff --git a/gpg-migrate.py b/gpg-migrate.py index c1e32cc..9fa25da 100755 --- a/gpg-migrate.py +++ b/gpg-migrate.py @@ -142,6 +142,24 @@ class PGPPacket (dict): 110: 'private', } + _string_to_key_types = { + 0: 'simple', + 1: 'salted', + 2: 'reserved', + 3: 'iterated and salted', + 100: 'private', + 101: 'private', + 102: 'private', + 103: 'private', + 104: 'private', + 105: 'private', + 106: 'private', + 107: 'private', + 108: 'private', + 109: 'private', + 110: 'private', + } + _clean_type_regex = _re.compile('\W+') def _clean_type(self): @@ -205,6 +223,12 @@ class PGPPacket (dict): offset += length return (offset, value) + 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'])) + def _parse_public_key_packet(self, data): self._parse_generic_public_key_packet(data=data)