2011-02-17 20 views
6

我已經啓用了在Windows 7中符合FIPS模式,但現在我的代碼失敗,出現以下錯誤編譯:如何在Visual Studio 2010和Windows 7中使用FIPS驗證的加密算法?

Source file 'whatever.cs' could not be opened ('This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.') 

我使用SHA1(哈希)和TripleDes的(加密)加密。 我也試過SHA512和AES(256位密鑰)。

我不能讓項目建立更多,但我需要編譯它使用FIPS兼容算法。

回答

8

試着做一個空白的C#應用​​程序,編譯它,它應該失敗出於同樣的原因。最終問題是Visual Studio,而不是你的代碼。按照instructions here,並添加到您的IDE的配置文件(Devenv.exe.config/VCSExpress.exe.config/vbexpress.exe.config):

<enforceFIPSPolicy enabled="false"/> 

這並不意味着你的應用程序不符合FIPS模式下運行,這意味着Visual Studio的ISN」現在。不符合規範的代碼仍會編譯,但如果它嘗試執行,您將收到System.InvalidOperationException例外。

我認爲,但不確定,VS用於在庫中生成特定散列的算法實際上並不符合FIPS標準。

9

This有一個FIPS兼容算法的列表。更完整的列表是here

FIPS compliant Algorithms:

Hash algorithms

HMACSHA1

MACTripleDES

SHA1CryptoServiceProvider

Symmetric algorithms (use the same key for encryption and decryption)

DESCryptoServiceProvider

TripleDESCryptoServiceProvider

Asymmetric algorithms (use a public key for encryption and a private key for decryption)

DSACryptoServiceProvider

RSACryptoServiceProvider

所以,你需要使用SHA1CryptoServiceProviderTripleDESCryptoServiceProvider是符合FIPS

+0

當使用組合的算法,我仍然收到我上面列出的錯誤。 – ScArcher2 2011-02-17 21:10:15

+0

正如個人指出的,您可能需要關閉所有文件並重新啓動VS.你甚至可能想創建一個新的csproj和sln文件。 – SwDevMan81 2011-02-18 03:27:10

0

You can also try closing all open files in the IDE and then building. Someone wrote up the >issue recently at Microsoft Connect: connect.microsoft.com/VisualStudio/feedback/details/644602/… – indiv

這也與Visual Studio 2010爲我工作在我的情況,我不得不關閉所有打開的文件,並重新啓動Visual Studio

相關問題