def parse_pem_private_key(data):
    """Parse a PEM RSA private key.

    @param data: RFC3447 RSAPrivateKey in PEM format.
    @return: RSA private key
    """
    m = re.search(b"--\n(.*?)\n--", data, re.DOTALL)
    if m is None:
        raise UnparsableKeyError("Private key not found")
    try:
        pkdata = base64.b64decode(m.group(1))
    except TypeError as e:
        raise UnparsableKeyError(str(e))
    return parse_private_key(pkdata)
Parse a PEM RSA private key.

    @param data: RFC3447 RSAPrivateKey in PEM format.
    @return: RSA private key
    
python/dkim/crypto.py