From e9eb3f3799c9edbf09365da4a0ea6adc00427916 Mon Sep 17 00:00:00 2001 From: Paulo Alfaiate Date: Mon, 18 Mar 2024 18:29:11 +0000 Subject: [PATCH] Removing Warning --- .gitignore | 1 + src/core/crypto/key_manager.cpp | 33 ++++++++++++++++++++++++--------- src/core/crypto/key_manager.h | 2 +- src/core/loader/nax.cpp | 4 ---- src/core/loader/nsp.cpp | 4 ---- src/core/loader/xci.cpp | 4 ---- src/suyu/main.cpp | 7 ++++--- 7 files changed, 30 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 0e06e5aa00..2bf2c86d8c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ # Build directory [Bb]uild*/ doc-build/ +cmake-build*/ # Generated source files src/common/scm_rev.cpp diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index e1b520333d..5a1943a5ce 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp @@ -648,14 +648,14 @@ void KeyManager::ReloadKeys() { if (Settings::values.use_dev_keys) { dev_mode = true; - LoadFromFile(suyu_keys_dir / "dev.keys", false); + LoadFromFile(suyu_keys_dir / "dev.keys", 1); } else { dev_mode = false; - LoadFromFile(suyu_keys_dir / "prod.keys", false); + LoadFromFile(suyu_keys_dir / "prod.keys", 2); } - LoadFromFile(suyu_keys_dir / "title.keys", true); - LoadFromFile(suyu_keys_dir / "console.keys", false); + LoadFromFile(suyu_keys_dir / "title.keys", 3); + LoadFromFile(suyu_keys_dir / "console.keys", 4); } static bool ValidCryptoRevisionString(std::string_view base, size_t begin, size_t length) { @@ -666,11 +666,26 @@ static bool ValidCryptoRevisionString(std::string_view base, size_t begin, size_ [](u8 c) { return std::isxdigit(c); }); } -void KeyManager::LoadFromFile(const std::filesystem::path& file_path, bool is_title_keys) { +void KeyManager::LoadFromFile(const std::filesystem::path& file_path, int key_type) { if (!Common::FS::Exists(file_path)) { - LOG_ERROR(Crypto, "Failed to load key file at '{}': File not found", - file_path.generic_string()); - return; + switch (key_type) { + case 1: + LOG_ERROR(Crypto, "Issue with Development key file at '{}': File not found", + file_path.generic_string()); + return; + case 2: + LOG_ERROR(Crypto, "Issue with Production key file at '{}': File not found", + file_path.generic_string()); + return; + case 3: + LOG_INFO(Crypto, "Issue with Title key file at '{}': File not found", + file_path.generic_string()); + case 4: + LOG_INFO(Crypto, "Issue with Console key file at '{}': File not found", + file_path.generic_string()); + default: + LOG_ERROR(Crypto, "Unknown Key Type"); + } } std::ifstream file; @@ -1307,4 +1322,4 @@ bool KeyManager::AddTicket(const Ticket& ticket) { SetKey(S128KeyType::Titlekey, key.value(), rights_id[1], rights_id[0]); return true; } -} // namespace Core::Crypto +} // namespace Core::Crypto \ No newline at end of file diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h index 005062345e..0d4cfe72af 100644 --- a/src/core/crypto/key_manager.h +++ b/src/core/crypto/key_manager.h @@ -312,7 +312,7 @@ private: RSAKeyPair<2048> eticket_rsa_keypair{}; bool dev_mode; - void LoadFromFile(const std::filesystem::path& file_path, bool is_title_keys); + void LoadFromFile(const std::filesystem::path& file_path, int key_type); void DeriveGeneralPurposeKeys(std::size_t crypto_revision); diff --git a/src/core/loader/nax.cpp b/src/core/loader/nax.cpp index 725cb228d0..3b7b005ff4 100644 --- a/src/core/loader/nax.cpp +++ b/src/core/loader/nax.cpp @@ -55,10 +55,6 @@ AppLoader_NAX::LoadResult AppLoader_NAX::Load(Kernel::KProcess& process, Core::S return {ResultStatus::ErrorMissingProductionKeyFile, {}}; } - if (!Core::Crypto::KeyManager::KeyFileExists(true)) { - return {ResultStatus::ErrorMissingProductionKeyFile, {}}; - } - return {ResultStatus::ErrorNAXInconvertibleToNCA, {}}; } diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp index 39198c9b66..3016d5f25f 100644 --- a/src/core/loader/nsp.cpp +++ b/src/core/loader/nsp.cpp @@ -102,10 +102,6 @@ AppLoader_NSP::LoadResult AppLoader_NSP::Load(Kernel::KProcess& process, Core::S return {ResultStatus::ErrorMissingProductionKeyFile, {}}; } - if (!Core::Crypto::KeyManager::KeyFileExists(true)) { - return {ResultStatus::ErrorMissingProductionKeyFile, {}}; - } - return {ResultStatus::ErrorNSPMissingProgramNCA, {}}; } diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index d4722ac4c0..e9abb199a1 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp @@ -71,10 +71,6 @@ AppLoader_XCI::LoadResult AppLoader_XCI::Load(Kernel::KProcess& process, Core::S return {ResultStatus::ErrorMissingProductionKeyFile, {}}; } - if (!xci->HasProgramNCA() && !Core::Crypto::KeyManager::KeyFileExists(true)) { - return {ResultStatus::ErrorMissingProductionKeyFile, {}}; - } - const auto result = nca_loader->Load(process, system); if (result.first != ResultStatus::Success) { return result; diff --git a/src/suyu/main.cpp b/src/suyu/main.cpp index 4b9265febf..92615564d9 100644 --- a/src/suyu/main.cpp +++ b/src/suyu/main.cpp @@ -1755,9 +1755,10 @@ bool GMainWindow::LoadROM(const QString& filename, Service::AM::FrontendAppletPa if (!ContentManager::AreKeysPresent()) { QMessageBox::warning(this, tr("Derivation Components Missing"), tr("Encryption keys are missing. " - "You need to provide both your own title.keys " - "and your own prod.keys " - "in order to play games")); + "In order to use this emulator" + "you need to provide your own prod.keys" + "Some games might also require your own title.keys as well" + "in order to play them.")); return false; }