diff --git a/build/CodeGen/Stage2/KeysCodeGen.cs b/build/CodeGen/Stage2/KeysCodeGen.cs index 4077ba5a..c9eee6e7 100644 --- a/build/CodeGen/Stage2/KeysCodeGen.cs +++ b/build/CodeGen/Stage2/KeysCodeGen.cs @@ -91,7 +91,7 @@ namespace LibHacBuild.CodeGen.Stage2 var keySet = new KeySet(); // Populate the key set with all the keys in IncludedKeys.txt - using (Stream keyFile = Common.GetResource(InputMainKeyFileName)) + using (Stream keyFile = GetResource(InputMainKeyFileName)) { List list = KeySet.CreateKeyInfoList(); ExternalKeyReader.ReadMainKeys(keySet, keyFile, list); diff --git a/src/LibHac/Common/Keys/ExternalKeyReader.cs b/src/LibHac/Common/Keys/ExternalKeyReader.cs index 34c14cc6..cbe476ff 100644 --- a/src/LibHac/Common/Keys/ExternalKeyReader.cs +++ b/src/LibHac/Common/Keys/ExternalKeyReader.cs @@ -67,14 +67,6 @@ namespace LibHac.Common.Keys } keySet.DeriveKeys(logger); - - // Dev keys can be read from prod key files, so derive any missing keys if necessary. - if (keySet.CurrentMode == KeySet.Mode.Prod) - { - keySet.SetMode(KeySet.Mode.Dev); - keySet.DeriveKeys(logger); - keySet.SetMode(KeySet.Mode.Prod); - } } /// @@ -122,14 +114,6 @@ namespace LibHac.Common.Keys } keySet.DeriveKeys(logger); - - // Dev keys can read from prod key files, so derive any missing keys if necessary. - if (keySet.CurrentMode == KeySet.Mode.Prod) - { - keySet.SetMode(KeySet.Mode.Dev); - keySet.DeriveKeys(logger); - keySet.SetMode(KeySet.Mode.Prod); - } } /// diff --git a/src/LibHac/Common/Keys/KeySet.cs b/src/LibHac/Common/Keys/KeySet.cs index 490809fb..79b7e32c 100644 --- a/src/LibHac/Common/Keys/KeySet.cs +++ b/src/LibHac/Common/Keys/KeySet.cs @@ -207,7 +207,19 @@ namespace LibHac.Common.Keys return DefaultKeySet.CreateKeyList(); } - public void DeriveKeys(IProgressReport logger = null) => KeyDerivation.DeriveAllKeys(this, logger); + public void DeriveKeys(IProgressReport logger = null) + { + Mode originalMode = CurrentMode; + + SetMode(Mode.Prod); + KeyDerivation.DeriveAllKeys(this, logger); + + SetMode(Mode.Dev); + KeyDerivation.DeriveAllKeys(this, logger); + + SetMode(originalMode); + } + public void DeriveSdCardKeys() => KeyDerivation.DeriveSdCardKeys(this); private static RSAParameters CreateRsaParameters(in RsaKey key)