def parse(self, keydata=None):
if keydata is None:<EOL><INDENT>if self.keydata is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>keydata = self.keydata<EOL><DEDENT>else:<EOL><INDENT>self.reset()<EOL>self.keydata = keydata<EOL><DEDENT>if keydata.startswith("<STR_LIT>"):<EOL><INDENT>key_type = None  <EOL>pubkey_content = "<STR_LIT>".join([line for line in keydata.split("<STR_LIT:\n>") if "<STR_LIT::>" not in line and "<STR_LIT>" not in line])<EOL><DEDENT>else:<EOL><INDENT>key_parts = self._split_key(keydata)<EOL>key_type = key_parts[<NUM_LIT:0>]<EOL>pubkey_content = key_parts[<NUM_LIT:1>]<EOL><DEDENT>self._decoded_key = self.decode_key(pubkey_content)<EOL>current_position, unpacked_key_type = self._unpack_by_int(self._decoded_key, <NUM_LIT:0>)<EOL>if key_type is not None and key_type != unpacked_key_type.decode():<EOL><INDENT>raise InvalidTypeError("<STR_LIT>" % (key_type, unpacked_key_type))<EOL><DEDENT>self.key_type = unpacked_key_type<EOL>key_data_length = self._process_key(self._decoded_key[current_position:])<EOL>current_position = current_position + key_data_length<EOL>if current_position != len(self._decoded_key):<EOL><INDENT>raise MalformedDataError("<STR_LIT>" % (len(self._decoded_key) - current_position))<EOL><DEDENT>if self.disallow_options and self.options:<EOL><INDENT>raise InvalidOptionsError("<STR_LIT>")<EOL><DEDENT>
Validates SSH public key.

        Throws exception for invalid keys. Otherwise returns None.

        Populates key_type, bits and bits fields.

        For rsa keys, see field "rsa" for raw public key data.
        For dsa keys, see field "dsa".
        For ecdsa keys, see field "ecdsa".