【发布时间】:2017-11-02 11:17:13
【问题描述】:
如何通过加密将 CngKey 导出到 PKCS#8?
static void Main(string[] args)
{
CngKeyCreationParameters ckcParams = new CngKeyCreationParameters()
{
ExportPolicy = CngExportPolicies.AllowExport,
KeyCreationOptions = CngKeyCreationOptions.None,
KeyUsage = CngKeyUsages.AllUsages,
};
ckcParams.Parameters.Add(new CngProperty("Length", BitConverter.GetBytes(2048), CngPropertyOptions.None));
myCngKey = CngKey.Create(CngAlgorithm.Rsa, "theCngKey", ckcParams);
byte[] privatePlainTextBlob = myCngKey.Export(CngKeyBlobFormat.Pkcs8PrivateBlob);
}
将 ExportPolicy 设置为 AllowPlainTextExport 允许导出密钥,但只能以纯文本形式导出。我想创建一个用对称密钥加密的 PCKS8 blob。
谢谢
【问题讨论】:
标签: c# encryption encryption-asymmetric cng