def validate(self):
if not isinstance(self.value, bytes):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>elif not isinstance(self.cryptographic_algorithm,<EOL>enums.CryptographicAlgorithm):<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>elif not isinstance(self.cryptographic_length, six.integer_types):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>elif not isinstance(self.key_format_type, enums.KeyFormatType):<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>elif self.key_format_type not in self._valid_formats:<EOL><INDENT>raise ValueError("<STR_LIT>".format(<EOL>self._valid_formats))<EOL><DEDENT>mask_count = len(self.cryptographic_usage_masks)<EOL>for i in range(mask_count):<EOL><INDENT>mask = self.cryptographic_usage_masks[i]<EOL>if not isinstance(mask, enums.CryptographicUsageMask):<EOL><INDENT>position = "<STR_LIT>".format(i)<EOL>raise TypeError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(position))<EOL><DEDENT><DEDENT>name_count = len(self.names)<EOL>for i in range(name_count):<EOL><INDENT>name = self.names[i]<EOL>if not isinstance(name, six.string_types):<EOL><INDENT>position = "<STR_LIT>".format(i)<EOL>raise TypeError("<STR_LIT>".format(<EOL>position))<EOL><DEDENT><DEDENT>
Verify that the contents of the PublicKey object are valid.

Raises:
    TypeError: if the types of any PublicKey attributes are invalid.