def validate_rsa_key(key, is_secret=True):
    '\n    Validate the format and type of an RSA key.\n    '
    if key.startswith('ssh-rsa '):
        raise forms.ValidationError('OpenSSH line format is not supported. Please ensure that your public is in PEM (base64) format.')
    try:
        key = RSA.importKey(key)
    except ValueError:
        raise forms.ValidationError('Invalid RSA key. Please ensure that your key is in PEM (base64) format.')
    except Exception as e:
        raise forms.ValidationError('Invalid key detected: {}'.format(e))
    if (is_secret and (not key.has_private())):
        raise forms.ValidationError('This looks like a public key. Please provide your private RSA key.')
    elif ((not is_secret) and key.has_private()):
        raise forms.ValidationError('This looks like a private key. Please provide your public RSA key.')
    try:
        PKCS1_OAEP.new(key)
    except Exception:
        raise forms.ValidationError('Error validating RSA key. Please ensure that your key supports PKCS#1 OAEP.')
Validate the format and type of an RSA key.
def validate_rsa_key(key, is_secret=True):
    '\n    \n    '
    if key.startswith('ssh-rsa '):
        raise forms.ValidationError('OpenSSH line format is not supported. Please ensure that your public is in PEM (base64) format.')
    try:
        key = RSA.importKey(key)
    except ValueError:
        raise forms.ValidationError('Invalid RSA key. Please ensure that your key is in PEM (base64) format.')
    except Exception as e:
        raise forms.ValidationError('Invalid key detected: {}'.format(e))
    if (is_secret and (not key.has_private())):
        raise forms.ValidationError('This looks like a public key. Please provide your private RSA key.')
    elif ((not is_secret) and key.has_private()):
        raise forms.ValidationError('This looks like a private key. Please provide your public RSA key.')
    try:
        PKCS1_OAEP.new(key)
    except Exception:
        raise forms.ValidationError('Error validating RSA key. Please ensure that your key supports PKCS#1 OAEP.')