2

嘿,我試圖比較我的數據庫中的密碼,使用我的ASP.net頁面時,我收到此錯誤。ASP.net此實現不是Windows平臺FIPS驗證的加密算法的一部分

此實現不是Windows平臺FIPS驗證的加密算法的一部分。

的代碼看起來是這樣的:

Public Shared Function UserAuthentication(ByVal user As String, ByVal pass As String) As WebUserSession 
    Dim strSQL As String = "" 
    Dim strForEncryption As String = pass 
    Dim result As Byte() 
    Dim sHA1Managed As SHA1 = New SHA1Managed() 
    Dim encryptedString As New System.Text.StringBuilder() 

    result = sHA1Managed.ComputeHash(ASCIIEncoding.ASCII.GetBytes(pass)) 

    For Each outputByte As Byte In result 
    'convert each byte to a Hexadecimal upper case string 
    encryptedString.Append(outputByte.ToString("x2").ToUpper()) 
    Next 

    strSQL &= "SELECT email, name, id, permission_id, username FROM (user) INNER JOIN user_per ON user.id = user_per.user_id " 
    strSQL &= "WHERE(username = '" & user & "' And password = '" & encryptedString.ToString() & "')" 

我們最近不得不更新/鎖定我們的服務器是符合安全漏洞等。但是這樣做會導致我們在同一臺服務器上託管的其中一個網站出現此錯誤。在所有這些安全設置之前,網站工作得很好。

奇怪的是,我能夠在VS 2010中運行本地網站(調試模式),它沒有問題。根本沒有錯誤。

有沒有人有關於如何解決這個問題的任何提示,以使網站再次運行,就像我們在添加所有這些安全設置之前所做的那樣。我們不能只是禁用它,因爲這會導致我們的其他網站不符合要求。

我已經嘗試過這些網頁上的建議: http://blogs.msdn.com/b/brijs/archive/2010/08/10/issue-getting-this-implementation-is-not-part-of-the-windows-platform-fips-validated-cryptographic-algorithms-exception-while-building-outlook-vsto-add-in-in-vs-2010.aspx

http://social.msdn.microsoft.com/Forums/en/clr/thread/7a62c936-b3cc-4493-a3cd-cc5fd18b6b2a

http://support.microsoft.com/kb/935434

http://blogs.iis.net/webtopics/archive/2009/07/20/parser-error-message-this-implementation-is-not-part-of-the-windows-platform-fips-validated-cryptographic-algorithms-when-net-page-has-debug-true.aspx

http://blog.aggregatedintelligence.com/2007/10/fips-validated-cryptographic-algorithms.html

感謝。

從字符串 「S51998Dg5」 轉換到類型 '整數' 是無效的:

使用此代碼以及

Dim p As String = Password.Text.ToString 
Dim data(p) As Byte 
Dim result() As Byte 
Dim sha As New SHA1CryptoServiceProvider() 

result = sha.ComputeHash(data) 

的錯誤是嘗試。

這誤差是就行:昏暗數據(P)作爲字節

+0

debug = false在web.config? –

+0

**應該永遠不可能解碼密碼**。密碼應該是散列的,而不是加密的。 – SLaks

+0

糾錯@SLaks:解碼=比較。 – StealthRT

回答

3

根據this sha1managed不是FIPS兼容。它會引發InvalidOperationException,因爲此類不符合FIPS算法。

您需要解除FIPS合規性或使用符合FIPS的實施。 sha1cryptoserviceprovider我認爲是FIPS投訴。

+0

似乎並沒有得以順利(或者我不能讓它在代碼中工作)。我們已經在SHA1中對密碼進行了散列處理,因此在將輸入密碼的用戶與db上的散列進行比較時,它們不會相同。我一直收到的錯誤是**從字符串「S51998Dg5」轉換爲類型「整數」無效。** – StealthRT

+0

檢查OP的代碼。 – StealthRT

+0

所以我現在不是VB,只是C#,但它看起來像你應該能夠在您發佈的原始代碼中用sha1cryptoserviceprovider(在c#中,您需要更改變量實例的類型)替換sha1managed 。您不需要添加數據調用,只需使用ASCIIEncoding.ASCII.GetBytes(pass)即可。如果這不起作用,您可以禁用系統上的FIPS兼容性。除非你爲國防部或銀行編寫代碼,否則不應該在意。 – imichaelmiers

相關問題