Is there a keyed SHA256 hash algorithm that is FIPS compliant for .NET?

自古美人都是妖i 提交于 2019-12-06 00:19:25
SwDevMan81

No, there is not. Here is a list of ones that are (scroll down to FIPS.sys Algorithms section).

A work around I've used int he past is here, but I'm not sure if that will work for web services. This solution could work.

I know this is old but it looks like Microsoft addressed this issue. I'm running .NET 4.5.1 on Windows 8. I can't speak to what version of the BCL this was fixed or OS.

this.m_hash1 = HMAC.GetHashAlgorithmWithFipsFallback((Func<HashAlgorithm>) (() => (HashAlgorithm) new SHA256Managed()), (Func<HashAlgorithm>) (() => HashAlgorithm.Create("System.Security.Cryptography.SHA256CryptoServiceProvider")));

Officially you may be out of luck, but it should be relatively easy to build a HMAC_SHA256 out of SHA-256. Just take a look at the Wikipedia page to see how easy this is.

Note that it may be the case that HMAC was not approved in FIPS mode because it is vulnerable to side channel attacks. In that case you should make sure that there is some protection against side channel attacks.

It is a bit dangerous to build your own crypto algorithms out of cryptographic primitives. If you yourself will try and claim FIPS level security then this may become an issue. But for most users it is enough if you say that you only use NIST compliant algorithms. It is up to you how far you are willing to go down this line...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!