CngKey MachineKey Delete() [英] CngKey MachineKey Delete()

查看:45
本文介绍了CngKey MachineKey Delete()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我正在努力解决框架的ECDiffieHellmanCng椭圆曲线密码术实现的使用问题.与我过去在RsaCryptoServiceProvider中使用Rsa的方式不同,它看起来围绕CngKey( 我现在知道RsaCng会使用).

I'm trying to wrap my head around the usage of the framework's ECDiffieHellmanCng Elliptic Curve cryptography implementation.  Unlike how I've used Rsa in the past with RsaCryptoServiceProvider, this looks to center around the concept of a CngKey (which I now know RsaCng uses).

我一直在阅读创建和安全存储用于这些密码提供程序的CngKey的方法,并使用以下内容创建了一个新的计算机范围的CngKey:

I've been reading up on ways to create and safely store a CngKey for use with these cryptographic providers and I created a new Machine wide CngKey with the following:

CngKey.Create(CngAlgorithm.ECDiffieHellmanP384,"Test",
                            新的CngKeyCreationParameters
                             {
                    KeyCreationOptions = CngKeyCreationOptions.MachineKey,
                    KeyUsage = CngKeyUsages.Decryption
                             });

CngKey.Create(CngAlgorithm.ECDiffieHellmanP384, "Test",
                new CngKeyCreationParameters
                {
                    KeyCreationOptions = CngKeyCreationOptions.MachineKey,
                    KeyUsage = CngKeyUsages.Decryption
                });

现在,如果我通过以下方式获得该计算机密钥的实例:

Now, if I get an instance of that machine key via:

CngKey k = CngKey.Open(测试",CngProvider.MicrosoftSoftwareKeyStorageProvider,CngKeyOpenOptions.MachineKey);

CngKey k = CngKey.Open("Test", CngProvider.MicrosoftSoftwareKeyStorageProvider, CngKeyOpenOptions.MachineKey);

然后尝试使用k.Delete();

And then try to delete it with k.Delete();

我注意到,与非机器宽键(或用户键)不同,它似乎并未真正被移除.

I'm noticing that it doesn't seem to actually be removed unlike a non-Machine wide key (or user key).

我看到这是因为当我打电话时:

I see this because when I then call:

CngKey.Exists(测试",CngProvider.MicrosoftSoftwareKeyStorageProvider,CngKeyOpenOptions.MachineKey)

CngKey.Exists("Test", CngProvider.MicrosoftSoftwareKeyStorageProvider, CngKeyOpenOptions.MachineKey)

如果我刚删除,我会得到一个TRUE答复.

I get a TRUE response where I would have expected a FALSE given that I just deleted.

无论我到目前为止在密钥创建过程中尝试过的选项或参数的哪种组合,我都不会收到任何UI提示或警告.

I don't get any sort of UI prompt or warning no matter what combination of options or parameters I've tried thus far during the creation of the key.

我什至尝试创建一个新密钥,将其标记为改写和用户密钥,然后删除却无济于事.

I've even tried creating a new key, marking it as overwritting and a user key, then deleting to no avail.

删除现有的计算机范围的CngKey真的很困难吗?在非Cng世界中,使用CspContainer和机器范围的密钥,我没有任何问题.

Is it really this difficult to delete an existing Machine wide CngKey?  I don't have any problem back in the non Cng world with a CspContainer and machine wide keys.

我想念什么?

推荐答案

嗨JustMorris,

Hi JustMorris,

谢谢您在这里发布.

对于您的问题,我以管理员身份运行VS来测试您的代码.我创建一个CngKey,然后删除. CngKey.Exist的布尔值返回false.它对我有用.

For your question, I run the VS as admin to test your code. I create a CngKey and then delete. The bool value of CngKey.Exist returns false. It works for me.


最好的问候,

温迪


这篇关于CngKey MachineKey Delete()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆