def _create_rsa_key_pair(self, length, public_exponent=<NUM_LIT>):
self.logger.info(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(<EOL>length, public_exponent<EOL>)<EOL>)<EOL>try:<EOL><INDENT>private_key = rsa.generate_private_key(<EOL>public_exponent=public_exponent,<EOL>key_size=length,<EOL>backend=default_backend())<EOL>public_key = private_key.public_key()<EOL>private_bytes = private_key.private_bytes(<EOL>serialization.Encoding.DER,<EOL>serialization.PrivateFormat.PKCS8,<EOL>serialization.NoEncryption())<EOL>public_bytes = public_key.public_bytes(<EOL>serialization.Encoding.DER,<EOL>serialization.PublicFormat.PKCS1)<EOL><DEDENT>except Exception as e:<EOL><INDENT>self.logger.exception(e)<EOL>raise exceptions.CryptographicFailure(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>public_key = {<EOL>'<STR_LIT:value>': public_bytes,<EOL>'<STR_LIT>': enums.KeyFormatType.PKCS_1,<EOL>'<STR_LIT>': public_exponent<EOL>}<EOL>private_key = {<EOL>'<STR_LIT:value>': private_bytes,<EOL>'<STR_LIT>': enums.KeyFormatType.PKCS_8,<EOL>'<STR_LIT>': public_exponent<EOL>}<EOL>return public_key, private_key<EOL>
Create an RSA key pair.

Args:
    length(int): The length of the keys to be created. This value must
        be compliant with the constraints of the provided algorithm.
    public_exponent(int): The value of the public exponent needed to
        generate the keys. Usually a small Fermat prime number.
        Optional, defaults to 65537.

Returns:
    dict: A dictionary containing the public key data, with the
        following key/value fields:
        * value - the bytes of the key
        * format - a KeyFormatType enumeration for the bytes format
        * public_exponent - the public exponent integer
    dict: A dictionary containing the private key data, identical in
        structure to the one above.

Raises:
    CryptographicFailure: Raised when the key generation process
        fails.