summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-09-23 21:35:32 -0400
committerGravatar Zach Hilman2018-10-07 13:16:04 -0400
commit8f958b89e713be88da516db57da4a2de7a15f093 (patch)
tree98cb9d532c61cbd921c99cd8589d2984390f87d9
parentqt: Add key derivation progress bar on initial setup (diff)
downloadyuzu-8f958b89e713be88da516db57da4a2de7a15f093.tar.gz
yuzu-8f958b89e713be88da516db57da4a2de7a15f093.tar.xz
yuzu-8f958b89e713be88da516db57da4a2de7a15f093.zip
qt: Add rederive keyset menu option
-rw-r--r--src/yuzu/main.cpp131
-rw-r--r--src/yuzu/main.h1
-rw-r--r--src/yuzu/main.ui6
3 files changed, 89 insertions, 49 deletions
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()
173 show(); 173 show();
174 174
175 // Gen keys if necessary 175 // Gen keys if necessary
176 Core::Crypto::KeyManager keys{}; 176 OnReinitializeKeys(false);
177 if (keys.BaseDeriveNecessary()) {
178 Core::Crypto::PartitionDataManager pdm{vfs->OpenDirectory(
179 FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir), FileSys::Mode::Read)};
180
181 const auto function = [this, &keys, &pdm]() {
182 keys.PopulateFromPartitionData(pdm);
183 Service::FileSystem::CreateFactories(vfs);
184 keys.DeriveETicket(pdm);
185 };
186
187 std::vector<std::string> errors;
188
189 if (!pdm.HasFuses())
190 errors.push_back("Missing fuses - Cannot derive SBK");
191 if (!pdm.HasBoot0())
192 errors.push_back("Missing BOOT0 - Cannot derive master keys");
193 if (!pdm.HasPackage2())
194 errors.push_back("Missing BCPKG2-1-Normal-Main - Cannot derive general keys");
195 if (!pdm.HasProdInfo())
196 errors.push_back("Missing PRODINFO - Cannot derive title keys");
197
198 if (!errors.empty()) {
199 std::string error_str;
200 for (const auto& error : errors)
201 error_str += " - " + error + "\n";
202
203 QMessageBox::warning(
204 this, tr("Warning Missing Derivation Components"),
205 tr("The following are missing from your configuration that may hinder key "
206 "derivation. It will be attempted but may not complete.\n\n") +
207 QString::fromStdString(error_str));
208 }
209
210 QProgressDialog prog;
211 prog.setRange(0, 0);
212 prog.setLabelText(tr("Deriving keys...\nThis may take up to a minute depending \non your "
213 "system's performance."));
214 prog.setWindowTitle(tr("Deriving Keys"));
215
216 prog.show();
217
218 auto future = QtConcurrent::run(function);
219 while (!future.isFinished()) {
220 QCoreApplication::processEvents();
221 }
222
223 prog.close();
224 }
225 177
226 // Necessary to load titles from nand in gamelist. 178 // Necessary to load titles from nand in gamelist.
227 Service::FileSystem::CreateFactories(vfs); 179 Service::FileSystem::CreateFactories(vfs);
@@ -495,6 +447,8 @@ void GMainWindow::ConnectMenuEvents() {
495 connect(ui.action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen); 447 connect(ui.action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen);
496 448
497 // Help 449 // Help
450 connect(ui.action_Rederive, &QAction::triggered, this,
451 std::bind(&GMainWindow::OnReinitializeKeys, this, true));
498 connect(ui.action_About, &QAction::triggered, this, &GMainWindow::OnAbout); 452 connect(ui.action_About, &QAction::triggered, this, &GMainWindow::OnAbout);
499} 453}
500 454
@@ -1427,6 +1381,85 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det
1427 } 1381 }
1428} 1382}
1429 1383
1384void GMainWindow::OnReinitializeKeys(bool callouts) {
1385 if (callouts) {
1386 const auto res = QMessageBox::information(
1387 this, tr("Confirm Key Rederivation"),
1388 tr("You are about to force rederive all of your keys. \nIf you do not know what this "
1389 "means or what you are doing, \nthis is a potentially destructive action. \nPlease "
1390 "make "
1391 "sure this is what you want \nand optionally make backups.\n\nThis will delete your "
1392 "autogenerated key files and re-run the key derivation module."),
1393 QMessageBox::StandardButtons{QMessageBox::Ok, QMessageBox::Cancel});
1394
1395 if (res == QMessageBox::Cancel)
1396 return;
1397
1398 FileUtil::Delete(FileUtil::GetUserPath(FileUtil::UserPath::KeysDir) +
1399 "prod.keys_autogenerated");
1400 FileUtil::Delete(FileUtil::GetUserPath(FileUtil::UserPath::KeysDir) +
1401 "console.keys_autogenerated");
1402 FileUtil::Delete(FileUtil::GetUserPath(FileUtil::UserPath::KeysDir) +
1403 "title.keys_autogenerated");
1404 }
1405
1406 Core::Crypto::KeyManager keys{};
1407 if (keys.BaseDeriveNecessary()) {
1408 Core::Crypto::PartitionDataManager pdm{vfs->OpenDirectory(
1409 FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir), FileSys::Mode::Read)};
1410
1411 const auto function = [this, &keys, &pdm]() {
1412 keys.PopulateFromPartitionData(pdm);
1413 Service::FileSystem::CreateFactories(vfs);
1414 keys.DeriveETicket(pdm);
1415 };
1416
1417 std::vector<std::string> errors;
1418
1419 if (!pdm.HasFuses())
1420 errors.push_back("Missing fuses - Cannot derive SBK");
1421 if (!pdm.HasBoot0())
1422 errors.push_back("Missing BOOT0 - Cannot derive master keys");
1423 if (!pdm.HasPackage2())
1424 errors.push_back("Missing BCPKG2-1-Normal-Main - Cannot derive general keys");
1425 if (!pdm.HasProdInfo())
1426 errors.push_back("Missing PRODINFO - Cannot derive title keys");
1427
1428 if (!errors.empty()) {
1429 std::string error_str;
1430 for (const auto& error : errors)
1431 error_str += " - " + error + "\n";
1432
1433 QMessageBox::warning(
1434 this, tr("Warning Missing Derivation Components"),
1435 tr("The following are missing from your configuration that may hinder key "
1436 "derivation. It will be attempted but may not complete.\n\n") +
1437 QString::fromStdString(error_str));
1438 }
1439
1440 QProgressDialog prog;
1441 prog.setRange(0, 0);
1442 prog.setLabelText(tr("Deriving keys...\nThis may take up to a minute depending \non your "
1443 "system's performance."));
1444 prog.setWindowTitle(tr("Deriving Keys"));
1445
1446 prog.show();
1447
1448 auto future = QtConcurrent::run(function);
1449 while (!future.isFinished()) {
1450 QCoreApplication::processEvents();
1451 }
1452
1453 prog.close();
1454 }
1455
1456 Service::FileSystem::CreateFactories(vfs);
1457
1458 if (callouts) {
1459 game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
1460 }
1461}
1462
1430bool GMainWindow::ConfirmClose() { 1463bool GMainWindow::ConfirmClose() {
1431 if (emu_thread == nullptr || !UISettings::values.confirm_before_closing) 1464 if (emu_thread == nullptr || !UISettings::values.confirm_before_closing)
1432 return true; 1465 return true;
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index fe0e9a50a..fd2c110ee 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -167,6 +167,7 @@ private slots:
167 void HideFullscreen(); 167 void HideFullscreen();
168 void ToggleWindowMode(); 168 void ToggleWindowMode();
169 void OnCoreError(Core::System::ResultStatus, std::string); 169 void OnCoreError(Core::System::ResultStatus, std::string);
170 void OnReinitializeKeys(bool callouts);
170 171
171private: 172private:
172 void UpdateStatusBar(); 173 void UpdateStatusBar();
diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui
index cb1664b21..9851f507d 100644
--- a/src/yuzu/main.ui
+++ b/src/yuzu/main.ui
@@ -103,6 +103,7 @@
103 </property> 103 </property>
104 <addaction name="action_Report_Compatibility"/> 104 <addaction name="action_Report_Compatibility"/>
105 <addaction name="separator"/> 105 <addaction name="separator"/>
106 <addaction name="action_Rederive"/>
106 <addaction name="action_About"/> 107 <addaction name="action_About"/>
107 </widget> 108 </widget>
108 <addaction name="menu_File"/> 109 <addaction name="menu_File"/>
@@ -159,6 +160,11 @@
159 <string>&amp;Stop</string> 160 <string>&amp;Stop</string>
160 </property> 161 </property>
161 </action> 162 </action>
163 <action name="action_Rederive">
164 <property name="text">
165 <string>Reinitialize keys...</string>
166 </property>
167 </action>
162 <action name="action_About"> 168 <action name="action_About">
163 <property name="text"> 169 <property name="text">
164 <string>About yuzu</string> 170 <string>About yuzu</string>