diff --git a/NUS Downloader/CommonKey.cs b/NUS Downloader/CommonKey.cs index fe4dfb9..7cbe4f0 100644 --- a/NUS Downloader/CommonKey.cs +++ b/NUS Downloader/CommonKey.cs @@ -21,6 +21,7 @@ namespace libWiiSharp { private static string standardKey = "ebe42a225e8593e448d9c5457381aaf7"; private static string koreanKey = "63b82bb4f4614e2e13f2fefbba4c9b7e"; + private static string dsiKey = "af1bf516a807d21aea45984f04742861"; public static byte[] GetStandardKey() { @@ -31,5 +32,10 @@ namespace libWiiSharp { return Shared.HexStringToByteArray(koreanKey); } + + public static byte[] GetDSiKey() + { + return Shared.HexStringToByteArray(dsiKey); + } } } diff --git a/NUS Downloader/Form1.cs b/NUS Downloader/Form1.cs index 859eb8b..c841ad3 100644 --- a/NUS Downloader/Form1.cs +++ b/NUS Downloader/Form1.cs @@ -99,7 +99,6 @@ namespace NUS_Downloader public Form1(string[] args) { InitializeComponent(); - //Application.DoEvents(); Debug.WriteLine("CLI Parameters passed"); GUISetup(); diff --git a/NUS Downloader/Latest/NUS Downloader.exe b/NUS Downloader/Latest/NUS Downloader.exe index 189770a..37cd0e2 100644 Binary files a/NUS Downloader/Latest/NUS Downloader.exe and b/NUS Downloader/Latest/NUS Downloader.exe differ diff --git a/NUS Downloader/NusClient.cs b/NUS Downloader/NusClient.cs index d8ee083..8c88d15 100644 --- a/NUS Downloader/NusClient.cs +++ b/NUS Downloader/NusClient.cs @@ -371,10 +371,15 @@ namespace libWiiSharp // Parse Ticket Ticket tik = new Ticket(); + if (File.Exists(Path.Combine(outputDir, "cetk"))) { fireDebug(" Parsing Ticket..."); tik = Ticket.Load(Path.Combine(outputDir, "cetk")); + + // DSi ticket? Must make sure to use DSi Key :D + if (nusUrl == DSI_NUS_URL) + tik.DSiTicket = true; } else { @@ -420,7 +425,10 @@ namespace libWiiSharp //Check SHA1 byte[] newSha = s.ComputeHash(decryptedContent); if (!Shared.CompareByteArrays(newSha, tmd.Contents[i].Hash)) - { fireDebug(@"/!\ /!\ Hashes do not match /!\ /!\"); throw new Exception(string.Format("Content #{0}: Hashes do not match!", i)); } + { + fireDebug(@"/!\ /!\ Hashes do not match /!\ /!\"); + //throw new Exception(string.Format("Content #{0}: Hashes do not match!", i)); + } //Write Decrypted Content File.WriteAllBytes(Path.Combine(outputDir, (tmd.Contents[i].ContentID.ToString("x8") + ".app")), decryptedContent); diff --git a/NUS Downloader/Ticket.cs b/NUS Downloader/Ticket.cs index 8f9e071..44b6c69 100644 --- a/NUS Downloader/Ticket.cs +++ b/NUS Downloader/Ticket.cs @@ -58,6 +58,8 @@ namespace libWiiSharp private uint timeLimit; private byte[] padding4 = new byte[88]; + private bool dsitik = false; + /// /// The Title Key the WADs content is encrypted with. /// @@ -91,6 +93,11 @@ namespace libWiiSharp /// public bool TitleKeyChanged { get { return titleKeyChanged; } } + /// + /// If true, the Ticket will utilize the DSi CommonKey. + /// + public bool DSiTicket { get { return dsitik; } set { dsitik = value; decryptTitleKey(); } } + #region IDisposable Members private bool isDisposed = false; @@ -532,7 +539,14 @@ namespace libWiiSharp private void decryptTitleKey() { - byte[] ckey = (commonKeyIndex == 0x01) ? CommonKey.GetKoreanKey() : CommonKey.GetStandardKey(); + byte[] ckey; + if (dsitik) + { + Console.WriteLine("dsi key in ya house!"); + ckey = CommonKey.GetDSiKey(); + } + else + ckey = (commonKeyIndex == 0x01) ? CommonKey.GetKoreanKey() : CommonKey.GetStandardKey(); byte[] iv = BitConverter.GetBytes(Shared.Swap(titleId)); Array.Resize(ref iv, 16); @@ -560,7 +574,11 @@ namespace libWiiSharp private void encryptTitleKey() { commonKeyIndex = newKeyIndex; - byte[] ckey = (commonKeyIndex == 0x01) ? CommonKey.GetKoreanKey() : CommonKey.GetStandardKey(); + byte[] ckey; + if (dsitik) + ckey = CommonKey.GetDSiKey(); + else + ckey = (commonKeyIndex == 0x01) ? CommonKey.GetKoreanKey() : CommonKey.GetStandardKey(); byte[] iv = BitConverter.GetBytes(Shared.Swap(titleId)); Array.Resize(ref iv, 16);