From d288a24c4e6da7996936a89d8ed1a7890067b3ce Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Thu, 14 Mar 2019 18:00:52 -0500 Subject: [PATCH] hactoolnet: Add option to load keys from dev.keys --- src/NandReader/Program.cs | 1 - src/hactoolnet/CliParser.cs | 2 ++ src/hactoolnet/Options.cs | 1 + src/hactoolnet/Program.cs | 6 ++++-- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/NandReader/Program.cs b/src/NandReader/Program.cs index fcc49f72..f7cd5f3c 100644 --- a/src/NandReader/Program.cs +++ b/src/NandReader/Program.cs @@ -51,7 +51,6 @@ namespace NandReader var nand = new Nand(stream, keyset); FatFileSystemProvider user = nand.OpenSystemPartition(); SwitchFs sdfs = SwitchFs.OpenNandPartition(keyset, user); - ; } } diff --git a/src/hactoolnet/CliParser.cs b/src/hactoolnet/CliParser.cs index 47fc86ad..ef744c35 100644 --- a/src/hactoolnet/CliParser.cs +++ b/src/hactoolnet/CliParser.cs @@ -13,6 +13,7 @@ namespace hactoolnet new CliOption("intype", 't', 1, (o, a) => o.InFileType = ParseFileType(a[0])), new CliOption("raw", 'r', 0, (o, a) => o.Raw = true), new CliOption("verify", 'y', 0, (o, a) => o.Validate = true), + new CliOption("dev", 'd', 0, (o, a) => o.UseDevKeys = true), new CliOption("enablehash", 'h', 0, (o, a) => o.EnableHash = true), new CliOption("keyset", 'k', 1, (o, a) => o.Keyfile = a[0]), new CliOption("titlekeys", 1, (o, a) => o.TitleKeyFile = a[0]), @@ -162,6 +163,7 @@ namespace hactoolnet sb.AppendLine(" -r, --raw Keep raw data, don\'t unpack."); sb.AppendLine(" -y, --verify Verify all hashes in the input file."); sb.AppendLine(" -h, --enablehash Enable hash checks when reading the input file."); + sb.AppendLine(" -d, --dev Decrypt with development keys instead of retail."); sb.AppendLine(" -k, --keyset Load keys from an external file."); sb.AppendLine(" -t, --intype=type Specify input file type [nca, xci, romfs, pfs0, pk11, pk21, ini1, kip1, switchfs, save, ndv0, keygen, romfsbuild, pfsbuild]"); sb.AppendLine(" --titlekeys Load title keys from an external file."); diff --git a/src/hactoolnet/Options.cs b/src/hactoolnet/Options.cs index fd0cbc05..17fdbf15 100644 --- a/src/hactoolnet/Options.cs +++ b/src/hactoolnet/Options.cs @@ -10,6 +10,7 @@ namespace hactoolnet public FileType InFileType = FileType.Nca; public bool Raw; public bool Validate; + public bool UseDevKeys; public bool EnableHash; public string Keyfile; public string TitleKeyFile; diff --git a/src/hactoolnet/Program.cs b/src/hactoolnet/Program.cs index d2445d29..fa683f20 100644 --- a/src/hactoolnet/Program.cs +++ b/src/hactoolnet/Program.cs @@ -113,8 +113,10 @@ namespace hactoolnet private static void OpenKeyset(Context ctx) { + string keyFileName = ctx.Options.UseDevKeys ? "dev.keys" : "prod.keys"; + string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - string homeKeyFile = Path.Combine(home, ".switch", "prod.keys"); + string homeKeyFile = Path.Combine(home, ".switch", keyFileName); string homeTitleKeyFile = Path.Combine(home, ".switch", "title.keys"); string homeConsoleKeyFile = Path.Combine(home, ".switch", "console.keys"); string keyFile = ctx.Options.Keyfile; @@ -147,7 +149,7 @@ namespace hactoolnet string dir = ctx.Options.OutDir; Directory.CreateDirectory(dir); - File.WriteAllText(Path.Combine(dir, "prod.keys"), ExternalKeys.PrintCommonKeys(ctx.Keyset)); + File.WriteAllText(Path.Combine(dir, keyFileName), ExternalKeys.PrintCommonKeys(ctx.Keyset)); File.WriteAllText(Path.Combine(dir, "console.keys"), ExternalKeys.PrintUniqueKeys(ctx.Keyset)); File.WriteAllText(Path.Combine(dir, "title.keys"), ExternalKeys.PrintTitleKeys(ctx.Keyset)); }