在Windows 7 64位下使用SHA256时,CryptDeriveKey(OID)未知

时间:2010-01-06 04:39:16

标签: c# windows encryption .net-3.5

我正在测试我使用面向.NET Framework 3.5 SP1的VS2008 SP1构建的一些组件。 我在方法PasswordDeriveBytes.CryptDeriveKey中通过“SHA256”作为哈希算法的参数得到异常“(OID)未知”(我还尝试了“SHA256Managed”和“SHA256Cng”,如上所述{{3} })。此方法在XP SP3下正常工作。据我所知,这些算法是在3.5的SP1中添加的,Windows 7附带的是3.5 SP1。

所以我的问题是如何在Windows 7下获得SHA256?

1 个答案:

答案 0 :(得分:1)

http://www.codeplex.com/clrsecurity/SourceControl/changeset/view/18423,然后点击“下载”。    湾解压缩并构建下载的Security.Cryptography \ src \ Security.Cryptography.csproj VS 2008项目。    C。编写一个程序来调用Security.Cryptography.Oid2.RegisterSha2OidInformationForRsa()。    d。执行该程序,该程序将向OS注册SHA-256 OID。    即如果这是64位体系结构,则还必须重新编译x86平台的程序并执行它。这是因为Visual Studio 2008是一个32位应用程序,需要在32位注册表中进行相同的更改。

使用System; 使用System.Collections.Generic; 使用System.Linq; 使用System.Text;

命名空间RegisterSHA256 {     课程     {         static void Main(string [] args)         {             Console.WriteLine(“++++开始注册SHA-256 ++++”);             Security.Cryptography.Oid2.RegisterSha2OidInformationForRsa();             Console.WriteLine(“++++ End to register SHA-256 +++++”);         }     } }