@is_connected<EOL><INDENT>def create_key_pair(self,<EOL>algorithm,<EOL>length,<EOL>operation_policy_name=None,<EOL>public_name=None,<EOL>public_usage_mask=None,<EOL>private_name=None,<EOL>private_usage_mask=None):<DEDENT>
<EOL>if not isinstance(algorithm, enums.CryptographicAlgorithm):<EOL><INDENT>raise TypeError(<EOL>"<STR_LIT>")<EOL><DEDENT>elif not isinstance(length, six.integer_types) or length <= <NUM_LIT:0>:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>common_attributes = self._build_common_attributes(<EOL>operation_policy_name<EOL>)<EOL>algorithm_attribute = self.attribute_factory.create_attribute(<EOL>enums.AttributeType.CRYPTOGRAPHIC_ALGORITHM,<EOL>algorithm<EOL>)<EOL>length_attribute = self.attribute_factory.create_attribute(<EOL>enums.AttributeType.CRYPTOGRAPHIC_LENGTH,<EOL>length<EOL>)<EOL>common_attributes.extend([algorithm_attribute, length_attribute])<EOL>template = cobjects.TemplateAttribute(<EOL>attributes=common_attributes,<EOL>tag=enums.Tags.COMMON_TEMPLATE_ATTRIBUTE<EOL>)<EOL>public_template = None<EOL>names = None<EOL>if public_name:<EOL><INDENT>names = self._build_name_attribute(name=public_name)<EOL><DEDENT>attrs = []<EOL>if public_usage_mask:<EOL><INDENT>attrs = [<EOL>self.attribute_factory.create_attribute(<EOL>enums.AttributeType.CRYPTOGRAPHIC_USAGE_MASK,<EOL>public_usage_mask<EOL>)<EOL>]<EOL><DEDENT>if names or attrs:<EOL><INDENT>public_template = cobjects.TemplateAttribute(<EOL>names=names,<EOL>attributes=attrs,<EOL>tag=enums.Tags.PUBLIC_KEY_TEMPLATE_ATTRIBUTE<EOL>)<EOL><DEDENT>private_template = None<EOL>names = None<EOL>if private_name:<EOL><INDENT>names = self._build_name_attribute(name=private_name)<EOL><DEDENT>attrs = []<EOL>if private_usage_mask:<EOL><INDENT>attrs = [<EOL>self.attribute_factory.create_attribute(<EOL>enums.AttributeType.CRYPTOGRAPHIC_USAGE_MASK,<EOL>private_usage_mask<EOL>)<EOL>]<EOL><DEDENT>if names or attrs:<EOL><INDENT>private_template = cobjects.TemplateAttribute(<EOL>names=names,<EOL>attributes=attrs,<EOL>tag=enums.Tags.PRIVATE_KEY_TEMPLATE_ATTRIBUTE<EOL>)<EOL><DEDENT>result = self.proxy.create_key_pair(<EOL>common_template_attribute=template,<EOL>private_key_template_attribute=private_template,<EOL>public_key_template_attribute=public_template)<EOL>status = result.result_status.value<EOL>if status == enums.ResultStatus.SUCCESS:<EOL><INDENT>public_uid = result.public_key_uuid<EOL>private_uid = result.private_key_uuid<EOL>return public_uid, private_uid<EOL><DEDENT>else:<EOL><INDENT>reason = result.result_reason.value<EOL>message = result.result_message.value<EOL>raise exceptions.KmipOperationFailure(status, reason, message)<EOL><DEDENT>
Create an asymmetric key pair on a KMIP appliance.

Args:
    algorithm (CryptographicAlgorithm): An enumeration defining the
        algorithm to use to generate the key pair.
    length (int): The length in bits for the key pair.
    operation_policy_name (string): The name of the operation policy
        to use for the new key pair. Optional, defaults to None.
    public_name (string): The name to give the public key. Optional,
        defaults to None.
    public_usage_mask (list): A list of CryptographicUsageMask
        enumerations indicating how the public key should be used.
        Optional, defaults to None.
    private_name (string): The name to give the public key. Optional,
        defaults to None.
    private_usage_mask (list): A list of CryptographicUsageMask
        enumerations indicating how the private key should be used.
        Optional, defaults to None.

Returns:
    string: The uid of the newly created public key.
    string: The uid of the newly created private key.

Raises:
    ClientConnectionNotOpen: if the client connection is unusable
    KmipOperationFailure: if the operation result is a failure
    TypeError: if the input arguments are invalid