mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-04-25 08:04:27 -05:00
Implemented &data= hash and length check.
This commit is contained in:
parent
d00c1a3ac2
commit
bf956a9260
|
|
@ -12,13 +12,10 @@ namespace PkmnFoundations.GTS
|
|||
{
|
||||
public partial class BattleVideo : System.Web.UI.Page
|
||||
{
|
||||
protected void Page_Init(object sender, EventArgs e)
|
||||
{
|
||||
litMessage.Text = "";
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
litMessage.Text = "";
|
||||
|
||||
using (MySqlConnection db = CreateConnection())
|
||||
{
|
||||
db.Open();
|
||||
|
|
|
|||
|
|
@ -58,7 +58,12 @@ namespace PkmnFoundations.GTS
|
|||
rand = DecryptRNG(rand);
|
||||
data3[pos] = (byte)(data2[pos + 4] ^ (byte)(rand >> 16));
|
||||
}
|
||||
// todo: validate checksum
|
||||
|
||||
int checkedsum = 0;
|
||||
foreach (byte b in data3)
|
||||
checkedsum += b;
|
||||
|
||||
if (checkedsum != checksum) throw new FormatException("Data checksum is incorrect.");
|
||||
|
||||
return data3;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,13 @@ namespace PkmnFoundations.GTS
|
|||
// the ashx to check for pids to match.
|
||||
// todo: prune first 12 bytes, pass pid to this function to validate
|
||||
Array.Copy(data2, 4, data3, 0, data2.Length - 4);
|
||||
// todo: validate checksum and length
|
||||
|
||||
if (length + 8 != data3.Length) throw new FormatException("Data length is incorrect.");
|
||||
int checkedsum = 0;
|
||||
foreach (byte b in data3)
|
||||
checkedsum += b;
|
||||
|
||||
if (checkedsum != checksum) throw new FormatException("Data checksum is incorrect.");
|
||||
|
||||
return data3;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,14 +10,9 @@ namespace PkmnFoundations.GTS.debug
|
|||
{
|
||||
public partial class Decode : System.Web.UI.Page
|
||||
{
|
||||
protected void Page_Init(object sender, EventArgs e)
|
||||
{
|
||||
litMessage.Text = "";
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
litMessage.Text = "";
|
||||
}
|
||||
|
||||
protected void btnDecode_Click(object sender, EventArgs e)
|
||||
|
|
@ -29,8 +24,6 @@ namespace PkmnFoundations.GTS.debug
|
|||
{
|
||||
data = GtsSession4.DecryptData(txtData.Text);
|
||||
litGeneration.Text = "4";
|
||||
// todo: genIV is always valid so genV never gets detected
|
||||
// need to validate checksum and error there
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user