KeySet.DeriveKeys now derives both sets automatically

This commit is contained in:
Alex Barney 2020-10-13 21:34:08 -07:00
parent c99f04970f
commit 9f81b933e8
3 changed files with 14 additions and 18 deletions

View file

@ -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<KeyInfo> list = KeySet.CreateKeyInfoList();
ExternalKeyReader.ReadMainKeys(keySet, keyFile, list);

View file

@ -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);
}
}
/// <summary>
@ -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);
}
}
/// <summary>

View file

@ -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)