Änderungen dass Async-Funktionen wieder synchron laufen. Das ändert nichts an geschwidnigkeit da es eh schon lanes in argon2 gibt, welche mehr Kerne oder threads zur Hasung benutzen.

This commit is contained in:
ja
2021-12-17 10:55:54 +01:00
parent e0a200ecdd
commit 0815ba086d
8 changed files with 122 additions and 59 deletions

View File

@@ -129,7 +129,7 @@ Partial Class login_Change_PW
MsgBox("")
End Sub
Protected Async Sub btn_submitpw_Click(sender As Object, e As EventArgs)
Protected Sub btn_submitpw_Click(sender As Object, e As EventArgs)
Dim tempstr As String = ""
Dim UsernameDB As String = String.Empty
Dim pwDB As String = String.Empty
@@ -240,10 +240,10 @@ Partial Class login_Change_PW
ConnectionString = "Server=DEVELOPER.verag.ost.dmn\DEVSQL;Database=VERAG_HOMEPAGE;Uid=AppUser;Pwd=yp/THDd?xM+pZ$;"
'ConnectionString = "Server=db593295684.db.1and1.com;Database=db593295684;Uid=dbo593295684;Pwd=atilla#2;"
End If
Dim isPasswhash As Byte() = Await gensaltPasswAsync(usrname, tempstr, salt, intzahliterats, intzahl, Email, Session.IsNewSession)
Dim isPasswDBhash As Byte() = Await gensaltPasswAsync(UsernameDB, pwDB, salt, intzahliterats, intzahl, EmailDB, Session.IsNewSession)
Dim isPasswhash As Byte() = gensaltPassw(usrname, tempstr, salt, intzahliterats, intzahl, Email, Session.IsNewSession)
Dim isPasswDBhash As Byte() = gensaltPassw(UsernameDB, pwDB, salt, intzahliterats, intzahl, EmailDB, Session.IsNewSession)
If regexval_txt_Pw.IsValid = True Then
If Await VERAG_VARIABLES.Verifyhash(txt_Pw.Text, salt, isPasswhash, intzahliterats, intzahl) = True And Await VERAG_VARIABLES.Verifyhash(txt_Pw_WH.Text, salt, Await VERAG_VARIABLES.HashPassword(txt_Pw.Text, salt, intzahliterats, intzahl), intzahliterats, intzahl) = True Then
If VERAG_VARIABLES.Verifyhash(txt_Pw.Text, salt, isPasswhash, intzahliterats, intzahl) = True And VERAG_VARIABLES.Verifyhash(txt_Pw_WH.Text, salt, VERAG_VARIABLES.HashPassword(txt_Pw.Text, salt, intzahliterats, intzahl), intzahliterats, intzahl) = True Then
Using con As New SqlConnection(ConnectionString)
Using cmd As New SqlCommand("UPDATE [VERAG_HOMEPAGE].[dbo].[Users] SET [Password]=@Password WHERE [Username]=@Username AND [UserId]=@UserId")
' cmd.CommandType = CommandType.StoredProcedure
@@ -356,7 +356,7 @@ Partial Class login_Change_PW
End If
End Sub
Protected Async Sub btn_submitpw_M_Click(sender As Object, e As EventArgs)
Protected Sub btn_submitpw_M_Click(sender As Object, e As EventArgs)
Dim tempstr As String = ""
Dim pwDB As String = String.Empty
Dim EmailDB As String = String.Empty
@@ -459,10 +459,10 @@ Partial Class login_Change_PW
End If
Using con As New SqlConnection(ConnectionString)
Dim isPasswhash As Byte() = Await gensaltPasswAsync(usrname, tempstr, salt, intzahliterats, intzahl, Email, Session.IsNewSession)
Dim isPasswDBhash As Byte() = Await gensaltPasswAsync(usrnmDB, pwDB, salt, intzahliterats, intzahl, EmailDB, Session.IsNewSession)
Dim isPasswhash As Byte() = gensaltPassw(usrname, tempstr, salt, intzahliterats, intzahl, Email, Session.IsNewSession)
Dim isPasswDBhash As Byte() = gensaltPassw(usrnmDB, pwDB, salt, intzahliterats, intzahl, EmailDB, Session.IsNewSession)
If regexval_txt_Pw.IsValid = True Then
If Await VERAG_VARIABLES.Verifyhash(tempstr, salt, isPasswhash, intzahliterats, intzahl) = True AndAlso Await VERAG_VARIABLES.Verifyhash(pwDB, salt, isPasswDBhash, intzahliterats, intzahl) = True Then
If VERAG_VARIABLES.Verifyhash(tempstr, salt, isPasswhash, intzahliterats, intzahl) = True AndAlso VERAG_VARIABLES.Verifyhash(pwDB, salt, isPasswDBhash, intzahliterats, intzahl) = True Then
Using cmd As New SqlCommand("UPDATE [VERAG_HOMEPAGE].[dbo].[Users] SET Password=@Password WHERE Username=@Username AND UserId=@UserId")
' cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@Username", usrname)
@@ -528,17 +528,17 @@ Partial Class login_Change_PW
End If
End Sub
Async Function gensaltPasswAsync(username As String, password As String, salt As Byte(), intzahliterats As Integer, intzahl As Integer, email As String, isnewSession As Boolean) As Task(Of Byte())
Function gensaltPassw(username As String, password As String, salt As Byte(), intzahliterats As Integer, intzahl As Integer, email As String, isnewSession As Boolean) As Byte()
If isnewSession = False Then
Dim token As Byte()
'Dim tok As Byte = Convert.ToBase64String(time.Concat(Key).ToArray())
Dim tok As String = password
token = Await VERAG_VARIABLES.HashPassword(password, salt, intzahliterats, intzahl)
token = VERAG_VARIABLES.HashPassword(password, salt, intzahliterats, intzahl)
Return token
End If
End Function
Async Function gennewsaltToken(username As String, password As String, email As String, salt As Byte(), CustomerID As String, intzahlits As Integer, intzahl As Integer, isnewSession As Boolean, theUserID As String) As Task(Of String)
Function gennewsaltToken(username As String, password As String, email As String, salt As Byte(), CustomerID As String, intzahlits As Integer, intzahl As Integer, isnewSession As Boolean, theUserID As String) As String
If isnewSession = False Then
Dim time() As Byte = BitConverter.GetBytes(DateTime.UtcNow.ToBinary())
Dim Key() As Byte = Guid.NewGuid().ToByteArray()
@@ -547,7 +547,7 @@ Partial Class login_Change_PW
If String.IsNullOrEmpty(theUserID) = False Then
Dim tok As String = Convert.ToBase64String(time.Concat(Key).ToArray())
token = Await VERAG_VARIABLES.HashPassword(tok, salt, intzahlits, intzahl)
token = VERAG_VARIABLES.HashPassword(tok, salt, intzahlits, intzahl)
Return VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(Convert.ToBase64String(token))
Else
@@ -558,13 +558,13 @@ Partial Class login_Change_PW
End If
End Function
Async Function gensaltTokenAsync(STrings As String) As Task(Of String)
Function gensaltTokenAsync(STrings As String) As String
If String.IsNullOrEmpty(STrings) = False Then
Dim token As Byte()
Dim salt As Byte() = VERAG_VARIABLES.GenerateSalt(intzahl)
Dim tok As String = STrings
token = Await VERAG_VARIABLES.HashPassword(tok, salt, intzahliterats, intzahl)
token = VERAG_VARIABLES.HashPassword(tok, salt, intzahliterats, intzahl)
Return Convert.ToBase64String(token)