我有一个通过 OpenSSL 模块加载到 C 应用程序中的现有私钥。
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);
据我了解,私钥采用 DER 格式,我现在正尝试在单独的 .NET 应用程序中使用该密钥。
有没有办法在RSACryptoServiceProvider
不使用 C# 中的第三方库的情况下将其加载到 a 中?
我有一种感觉,我应该RSAParameters
像这样创建一个并从密钥加载相关字节,但不确定我应该使用哪些字节
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);
我走远了吗?