kmip/services/server/crypto/engine.py
def _create_RSA_private_key(self,
                                bytes):
        """
        Instantiates an RSA key from bytes.

        Args:
            bytes (byte string): Bytes of RSA private key.
        Returns:
            private_key
                (cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey):
                RSA private key created from key bytes.
        """

        try:
            private_key = serialization.load_pem_private_key(
                bytes,
                password=None,
                backend=default_backend()
            )
            return private_key
        except Exception:
            private_key = serialization.load_der_private_key(
                bytes,
                password=None,
                backend=default_backend()
            )
            return private_key
def _create_RSA_private_key(self,
                                bytes):
        """
        Instantiates an RSA key from bytes.

        Args:
            bytes (byte string): Bytes of RSA private key.
        Returns:
            private_key
                (cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey):
                RSA private key created from key bytes.
        """

        try:
            private_key = serialization.load_pem_private_key(
                bytes,
                password=None,
                backend=default_backend()
            )
            return private_key
        except Exception:
            private_key = serialization.load_der_private_key(
                bytes,
                password=None,
                backend=default_backend()
            )
            return private_key
Instantiates an RSA key from bytes.

        Args:
            bytes (byte string): Bytes of RSA private key.
        Returns:
            private_key
                (cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey):
                RSA private key created from key bytes.