Cleaning
This commit is contained in:
@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using System.Security.Cryptography;
|
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
@ -19,7 +17,6 @@ namespace NightmareCoreWeb2.Pages
|
|||||||
public bool IsGM { get; set; }
|
public bool IsGM { get; set; }
|
||||||
public bool IsAuthenticated = false;
|
public bool IsAuthenticated = false;
|
||||||
public Account UserAccount { get; set; }
|
public Account UserAccount { get; set; }
|
||||||
|
|
||||||
public List<Character> OnlineCharacters = new List<Character>();
|
public List<Character> OnlineCharacters = new List<Character>();
|
||||||
public List<GMTicket> Tickets = new List<GMTicket>();
|
public List<GMTicket> Tickets = new List<GMTicket>();
|
||||||
|
|
||||||
@ -28,8 +25,6 @@ namespace NightmareCoreWeb2.Pages
|
|||||||
private MySqlConnection conn;
|
private MySqlConnection conn;
|
||||||
public AccountModel(ILogger<AccountModel> logger)
|
public AccountModel(ILogger<AccountModel> logger)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
conn = new MySqlConnection(Program.connStr);
|
conn = new MySqlConnection(Program.connStr);
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
@ -47,6 +42,7 @@ namespace NightmareCoreWeb2.Pages
|
|||||||
c.AtLogin |= (Character.AtLoginOptions)action;
|
c.AtLogin |= (Character.AtLoginOptions)action;
|
||||||
}
|
}
|
||||||
c.SetAtLogin();
|
c.SetAtLogin();
|
||||||
|
Response.Redirect("/Account");
|
||||||
|
|
||||||
}
|
}
|
||||||
public void OnGet()
|
public void OnGet()
|
||||||
@ -98,8 +94,6 @@ namespace NightmareCoreWeb2.Pages
|
|||||||
this.UserAccount = a;
|
this.UserAccount = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void OnPostLogin()
|
public void OnPostLogin()
|
||||||
{
|
{
|
||||||
UserEmail = Request.Form["UserEmail"];
|
UserEmail = Request.Form["UserEmail"];
|
||||||
|
|||||||
16
SRP6.cs
16
SRP6.cs
@ -44,13 +44,6 @@ namespace Framework.Cryptography
|
|||||||
var salt = new byte[0].GenerateRandomKey(32); // random salt
|
var salt = new byte[0].GenerateRandomKey(32); // random salt
|
||||||
return (salt, CalculateVerifier(username, password, salt));
|
return (salt, CalculateVerifier(username, password, salt));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
public static (byte[] Salt, byte[] Verifier) MakeRegistrationDataFromHash(byte[] hash)
|
|
||||||
{
|
|
||||||
var salt = new byte[0].GenerateRandomKey(32); // random salt
|
|
||||||
return (salt, CalculateVerifierFromHash(hash, salt));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] CalculateVerifier(string username, string password, byte[] salt)
|
public static byte[] CalculateVerifier(string username, string password, byte[] salt)
|
||||||
{
|
{
|
||||||
@ -64,14 +57,5 @@ namespace Framework.Cryptography
|
|||||||
// v = BigInteger.ModPow(gBN, x, BN);
|
// v = BigInteger.ModPow(gBN, x, BN);
|
||||||
return BigInteger.ModPow(_g, new BigInteger(_sha1.ComputeHash(salt.Combine(hash)), true), _N).ToByteArray();
|
return BigInteger.ModPow(_g, new BigInteger(_sha1.ComputeHash(salt.Combine(hash)), true), _N).ToByteArray();
|
||||||
}
|
}
|
||||||
public static BigInteger CalculateBigIntVerifier(string username, string password, byte[] salt) {
|
|
||||||
byte[] hash = _sha1.ComputeHash(Encoding.UTF8.GetBytes(username.ToUpperInvariant() + ":" + password.ToUpperInvariant()));
|
|
||||||
return BigInteger.ModPow(_g, new BigInteger(_sha1.ComputeHash(salt.Combine(hash)), true), _N);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool CheckLogin(string username, string password, byte[] salt, byte[] verifier)
|
|
||||||
{
|
|
||||||
return verifier.Compare(CalculateVerifier(username, password, salt));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user