I have an existing private key that is being loaded in a C application via an OpenSSL module.
int PRIVATE_KEY_LEN = 512;
RSA *rsa;
unsigned char PRIVATE_KEY[] = { 0x00, 0x01, 0x02, ... }
const unsigned char *Key = PRIVATE_KEY;
rsa = d2i_RSAPrivateKey(NULL, &Key, PRIVATE_KEY_LEN);
From what I understand the private key is in a DER format and I'm now trying to use the key in a separate .NET application.
Is there a way to load this into a RSACryptoServiceProvider
without using a third part library in C#?
I have a feeling I'm supposed to create a RSAParameters
and load the relevant bytes from the key like so but not really sure which bytes I'm supposed to be using
int PRIVATE_KEY_LEN = 512;
private byte[] PRIVATE_KEY = { 0x00, 0x01, 0x02, ... }
rsa = new RSACryptoServiceProvider();
var rsaParam = rsa.ExportParameters(false);
rsaParam.Modulus = PRIVATE_KEY.Take(PRIVATE_KEY_LEN).ToArray();
rsa.ImportParameters(rsaParam);
Am I way off?