Hashfunktion und Saltgenerierung funktionieren wieder wie angenommen.

This commit is contained in:
ja
2021-12-22 11:23:55 +01:00
parent 7e52a02586
commit a833f5a7f6
13 changed files with 137 additions and 63 deletions

View File

@@ -4,7 +4,7 @@ Imports Konscious.Security.Cryptography
Public Class VERAG_VARIABLES
Public Shared errornumb As Integer = 0
Shared Function getiterationnumber() As Integer
Return RandomInteger(Math.Pow(2, 4), Math.Pow(2, 11))
Return RandomInteger(Math.Pow(2, 4), Math.Pow(2, 10))
End Function
Shared Sub initerrorcount()
@@ -31,25 +31,25 @@ Public Class VERAG_VARIABLES
'Dim Argon As Argon2id = New Argon2id(Encoding.UTF8.GetBytes(password))
If HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
Dim Argon As Argon2d = New Argon2d(Encoding.UTF8.GetBytes(VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(password)))
Dim Argon As Argon2id = New Argon2id(Encoding.UTF8.GetBytes(VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(password)))
Argon.Salt = salt
Argon.DegreeOfParallelism = 24
Argon.Iterations = nIterations
Argon.MemorySize = (((nIterations * 1.18 - (nIterations * 1.23) / 4 * 2) / 1.05) + 1 * 270)
Argon.Iterations = nIterations * 2
Argon.MemorySize = (((nIterations * 2.98 - (nIterations * 1.23) / 4 * 1.5) / 1.05) + 1 * 290)
Return Argon.GetBytes(nHash)
Else
Dim Argon As Argon2d = New Argon2d(Encoding.UTF8.GetBytes(VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(password)))
Argon.Salt = salt
Argon.DegreeOfParallelism = 36
Dim Argon As Argon2id = New Argon2id(Encoding.UTF8.GetBytes(VERAG_PROG_ALLGEMEIN.cCryptography3.Encrypt(password)))
Argon.Salt = GenerateSalt(nHash)
Argon.DegreeOfParallelism = 48
Argon.Iterations = nIterations * 3
Argon.MemorySize = (((nIterations * 1.385 - (nIterations * 0.56) / 1.95 * 2.28) / 5.18) + 1.024 * 316)
Argon.MemorySize = (((nIterations * 2.485 - (nIterations * 0.56) / 1.85 * 2.28) / 5.18) + 1.024 * 416)
Return Argon.GetBytes(nHash)
End If
End Function
Public Shared Function Verifyhash(ByVal passw As String, ByVal salt As Byte(), ByVal hash As Byte(), ByVal nIterations As Integer, ByVal nHash As Integer) As Boolean
Public Shared Function Verifyhash(ByVal passw As String, salt As Byte(), ByVal hash As Byte(), ByVal nIterations As Integer, ByVal nHash As Integer) As Boolean
Dim newHash As Byte() = HashPassword(passw, salt, nIterations, nHash)
Return hash.SequenceEqual(newHash)
End Function