'Import an RSA key (public or private half), encoded in standard form.
:Parameter externKey:
The RSA key to import, encoded as a string.
An RSA public key can be in any of the following formats:
- X.509 `subjectPublicKeyInfo` DER SEQUENCE (binary or PEM encoding)
- `PKCS#1`_ `RSAPublicKey` DER SEQUENCE (binary or PEM encoding)
- OpenSSH (textual public key only)
An RSA private key can be in any of the following formats:
- PKCS#1 `RSAPrivateKey` DER SEQUENCE (binary or PEM encoding)
- `PKCS#8`_ `PrivateKeyInfo` DER SEQUENCE (binary or PEM encoding)
- OpenSSH (textual public key only)
For details about the PEM encoding, see `RFC1421`_/`RFC1423`_.
In case of PEM encoding, the private key can be encrypted with DES or 3TDES according to a certain ``pass phrase``.
Only OpenSSL-compatible pass phrases are supported.
:Type externKey: string
:Parameter passphrase:
In case of an encrypted PEM key, this is the pass phrase from which the encryption key is derived.
:Type passphrase: string
:Return: An RSA key object (`_RSAobj`).
:Raise ValueError/IndexError/TypeError:
When the given key cannot be parsed (possibly because the pass phrase is wrong).
.. _RFC1421: http://www.ietf.org/rfc/rfc1421.txt
.. _RFC1423: http://www.ietf.org/rfc/rfc1423.txt
.. _`PKCS#1`: http://www.ietf.org/rfc/rfc3447.txt
.. _`PKCS#8`: http://www.ietf.org/rfc/rfc5208.txt'

def importKey(self, externKey, passphrase=None):

    externKey = tobytes(externKey)
    if (passphrase is not None):
        passphrase = tobytes(passphrase)
    if externKey.startswith(b('-----')):
        lines = externKey.replace(b('    '), b('')).split()
        keyobj = None
        if lines[1].startswith(b('Proc-Type:4,ENCRYPTED')):
            DEK = lines[2].split(b(':'))
            if ((len(DEK) != 2) or (DEK[0] != b('DEK-Info')) or (not passphrase)):
                raise ValueError('PEM    encryption    format    not    supported.')
            (algo, salt) = DEK[1].split(b(','))
            salt = binascii.a2b_hex(salt)
            import Crypto.Hash.MD5
            from Crypto.Cipher import DES, DES3
            from Crypto.Protocol.KDF import PBKDF1
            if (algo == b('DES-CBC')):
                key = PBKDF1(passphrase, salt, 8, 1, Crypto.Hash.MD5)
                keyobj = DES.new(key, Crypto.Cipher.DES.MODE_CBC, salt)
            elif (algo == b('DES-EDE3-CBC')):
                key = PBKDF1(passphrase, salt, 16, 1, Crypto.Hash.MD5)
                key += PBKDF1((key + passphrase), salt, 8, 1, Crypto.Hash.MD5)
                keyobj = DES3.new(key, Crypto.Cipher.DES3.MODE_CBC, salt)
            else:
                raise ValueError('Unsupport    PEM    encryption    algorithm.')
            lines = lines[2:]
        der = binascii.a2b_base64(b('').join(lines[1:(-1)]))
        if keyobj:
            der = keyobj.decrypt(der)
            padding = bord(der[(-1)])
            der = der[:(- padding)]
        return self._importKeyDER(der)
    if externKey.startswith(b('ssh-rsa    ')):
        keystring = binascii.a2b_base64(externKey.split(b('    '))[1])
        keyparts = []
        while (len(keystring) > 4):
            l = struct.unpack('>I', keystring[:4])[0]
            keyparts.append(keystring[4:(4 + l)])
            keystring = keystring[(4 + l):]
        e = bytes_to_long(keyparts[1])
        n = bytes_to_long(keyparts[2])
        return self.construct([n, e])
    if (bord(externKey[0]) == 48):
        return self._importKeyDER(externKey)
    raise ValueError('RSA    key    format    is    not    supported')
