简体   繁体   中英

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. 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 ). This method works OK under XP SP3. As I understand these algorithms were added with the SP1 of 3.5 and Windows 7 comes with 3.5 SP1.

So my question is how I can get SHA256 under Windows 7?

to http://www.codeplex.com/clrsecurity/SourceControl/changeset/view/18423 and click "Download". b. Unzip and build the downloaded Security.Cryptography\\src\\Security.Cryptography.csproj VS 2008 project. c. Write a program to call Security.Cryptography.Oid2.RegisterSha2OidInformationForRsa(). d. Execute that program, which will register SHA-256 OID with the OS. e. If this is a 64-bit architecture, you must also recompile the program for the x86 platform and execute it. This is because Visual Studio 2008 is a 32-bit application and requires that the same changes be made in the 32-bit registry.

using System; using System.Collections.Generic; using System.Linq; using System.Text;

namespace RegisterSHA256 { class Program { static void Main(string[] args) { Console.WriteLine("++++Begin to register SHA-256++++"); Security.Cryptography.Oid2.RegisterSha2OidInformationForRsa(); Console.WriteLine("++++ End to register SHA-256+++++"); } } }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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