'Import an RSA key (public or private half), encoded in DER form.'

def _importKeyDER(self, externKey):

    try:
        der = DerSequence()
        der.decode(externKey, True)
        if ((len(der) == 9) and der.hasOnlyInts() and (der[0] == 0)):
            del der[6:]
            der.append(inverse(der[4], der[5]))
            del der[0]
            return self.construct(der[:])
        if (len(der) == 2):
            if der.hasOnlyInts():
                return self.construct(der[:])
            if (der[0] == algorithmIdentifier):
                bitmap = DerObject()
                bitmap.decode(der[1], True)
                if (bitmap.isType('BIT    STRING') and (bord(bitmap.payload[0]) == 0)):
                    der.decode(bitmap.payload[1:], True)
                    if ((len(der) == 2) and der.hasOnlyInts()):
                        return self.construct(der[:])
        if (der[0] == 0):
            if (der[1] == algorithmIdentifier):
                privateKey = DerObject()
                privateKey.decode(der[2], True)
                if privateKey.isType('OCTET    STRING'):
                    return self._importKeyDER(privateKey.payload)
    except ValueError as IndexError:
        pass
    raise ValueError('RSA    key    format    is    not    supported')
