summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authort895 <clombardo169@gmail.com>2024-01-24 18:33:34 +0100
committert895 <clombardo169@gmail.com>2024-01-25 18:53:48 +0100
commit1a3fc3724aa2d38e717a8dcbfcc6c8a808a693b6 (patch)
treebea2cc265f8c2ca59a2f642128e6ee6d1c1196a6 /src
parentMerge pull request #12739 from t895/debug-keystore (diff)
downloadyuzu-1a3fc3724aa2d38e717a8dcbfcc6c8a808a693b6.tar
yuzu-1a3fc3724aa2d38e717a8dcbfcc6c8a808a693b6.tar.gz
yuzu-1a3fc3724aa2d38e717a8dcbfcc6c8a808a693b6.tar.bz2
yuzu-1a3fc3724aa2d38e717a8dcbfcc6c8a808a693b6.tar.lz
yuzu-1a3fc3724aa2d38e717a8dcbfcc6c8a808a693b6.tar.xz
yuzu-1a3fc3724aa2d38e717a8dcbfcc6c8a808a693b6.tar.zst
yuzu-1a3fc3724aa2d38e717a8dcbfcc6c8a808a693b6.zip
Diffstat (limited to '')
-rw-r--r--src/frontend_common/content_manager.h7
-rw-r--r--src/yuzu/main.cpp114
-rw-r--r--src/yuzu/main.h8
-rw-r--r--src/yuzu/main.ui5
4 files changed, 13 insertions, 121 deletions
diff --git a/src/frontend_common/content_manager.h b/src/frontend_common/content_manager.h
index 0b0fee73e..fb92a1695 100644
--- a/src/frontend_common/content_manager.h
+++ b/src/frontend_common/content_manager.h
@@ -368,4 +368,11 @@ inline GameVerificationResult VerifyGameContents(
return GameVerificationResult::Success;
}
+/**
+ * Checks if the keys required for decrypting firmware and games are available
+ */
+inline bool AreKeysPresent() {
+ return !Core::Crypto::KeyManager::Instance().BaseDeriveNecessary();
+}
+
} // namespace ContentManager
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index d8b0beadf..bb0fbef7c 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -423,7 +423,7 @@ GMainWindow::GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulk
RemoveCachedContents();
// Gen keys if necessary
- OnReinitializeKeys(ReinitializeKeyBehavior::NoWarning);
+ OnCheckFirmwareDecryption();
game_list->LoadCompatibilityList();
game_list->PopulateAsync(UISettings::values.game_dirs);
@@ -1574,8 +1574,6 @@ void GMainWindow::ConnectMenuEvents() {
connect(multiplayer_state, &MultiplayerState::SaveConfig, this, &GMainWindow::OnSaveConfig);
// Tools
- connect_menu(ui->action_Rederive, std::bind(&GMainWindow::OnReinitializeKeys, this,
- ReinitializeKeyBehavior::Warning));
connect_menu(ui->action_Load_Album, &GMainWindow::OnAlbum);
connect_menu(ui->action_Load_Cabinet_Nickname_Owner,
[this]() { OnCabinet(Service::NFP::CabinetMode::StartNicknameAndOwnerSettings); });
@@ -4551,122 +4549,20 @@ void GMainWindow::OnMouseActivity() {
}
}
-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 "
- "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;
-
- const auto keys_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir);
-
- Common::FS::RemoveFile(keys_dir / "prod.keys_autogenerated");
- Common::FS::RemoveFile(keys_dir / "console.keys_autogenerated");
- Common::FS::RemoveFile(keys_dir / "title.keys_autogenerated");
- }
-
- Core::Crypto::KeyManager& keys = Core::Crypto::KeyManager::Instance();
- bool all_keys_present{true};
-
- if (keys.BaseDeriveNecessary()) {
- Core::Crypto::PartitionDataManager pdm{vfs->OpenDirectory("", FileSys::Mode::Read)};
-
- const auto function = [this, &keys, &pdm] {
- keys.PopulateFromPartitionData(pdm);
-
- system->GetFileSystemController().CreateFactories(*vfs);
- keys.DeriveETicket(pdm, system->GetContentProvider());
- };
-
- QString errors;
- if (!pdm.HasFuses()) {
- errors += tr("Missing fuses");
- }
- if (!pdm.HasBoot0()) {
- errors += tr(" - Missing BOOT0");
- }
- if (!pdm.HasPackage2()) {
- errors += tr(" - Missing BCPKG2-1-Normal-Main");
- }
- if (!pdm.HasProdInfo()) {
- errors += tr(" - Missing PRODINFO");
- }
- if (!errors.isEmpty()) {
- all_keys_present = false;
- QMessageBox::warning(
- this, tr("Derivation Components Missing"),
- tr("Encryption keys are missing. "
- "<br>Please follow <a href='https://yuzu-emu.org/help/quickstart/'>the yuzu "
- "quickstart guide</a> to get all your keys, firmware and "
- "games.<br><br><small>(%1)</small>")
- .arg(errors));
- }
-
- QProgressDialog prog(this);
- 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();
- }
-
+void GMainWindow::OnCheckFirmwareDecryption() {
system->GetFileSystemController().CreateFactories(*vfs);
-
- if (all_keys_present && !this->CheckSystemArchiveDecryption()) {
- LOG_WARNING(Frontend, "Mii model decryption failed");
+ if (!ContentManager::AreKeysPresent()) {
QMessageBox::warning(
- this, tr("System Archive Decryption Failed"),
- tr("Encryption keys failed to decrypt firmware. "
+ this, tr("Derivation Components Missing"),
+ tr("Encryption keys are missing. "
"<br>Please follow <a href='https://yuzu-emu.org/help/quickstart/'>the yuzu "
"quickstart guide</a> to get all your keys, firmware and "
"games."));
}
-
SetFirmwareVersion();
-
- if (behavior == ReinitializeKeyBehavior::Warning) {
- game_list->PopulateAsync(UISettings::values.game_dirs);
- }
-
UpdateMenuState();
}
-bool GMainWindow::CheckSystemArchiveDecryption() {
- constexpr u64 MiiModelId = 0x0100000000000802;
-
- auto bis_system = system->GetFileSystemController().GetSystemNANDContents();
- if (!bis_system) {
- // Not having system BIS files is not an error.
- return true;
- }
-
- auto mii_nca = bis_system->GetEntry(MiiModelId, FileSys::ContentRecordType::Data);
- if (!mii_nca) {
- // Not having the Mii model is not an error.
- return true;
- }
-
- // Return whether we are able to decrypt the RomFS of the Mii model.
- return mii_nca->GetRomFS().get() != nullptr;
-}
-
bool GMainWindow::CheckFirmwarePresence() {
constexpr u64 MiiEditId = static_cast<u64>(Service::AM::Applets::AppletProgramId::MiiEdit);
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index 280fae5c3..6b72094ff 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -125,11 +125,6 @@ enum class EmulatedDirectoryTarget {
SDMC,
};
-enum class ReinitializeKeyBehavior {
- NoWarning,
- Warning,
-};
-
namespace VkDeviceInfo {
class Record;
}
@@ -400,7 +395,7 @@ private slots:
void OnMiiEdit();
void OnOpenControllerMenu();
void OnCaptureScreenshot();
- void OnReinitializeKeys(ReinitializeKeyBehavior behavior);
+ void OnCheckFirmwareDecryption();
void OnLanguageChanged(const QString& locale);
void OnMouseActivity();
bool OnShutdownBegin();
@@ -441,7 +436,6 @@ private:
void LoadTranslation();
void OpenPerGameConfiguration(u64 title_id, const std::string& file_name);
bool CheckDarkMode();
- bool CheckSystemArchiveDecryption();
bool CheckFirmwarePresence();
void SetFirmwareVersion();
void ConfigureFilesystemProvider(const std::string& filepath);
diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui
index e53f9951e..6a6b0821f 100644
--- a/src/yuzu/main.ui
+++ b/src/yuzu/main.ui
@@ -224,11 +224,6 @@
<string>&amp;Stop</string>
</property>
</action>
- <action name="action_Rederive">
- <property name="text">
- <string>&amp;Reinitialize keys...</string>
- </property>
- </action>
<action name="action_Verify_installed_contents">
<property name="text">
<string>&amp;Verify Installed Contents</string>