基于SHA512的具有HMACfunction的FIPSvalidation应用程序?

我正在构建一个FIPSvalidation的应用程序,并在我的计算机上打开FIPS模式。 我需要HMACfunction,希望基于SHA512。 我知道HMAC SHA1function已通过FIPSvalidation,但我有一个散列函数SHA512CryptoServiceProvider,它经过FIPSvalidation,我知道FIPS实际上允许使用SHA512。 在使用FIPSvalidation的HMAC SHA512的C#中是否有类似的HMACfunction?

有一个HMACSHA512类 ,但它内部使用SHA512Managed Class , 未经FIPS认证 。

您可以尝试基于SHA512CryptoServiceProvider类创建自己的HMACSHA512类 :

public class MyHMACSHA512 : HMAC { public MyHMACSHA512(byte[] key) { HashName = "System.Security.Cryptography.SHA512CryptoServiceProvider"; HashSizeValue = 512; BlockSizeValue = 128; Key = key; } } 

以下对我有用 – 我能够创建AES和SHA256 FIPS快乐HMAC:

  /// Computes a Hash-based Message Authentication Code (HMAC) using the AES hash function. public class AesHmac : HMAC { /// Initializes a new instance of the AesHmac class with the specified key data. /// The secret key for AesHmac encryption. public AesHmac(byte[] key) { HashName = "System.Security.Cryptography.AesCryptoServiceProvider"; HashSizeValue = 128; BlockSizeValue = 128; Initialize(); Key = (byte[])key.Clone(); } } /// Computes a Hash-based Message Authentication Code (HMAC) using the SHA256 hash function. public class ShaHmac : HMAC { /// Initializes a new instance of the ShaHmac class with the specified key data. /// The secret key for ShaHmac encryption. public ShaHmac(byte[] key) { HashName = "System.Security.Cryptography.SHA256CryptoServiceProvider"; HashSizeValue = 256; BlockSizeValue = 128; Initialize(); Key = (byte[])key.Clone(); } } 

谢谢,里奇