Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2012 PBFKDF2 implementation for WPA

$
0
0
I'm trying to basically reproduce this hxxp://jorisvr.nl/wpapsk.html

this page shows you the WPA key calculation when it takes your password and the ssid to make the pre shared key. I have reproduced it except for the salt error that needs at least 8 bytes. I put in a random 8 bytes just to see and it works but again its random so it doesn't match the keys. So how do I get Rfc2898DeriveBytes (microsofts implementation) to match the PBFKDF2 implementation? So as long as the SSID is at least 8 characters it works.

here is the code
Code:

Public Function WPA(password As String, ssid As String, iterations As Integer, keylength As Integer)
        Dim strReturn As String = Nothing
        Dim salt1(8) As Byte
        If ssid.Length < 8 Then

            Using rngCsp As New System.Security.Cryptography.RNGCryptoServiceProvider
                rngCsp.GetBytes(salt1)
            End Using

        Else
            salt1 = System.Text.Encoding.UTF8.GetBytes(ssid)
        End If

        Dim rfc2898 As New Security.Cryptography.Rfc2898DeriveBytes(password, salt1, iterations)
        Dim ByteHash() As Byte = rfc2898.GetBytes(keylength)
        For Each b As Byte In ByteHash
            strReturn &= b.ToString("x2")
        Next

        Return strReturn
    End Function


Usage
Code:

TextBox1.Text = WPA(password, ssid, 4096, 32)
Any help would be appreciated.

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>