hactoolnet: Add disablekeywarns option

This commit is contained in:
Alex Barney 2021-11-17 11:47:44 -07:00
parent 80e7466840
commit 01ecd31110
3 changed files with 7 additions and 2 deletions

View file

@ -15,6 +15,7 @@ internal static class CliParser
new CliOption("verify", 'y', 0, (o, _) => o.Validate = true), new CliOption("verify", 'y', 0, (o, _) => o.Validate = true),
new CliOption("dev", 'd', 0, (o, _) => o.UseDevKeys = true), new CliOption("dev", 'd', 0, (o, _) => o.UseDevKeys = true),
new CliOption("enablehash", 'h', 0, (o, _) => o.EnableHash = true), new CliOption("enablehash", 'h', 0, (o, _) => o.EnableHash = true),
new CliOption("disablekeywarns", 0, (o, _) => o.DisableKeyWarns = true),
new CliOption("keyset", 'k', 1, (o, a) => o.Keyfile = a[0]), new CliOption("keyset", 'k', 1, (o, a) => o.Keyfile = a[0]),
new CliOption("titlekeys", 1, (o, a) => o.TitleKeyFile = a[0]), new CliOption("titlekeys", 1, (o, a) => o.TitleKeyFile = a[0]),
new CliOption("consolekeys", 1, (o, a) => o.ConsoleKeyFile = a[0]), new CliOption("consolekeys", 1, (o, a) => o.ConsoleKeyFile = a[0]),
@ -208,6 +209,7 @@ internal static class CliParser
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(" -t, --intype=type Specify input file type [nca, xci, romfs, pfs0, pk11, pk21, ini1, kip1, switchfs, save, ndv0, keygen, romfsbuild, pfsbuild]");
sb.AppendLine(" --titlekeys <file> Load title keys from an external file."); sb.AppendLine(" --titlekeys <file> Load title keys from an external file.");
sb.AppendLine(" --accesslog <file> Specify the access log file path."); sb.AppendLine(" --accesslog <file> Specify the access log file path.");
sb.AppendLine(" --disablekeywarns Disables warning output when loading external keys.");
sb.AppendLine("NCA options:"); sb.AppendLine("NCA options:");
sb.AppendLine(" --plaintext <file> Specify file path for saving a decrypted copy of the NCA."); sb.AppendLine(" --plaintext <file> Specify file path for saving a decrypted copy of the NCA.");
sb.AppendLine(" --ciphertext <file> Specify file path for saving an encrypted copy of the NCA."); sb.AppendLine(" --ciphertext <file> Specify file path for saving an encrypted copy of the NCA.");

View file

@ -13,6 +13,7 @@ internal class Options
public bool Validate; public bool Validate;
public bool UseDevKeys; public bool UseDevKeys;
public bool EnableHash; public bool EnableHash;
public bool DisableKeyWarns;
public string Keyfile; public string Keyfile;
public string TitleKeyFile; public string TitleKeyFile;
public string ConsoleKeyFile; public string ConsoleKeyFile;

View file

@ -221,6 +221,8 @@ public static class Program
var keySet = KeySet.CreateDefaultKeySet(); var keySet = KeySet.CreateDefaultKeySet();
var logger = ctx.Options.DisableKeyWarns ? null : ctx.Logger;
// If the user specifies a key file then only load that file into the mode they specified, // If the user specifies a key file then only load that file into the mode they specified,
// otherwise load both prod.keys and dev.keys. // otherwise load both prod.keys and dev.keys.
// Todo: Should we add a way that both dev-only key files and mixed prod/dev key files // Todo: Should we add a way that both dev-only key files and mixed prod/dev key files
@ -228,11 +230,11 @@ public static class Program
if (ctx.Options.Keyfile != null && File.Exists(ctx.Options.Keyfile)) if (ctx.Options.Keyfile != null && File.Exists(ctx.Options.Keyfile))
{ {
keySet.SetMode(ctx.Options.KeyMode); keySet.SetMode(ctx.Options.KeyMode);
ExternalKeyReader.ReadKeyFile(keySet, ctx.Options.Keyfile, titleKeyFile, consoleKeyFile, ctx.Logger); ExternalKeyReader.ReadKeyFile(keySet, ctx.Options.Keyfile, titleKeyFile, consoleKeyFile, logger);
} }
else else
{ {
ExternalKeyReader.ReadKeyFile(keySet, prodKeyFile, devKeyFile, titleKeyFile, consoleKeyFile, ctx.Logger); ExternalKeyReader.ReadKeyFile(keySet, prodKeyFile, devKeyFile, titleKeyFile, consoleKeyFile, logger);
} }
keySet.SetMode(ctx.Options.KeyMode); keySet.SetMode(ctx.Options.KeyMode);