我在.NET中实现了ECDSA密钥和证书,我需要存储这些密钥,以便可以在新的签名中重用它们。在RSA中,我使用的是RSACryptoServiceProvider类,但在ECDsa和ECDsaCng类中,我没有看到任何类似的东西。
我只见过DSACryptoServiceProvider和一个旧的ECDsaCryptoServiceProvider到Framework4.3(有点旧)。
有人知道用RSA存储ECDSA密钥的方法吗?
发布于 2016-09-29 13:36:30
假设您想要将密钥持久化到OS密钥存储中(使用命名密钥的RSACryptoServiceProvider),那么与CNG的接口略有不同:
private static ECDsa CreateOrOpenECDsaKey(string keyName)
{
CngKey key;
if (CngKey.Exists(keyName))
{
key = CngKey.Open(keyName);
}
else
{
// You can also specify options here, like if it should be exportable, in a
// different overload.
key = CngKey.Create(CngAlgorithm.ECDsaP521, keyName);
}
// The ECDsaCng constructor will duplicate the key reference, so we can close this one.
using (key)
{
return new ECDsaCng(key);
}
}如果您想要像RSAParameters一样进行导出/导入,那么.NET核心中已经提供了该功能,但.NET框架中尚未提供该功能。
https://stackoverflow.com/questions/39749637
复制相似问题