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
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):
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)