SHA256CryptoServiceProvider不符合FIPS? [英] SHA256CryptoServiceProvider not FIPS compliant?

查看:609
本文介绍了SHA256CryptoServiceProvider不符合FIPS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一个在C#中SHA256的实现,是符合FIPS。事实证明,SHA1CryptoServiceProvider工作。但是为什么SHA256CryptoServiceProvider跳闸




  {此实现不验证的Windows平台FIPS的一部分加密算法。} 




错误? 。看起来它应该只是工作。



  VAR SHA = System.Security.Cryptography.SHA256CryptoServiceProvider.Create(); //不是FIPS 

在这种情况下,我使用.NET 4.5,但同样的事情发生在3.5和4.0。我以为SHA256CryptoServiceProvider是符合FIPS标准的替代SHA256Managed。 SHA256Cng抛出了同样的错误。



更新。我想我需要做出一个新SHA256CryptoServiceProvider而不是使用的Create()


解决方案

由于在更新建议楼主,解决的办法就是实际创建SHA256CryptoServiceProvider(或512)的新实例。创建调用将无法工作:

  VAR CSP =新SHA512CryptoServiceProvider(); 
字节[] = hashedBytes csp.ComputeHash(......);
字符串hashedText = Convert.ToBase64String(hashedBytes);


I am looking for a SHA256 implementation in C# that is FIPS compliant. It turns out that SHA1CryptoServiceProvider works. But why does SHA256CryptoServiceProvider trip the

{"This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms."}

error? Seems like it should just work.

var sha = System.Security.Cryptography.SHA256CryptoServiceProvider.Create();   // not FIPS

In this case I am using .NET 4.5, but the same thing happens in 3.5 and 4.0. I thought SHA256CryptoServiceProvider was the FIPS-compliant alternative to SHA256Managed. SHA256Cng throws the same error.

Update. I think I needed to make a "new SHA256CryptoServiceProvider" instead of using Create()

解决方案

As the original poster suggested in the update, the solution is to actually create a new instance of the SHA256CryptoServiceProvider (or 512). Calling Create will not work:

var csp = new SHA512CryptoServiceProvider();
byte[] hashedBytes = csp.ComputeHash(......);
String hashedText = Convert.ToBase64String(hashedBytes); 

这篇关于SHA256CryptoServiceProvider不符合FIPS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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