Ejemplo n.º 1
0
        public void ReloadKeySet()
        {
            KeySet ??= KeySet.CreateDefaultKeySet();

            string keyFile        = null;
            string titleKeyFile   = null;
            string consoleKeyFile = null;

            if (AppDataManager.Mode == AppDataManager.LaunchMode.UserProfile)
            {
                LoadSetAtPath(AppDataManager.KeysDirPathUser);
            }

            LoadSetAtPath(AppDataManager.KeysDirPath);

            void LoadSetAtPath(string basePath)
            {
                string localKeyFile        = Path.Combine(basePath, "prod.keys");
                string localTitleKeyFile   = Path.Combine(basePath, "title.keys");
                string localConsoleKeyFile = Path.Combine(basePath, "console.keys");

                if (File.Exists(localKeyFile))
                {
                    keyFile = localKeyFile;
                }

                if (File.Exists(localTitleKeyFile))
                {
                    titleKeyFile = localTitleKeyFile;
                }

                if (File.Exists(localConsoleKeyFile))
                {
                    consoleKeyFile = localConsoleKeyFile;
                }
            }

            ExternalKeyReader.ReadKeyFile(KeySet, keyFile, titleKeyFile, consoleKeyFile, null);
        }
Ejemplo n.º 2
0
        private static void OpenKeySet(Context ctx)
        {
#if CORERT_NO_REFLECTION
            string home = HomeFolder.GetFolderPath(Environment.SpecialFolder.UserProfile);
#else
            string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
#endif
            string homeTitleKeyFile   = Path.Combine(home, ".switch", "title.keys");
            string homeConsoleKeyFile = Path.Combine(home, ".switch", "console.keys");

            string prodKeyFile    = Path.Combine(home, ".switch", "prod.keys");
            string devKeyFile     = Path.Combine(home, ".switch", "dev.keys");
            string titleKeyFile   = ctx.Options.TitleKeyFile;
            string consoleKeyFile = ctx.Options.ConsoleKeyFile;

            // Check if the files from the command line exist
            if (titleKeyFile != null && !File.Exists(titleKeyFile))
            {
                titleKeyFile = null;
            }

            if (consoleKeyFile != null && !File.Exists(consoleKeyFile))
            {
                consoleKeyFile = null;
            }

            if (!File.Exists(prodKeyFile))
            {
                prodKeyFile = null;
            }

            if (!File.Exists(devKeyFile))
            {
                devKeyFile = null;
            }

            // Check the home directory if no existing key files were specified
            if (consoleKeyFile == null && File.Exists(homeConsoleKeyFile))
            {
                consoleKeyFile = homeConsoleKeyFile;
            }

            if (titleKeyFile == null && File.Exists(homeTitleKeyFile))
            {
                titleKeyFile = homeTitleKeyFile;
            }

            var keySet = KeySet.CreateDefaultKeySet();

            // 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.
            // Todo: Should we add a way that both dev-only key files and mixed prod/dev key files
            // can both be loaded when specifying a key file in dev mode?
            if (ctx.Options.Keyfile != null && File.Exists(ctx.Options.Keyfile))
            {
                keySet.SetMode(ctx.Options.KeyMode);
                ExternalKeyReader.ReadKeyFile(keySet, ctx.Options.Keyfile, titleKeyFile, consoleKeyFile, ctx.Logger);
            }
            else
            {
                ExternalKeyReader.ReadKeyFile(keySet, prodKeyFile, devKeyFile, titleKeyFile, consoleKeyFile, ctx.Logger);
            }

            keySet.SetMode(ctx.Options.KeyMode);

            if (ctx.Options.SdSeed != null)
            {
                keySet.SetSdSeed(ctx.Options.SdSeed.ToBytes());
            }

            ctx.KeySet = keySet;
        }