简体   繁体   English

在Windows 7 64位下,SHA256的CryptDeriveKey(OID)未知

[英]CryptDeriveKey (OID) is unknown with SHA256 under Windows 7 64 bits

I'm testing some components I built with VS2008 SP1 targeting .NET Framework 3.5 SP1. 我正在测试使用VS2008 SP1构建的一些组件,它们针对.NET Framework 3.5 SP1。 I'm getting the exception "(OID) is unknown" in the method PasswordDeriveBytes.CryptDeriveKey passing "SHA256" as the parameter of the hashing algorithm (I also tried with "SHA256Managed" and "SHA256Cng" as mentioned here ). 我发现了异常“(OID)是未知”的方法PasswordDeriveBytes.CryptDeriveKey通过“SHA256”作为哈希算法的参数(我也有“SHA256Managed”和“SHA256Cng”提到试图在这里 )。 This method works OK under XP SP3. 该方法在XP SP3下可以正常工作。 As I understand these algorithms were added with the SP1 of 3.5 and Windows 7 comes with 3.5 SP1. 据我了解,这些算法是在3.5 SP1中添加的,而Windows 7则带有3.5 SP1。

So my question is how I can get SHA256 under Windows 7? 所以我的问题是如何在Windows 7下获得SHA256?

to http://www.codeplex.com/clrsecurity/SourceControl/changeset/view/18423 and click "Download". 转到http://www.codeplex.com/clrsecurity/SourceControl/changeset/view/18423 ,然后单击“下载”。 b. b。 Unzip and build the downloaded Security.Cryptography\\src\\Security.Cryptography.csproj VS 2008 project. 解压缩并生成下载的Security.Cryptography \\ src \\ Security.Cryptography.csproj VS 2008项目。 c. C。 Write a program to call Security.Cryptography.Oid2.RegisterSha2OidInformationForRsa(). 编写一个程序来调用Security.Cryptography.Oid2.RegisterSha2OidInformationForRsa()。 d. d。 Execute that program, which will register SHA-256 OID with the OS. 执行该程序,该程序将在OS中注册SHA-256 OID。 e. e。 If this is a 64-bit architecture, you must also recompile the program for the x86 platform and execute it. 如果是64位体系结构,则还必须重新编译x86平台的程序并执行它。 This is because Visual Studio 2008 is a 32-bit application and requires that the same changes be made in the 32-bit registry. 这是因为Visual Studio 2008是32位应用程序,并且要求在32位注册表中进行相同的更改。

using System; 使用系统; using System.Collections.Generic; 使用System.Collections.Generic; using System.Linq; 使用System.Linq; using System.Text; 使用System.Text;

namespace RegisterSHA256 { class Program { static void Main(string[] args) { Console.WriteLine("++++Begin to register SHA-256++++"); 名称空间RegisterSHA256 {类Program {静态void Main(string [] args){Console.WriteLine(“ ++++开始注册SHA-256 ++++”); Security.Cryptography.Oid2.RegisterSha2OidInformationForRsa(); Security.Cryptography.Oid2.RegisterSha2OidInformationForRsa(); Console.WriteLine("++++ End to register SHA-256+++++"); Console.WriteLine(“ ++++结束注册SHA-256 +++++”); } } } }}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM