From 3edafc6802a7836bf4e9c1a4751b9b45316d9855 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 23 Sep 2018 21:06:33 -0400 Subject: qt: Add key derivation progress bar on initial setup --- src/yuzu/main.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index e11833c5a..48d7833b2 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -31,6 +31,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include #include #include +#include #include #include #include @@ -171,6 +172,57 @@ GMainWindow::GMainWindow() .arg(Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc)); show(); + // Gen keys if necessary + Core::Crypto::KeyManager keys{}; + if (keys.BaseDeriveNecessary()) { + Core::Crypto::PartitionDataManager pdm{vfs->OpenDirectory( + FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir), FileSys::Mode::Read)}; + + const auto function = [this, &keys, &pdm]() { + keys.PopulateFromPartitionData(pdm); + Service::FileSystem::CreateFactories(vfs); + keys.DeriveETicket(pdm); + }; + + std::vector errors; + + if (!pdm.HasFuses()) + errors.push_back("Missing fuses - Cannot derive SBK"); + if (!pdm.HasBoot0()) + errors.push_back("Missing BOOT0 - Cannot derive master keys"); + if (!pdm.HasPackage2()) + errors.push_back("Missing BCPKG2-1-Normal-Main - Cannot derive general keys"); + if (!pdm.HasProdInfo()) + errors.push_back("Missing PRODINFO - Cannot derive title keys"); + + if (!errors.empty()) { + std::string error_str; + for (const auto& error : errors) + error_str += " - " + error + "\n"; + + QMessageBox::warning( + this, tr("Warning Missing Derivation Components"), + tr("The following are missing from your configuration that may hinder key " + "derivation. It will be attempted but may not complete.\n\n") + + QString::fromStdString(error_str)); + } + + QProgressDialog prog; + prog.setRange(0, 0); + prog.setLabelText(tr("Deriving keys...\nThis may take up to a minute depending \non your " + "system's performance.")); + prog.setWindowTitle(tr("Deriving Keys")); + + prog.show(); + + auto future = QtConcurrent::run(function); + while (!future.isFinished()) { + QCoreApplication::processEvents(); + } + + prog.close(); + } + // Necessary to load titles from nand in gamelist. Service::FileSystem::CreateFactories(vfs); game_list->LoadCompatibilityList(); -- cgit v1.2.3 From 8f958b89e713be88da516db57da4a2de7a15f093 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 23 Sep 2018 21:35:32 -0400 Subject: qt: Add rederive keyset menu option --- src/yuzu/main.cpp | 131 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 82 insertions(+), 49 deletions(-) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 48d7833b2..076fcff18 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -173,55 +173,7 @@ GMainWindow::GMainWindow() show(); // Gen keys if necessary - Core::Crypto::KeyManager keys{}; - if (keys.BaseDeriveNecessary()) { - Core::Crypto::PartitionDataManager pdm{vfs->OpenDirectory( - FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir), FileSys::Mode::Read)}; - - const auto function = [this, &keys, &pdm]() { - keys.PopulateFromPartitionData(pdm); - Service::FileSystem::CreateFactories(vfs); - keys.DeriveETicket(pdm); - }; - - std::vector errors; - - if (!pdm.HasFuses()) - errors.push_back("Missing fuses - Cannot derive SBK"); - if (!pdm.HasBoot0()) - errors.push_back("Missing BOOT0 - Cannot derive master keys"); - if (!pdm.HasPackage2()) - errors.push_back("Missing BCPKG2-1-Normal-Main - Cannot derive general keys"); - if (!pdm.HasProdInfo()) - errors.push_back("Missing PRODINFO - Cannot derive title keys"); - - if (!errors.empty()) { - std::string error_str; - for (const auto& error : errors) - error_str += " - " + error + "\n"; - - QMessageBox::warning( - this, tr("Warning Missing Derivation Components"), - tr("The following are missing from your configuration that may hinder key " - "derivation. It will be attempted but may not complete.\n\n") + - QString::fromStdString(error_str)); - } - - QProgressDialog prog; - prog.setRange(0, 0); - prog.setLabelText(tr("Deriving keys...\nThis may take up to a minute depending \non your " - "system's performance.")); - prog.setWindowTitle(tr("Deriving Keys")); - - prog.show(); - - auto future = QtConcurrent::run(function); - while (!future.isFinished()) { - QCoreApplication::processEvents(); - } - - prog.close(); - } + OnReinitializeKeys(false); // Necessary to load titles from nand in gamelist. Service::FileSystem::CreateFactories(vfs); @@ -495,6 +447,8 @@ void GMainWindow::ConnectMenuEvents() { connect(ui.action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen); // Help + connect(ui.action_Rederive, &QAction::triggered, this, + std::bind(&GMainWindow::OnReinitializeKeys, this, true)); connect(ui.action_About, &QAction::triggered, this, &GMainWindow::OnAbout); } @@ -1427,6 +1381,85 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det } } +void GMainWindow::OnReinitializeKeys(bool callouts) { + if (callouts) { + const auto res = QMessageBox::information( + this, tr("Confirm Key Rederivation"), + tr("You are about to force rederive all of your keys. \nIf you do not know what this " + "means or what you are doing, \nthis is a potentially destructive action. \nPlease " + "make " + "sure this is what you want \nand optionally make backups.\n\nThis will delete your " + "autogenerated key files and re-run the key derivation module."), + QMessageBox::StandardButtons{QMessageBox::Ok, QMessageBox::Cancel}); + + if (res == QMessageBox::Cancel) + return; + + FileUtil::Delete(FileUtil::GetUserPath(FileUtil::UserPath::KeysDir) + + "prod.keys_autogenerated"); + FileUtil::Delete(FileUtil::GetUserPath(FileUtil::UserPath::KeysDir) + + "console.keys_autogenerated"); + FileUtil::Delete(FileUtil::GetUserPath(FileUtil::UserPath::KeysDir) + + "title.keys_autogenerated"); + } + + Core::Crypto::KeyManager keys{}; + if (keys.BaseDeriveNecessary()) { + Core::Crypto::PartitionDataManager pdm{vfs->OpenDirectory( + FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir), FileSys::Mode::Read)}; + + const auto function = [this, &keys, &pdm]() { + keys.PopulateFromPartitionData(pdm); + Service::FileSystem::CreateFactories(vfs); + keys.DeriveETicket(pdm); + }; + + std::vector errors; + + if (!pdm.HasFuses()) + errors.push_back("Missing fuses - Cannot derive SBK"); + if (!pdm.HasBoot0()) + errors.push_back("Missing BOOT0 - Cannot derive master keys"); + if (!pdm.HasPackage2()) + errors.push_back("Missing BCPKG2-1-Normal-Main - Cannot derive general keys"); + if (!pdm.HasProdInfo()) + errors.push_back("Missing PRODINFO - Cannot derive title keys"); + + if (!errors.empty()) { + std::string error_str; + for (const auto& error : errors) + error_str += " - " + error + "\n"; + + QMessageBox::warning( + this, tr("Warning Missing Derivation Components"), + tr("The following are missing from your configuration that may hinder key " + "derivation. It will be attempted but may not complete.\n\n") + + QString::fromStdString(error_str)); + } + + QProgressDialog prog; + prog.setRange(0, 0); + prog.setLabelText(tr("Deriving keys...\nThis may take up to a minute depending \non your " + "system's performance.")); + prog.setWindowTitle(tr("Deriving Keys")); + + prog.show(); + + auto future = QtConcurrent::run(function); + while (!future.isFinished()) { + QCoreApplication::processEvents(); + } + + prog.close(); + } + + Service::FileSystem::CreateFactories(vfs); + + if (callouts) { + game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan); + } +} + bool GMainWindow::ConfirmClose() { if (emu_thread == nullptr || !UISettings::values.confirm_before_closing) return true; -- cgit v1.2.3 From 3ec054643e50f2845fb6a1a924b83bd71a0e2234 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sat, 29 Sep 2018 11:48:51 -0400 Subject: partition_data_manager: Rename system files for hekate x --- src/yuzu/main.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 076fcff18..fc186dc2d 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -173,7 +173,7 @@ GMainWindow::GMainWindow() show(); // Gen keys if necessary - OnReinitializeKeys(false); + OnReinitializeKeys(ReinitializeKeyBehavior::NoWarning); // Necessary to load titles from nand in gamelist. Service::FileSystem::CreateFactories(vfs); @@ -448,7 +448,7 @@ void GMainWindow::ConnectMenuEvents() { // Help connect(ui.action_Rederive, &QAction::triggered, this, - std::bind(&GMainWindow::OnReinitializeKeys, this, true)); + std::bind(&GMainWindow::OnReinitializeKeys, this, ReinitializeKeyBehavior::Warning)); connect(ui.action_About, &QAction::triggered, this, &GMainWindow::OnAbout); } @@ -1381,8 +1381,8 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det } } -void GMainWindow::OnReinitializeKeys(bool callouts) { - if (callouts) { +void GMainWindow::OnReinitializeKeys(ReinitializeKeyBehavior behavior) { + if (behavior == ReinitializeKeyBehavior::Warning) { const auto res = QMessageBox::information( this, tr("Confirm Key Rederivation"), tr("You are about to force rederive all of your keys. \nIf you do not know what this " @@ -1408,33 +1408,30 @@ void GMainWindow::OnReinitializeKeys(bool callouts) { Core::Crypto::PartitionDataManager pdm{vfs->OpenDirectory( FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir), FileSys::Mode::Read)}; - const auto function = [this, &keys, &pdm]() { + const auto function = [this, &keys, &pdm] { keys.PopulateFromPartitionData(pdm); Service::FileSystem::CreateFactories(vfs); keys.DeriveETicket(pdm); }; - std::vector errors; + QString errors; if (!pdm.HasFuses()) - errors.push_back("Missing fuses - Cannot derive SBK"); + errors += tr("- Missing fuses - Cannot derive SBK\n"); if (!pdm.HasBoot0()) - errors.push_back("Missing BOOT0 - Cannot derive master keys"); + errors += tr("- Missing BOOT0 - Cannot derive master keys\n"); if (!pdm.HasPackage2()) - errors.push_back("Missing BCPKG2-1-Normal-Main - Cannot derive general keys"); + errors += tr("- Missing BCPKG2-1-Normal-Main - Cannot derive general keys\n"); if (!pdm.HasProdInfo()) - errors.push_back("Missing PRODINFO - Cannot derive title keys"); + errors += tr("- Missing PRODINFO - Cannot derive title keys\n"); - if (!errors.empty()) { - std::string error_str; - for (const auto& error : errors) - error_str += " - " + error + "\n"; + if (!errors.isEmpty()) { QMessageBox::warning( this, tr("Warning Missing Derivation Components"), tr("The following are missing from your configuration that may hinder key " "derivation. It will be attempted but may not complete.\n\n") + - QString::fromStdString(error_str)); + errors); } QProgressDialog prog; @@ -1455,7 +1452,7 @@ void GMainWindow::OnReinitializeKeys(bool callouts) { Service::FileSystem::CreateFactories(vfs); - if (callouts) { + if (behavior == ReinitializeKeyBehavior::Warning) { game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan); } } -- cgit v1.2.3