From 1036ee3ccb7a62955eabd9280f37e99ec8ae9045 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sun, 15 May 2016 15:29:36 -0700 Subject: [PATCH] Simplify past gen crypto methods Seed bypass used by PGT supplied checksum; this is what the fixed methods do already (so remove the parameter). --- Misc/PGT.cs | 2 +- Misc/PKM.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Misc/PGT.cs b/Misc/PGT.cs index 1ed29fe66..79ff137bc 100644 --- a/Misc/PGT.cs +++ b/Misc/PGT.cs @@ -38,7 +38,7 @@ public PGT(byte[] data = null) byte[] ekdata = new byte[PK4.SIZE_PARTY]; Array.Copy(Data, 8, ekdata, 0, ekdata.Length); // Decrypt PK4 - PK = new PK4(PKM.decryptArray(ekdata, BitConverter.ToUInt16(ekdata, 6))); + PK = new PK4(PKM.decryptArray(ekdata)); Unknown = new byte[0x10]; Array.Copy(Data, 0xF4, Unknown, 0, 0x10); diff --git a/Misc/PKM.cs b/Misc/PKM.cs index 892d6d2c5..7b0f9fca7 100644 --- a/Misc/PKM.cs +++ b/Misc/PKM.cs @@ -68,7 +68,7 @@ internal static byte[] shuffleArray(byte[] data, uint sv) return sdata; } - internal static byte[] decryptArray(byte[] ekm, uint seed = 0x10000) + internal static byte[] decryptArray(byte[] ekm) { byte[] pkm = (byte[])ekm.Clone(); @@ -76,7 +76,7 @@ internal static byte[] decryptArray(byte[] ekm, uint seed = 0x10000) uint chk = BitConverter.ToUInt16(pkm, 6); uint sv = ((pv & 0x3E000) >> 0xD) % 24; - seed = seed > 0xFFFF ? chk : seed; + uint seed = chk; // Decrypt Blocks with RNG Seed for (int i = 8; i < 136; i += 2) @@ -93,7 +93,7 @@ internal static byte[] decryptArray(byte[] ekm, uint seed = 0x10000) return pkm; } - internal static byte[] encryptArray(byte[] pkm, uint seed = 0x10000) + internal static byte[] encryptArray(byte[] pkm) { uint pv = BitConverter.ToUInt32(pkm, 0); uint sv = ((pv & 0x3E000) >> 0xD) % 24; @@ -103,7 +103,7 @@ internal static byte[] encryptArray(byte[] pkm, uint seed = 0x10000) ekm = shuffleArray(ekm, blockPositionInvert[sv]); - seed = seed > 0xFFFF ? chk : seed; + uint seed = chk; // Encrypt Blocks with RNG Seed for (int i = 8; i < 136; i += 2)