private static KeySet CreateKeySet() { var keySet = new KeySet(); // Populate the key set with all the keys in IncludedKeys.txt using (Stream keyFile = GetResource(InputMainKeyFileName)) { List <KeyInfo> list = KeySet.CreateKeyInfoList(); ExternalKeyReader.ReadMainKeys(keySet, keyFile, list); } // Recover all the RSA key parameters and write the key to the key set RSAParameters betaNca0Params = Rsa.RecoverParameters(BetaNca0Modulus, StandardPublicExponent, BetaNca0Exponent); betaNca0Params.D.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.PrivateExponent.Data); betaNca0Params.DP.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.Dp.Data); betaNca0Params.DQ.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.Dq.Data); betaNca0Params.Exponent.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.PublicExponent.Data); betaNca0Params.InverseQ.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.InverseQ.Data); betaNca0Params.Modulus.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.Modulus.Data); betaNca0Params.P.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.P.Data); betaNca0Params.Q.AsSpan().CopyTo(keySet.BetaNca0KeyAreaKey.Q.Data); // First populate the prod RSA keys keySet.SetMode(KeySet.Mode.Prod); StandardPublicExponent.CopyTo(keySet.NcaHeaderSigningKeys[0].PublicExponent.Data); StandardPublicExponent.CopyTo(keySet.NcaHeaderSigningKeys[1].PublicExponent.Data); NcaHdrFixedKeyModulus0Prod.CopyTo(keySet.NcaHeaderSigningKeys[0].Modulus.Data); NcaHdrFixedKeyModulus1Prod.CopyTo(keySet.NcaHeaderSigningKeys[1].Modulus.Data); StandardPublicExponent.CopyTo(keySet.AcidSigningKeys[0].PublicExponent.Data); StandardPublicExponent.CopyTo(keySet.AcidSigningKeys[1].PublicExponent.Data); AcidFixedKeyModulus0Prod.CopyTo(keySet.AcidSigningKeys[0].Modulus.Data); AcidFixedKeyModulus1Prod.CopyTo(keySet.AcidSigningKeys[1].Modulus.Data); StandardPublicExponent.CopyTo(keySet.Package2SigningKey.PublicExponent.Data); Package2FixedKeyModulusProd.CopyTo(keySet.Package2SigningKey.Modulus.Data); // Populate the dev RSA keys keySet.SetMode(KeySet.Mode.Dev); StandardPublicExponent.CopyTo(keySet.NcaHeaderSigningKeys[0].PublicExponent.Data); StandardPublicExponent.CopyTo(keySet.NcaHeaderSigningKeys[1].PublicExponent.Data); NcaHdrFixedKeyModulus0Dev.CopyTo(keySet.NcaHeaderSigningKeys[0].Modulus.Data); NcaHdrFixedKeyModulus1Dev.CopyTo(keySet.NcaHeaderSigningKeys[1].Modulus.Data); StandardPublicExponent.CopyTo(keySet.AcidSigningKeys[0].PublicExponent.Data); StandardPublicExponent.CopyTo(keySet.AcidSigningKeys[1].PublicExponent.Data); AcidFixedKeyModulus0Dev.CopyTo(keySet.AcidSigningKeys[0].Modulus.Data); AcidFixedKeyModulus1Dev.CopyTo(keySet.AcidSigningKeys[1].Modulus.Data); StandardPublicExponent.CopyTo(keySet.Package2SigningKey.PublicExponent.Data); Package2FixedKeyModulusDev.CopyTo(keySet.Package2SigningKey.Modulus.Data); return(keySet); }