¿Cómo analizar (Convertir a RSAParameters) la clave privada X.509 en C #?

Estoy trabajando en un canal de cifrado para cifrar la comunicación entre dos dispositivos. Entonces estoy creando una clase auxiliar para hacer el cifrado y descifrado. Busqué en Google mucho y encontré un código que puede analizar la clave pública RSA enRSACryptoServiceProvider.

Este es el código:

public static RSACryptoServiceProvider DecodeX509PublicKey(byte[] x509key)
{
    byte[] SeqOID = { 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00 };
    byte[] seq = new byte[15];
    MemoryStream mem = new MemoryStream(x509key);
    BinaryReader binr = new BinaryReader(mem);
    byte bt = 0;
    ushort twobytes = 0;

    try
    {

        twobytes = binr.ReadUInt16();
        if (twobytes == 0x8130)
            binr.ReadByte();
        else if (twobytes == 0x8230)
            binr.ReadInt16();
        else
            return null;

        seq = binr.ReadBytes(15);
        if (!CompareBytearrays(seq, SeqOID))
            return null;

        twobytes = binr.ReadUInt16();
        if (twobytes == 0x8103)
            binr.ReadByte();
        else if (twobytes == 0x8203)
            binr.ReadInt16();
        else
            return null;

        bt = binr.ReadByte();
        if (bt != 0x00)
            return null;

        twobytes = binr.ReadUInt16();
        if (twobytes == 0x8130)
            binr.ReadByte();
        else if (twobytes == 0x8230)
            binr.ReadInt16();
        else
            return null;

        twobytes = binr.ReadUInt16();
        byte lowbyte = 0x00;
        byte highbyte = 0x00;

        if (twobytes == 0x8102)
            lowbyte = binr.ReadByte();
        else if (twobytes == 0x8202)
        {
            highbyte = binr.ReadByte();
            lowbyte = binr.ReadByte();
        }
        else
            return null;
        byte[] modint = { lowbyte, highbyte, 0x00, 0x00 };
        int modsize = BitConverter.ToInt32(modint, 0);

        byte firstbyte = binr.ReadByte();
        binr.BaseStream.Seek(-1, SeekOrigin.Current);

        if (firstbyte == 0x00)
        {
            binr.ReadByte();
            modsize -= 1;
        }

        byte[] modulus = binr.ReadBytes(modsize);

        if (binr.ReadByte() != 0x02)
            return null;
        int expbytes = (int)binr.ReadByte();
        byte[] exponent = binr.ReadBytes(expbytes);

        RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
        RSAParameters RSAKeyInfo = new RSAParameters();
        RSAKeyInfo.Modulus = modulus;
        RSAKeyInfo.Exponent = exponent;
        RSA.ImportParameters(RSAKeyInfo);
        return RSA;
    }
    catch (Exception)
    {
        return null;
    }

    finally { binr.Close(); }
}

Funciona increíble con una clave pública. Pero mi pregunta es ¿cómo puedo analizar una clave privada X.509? No estoy realmente familiarizado con la estructura de la clave RSA.

Las claves se generan a partir denode-rsa ennode.js

Gracias por adelantado.<3

Respuestas a la pregunta(1)

Su respuesta a la pregunta