From e19072e26ed6b9896f6a66c3b1a01ad663f81406 Mon Sep 17 00:00:00 2001 From: Crimson Hawk Date: Thu, 7 Mar 2024 03:04:42 +0000 Subject: [PATCH] Revert "Merge branch 'palfaiate-dev-patch-24781' into 'dev'" This reverts merge request !62 --- src/core/crypto/key_manager.cpp | 48 +++++---------------------------- src/core/crypto/key_manager.h | 4 +-- 2 files changed, 8 insertions(+), 44 deletions(-) diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index a268211fd6..c6215c8aad 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project & 2024 suyu Emulator Project +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include @@ -372,7 +372,7 @@ Key128 DeriveKeyblobMACKey(const Key128& keyblob_key, const Key128& mac_source) std::optional DeriveSDSeed() { const auto system_save_43_path = - Common::FS::GetSuyuPath(Common::FS::SuyuPath::NANDDir) / "system/save/8000000000000043"; + Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000043"; const Common::FS::IOFile save_43{system_save_43_path, Common::FS::FileAccessMode::Read, Common::FS::FileType::BinaryFile}; @@ -381,7 +381,7 @@ std::optional DeriveSDSeed() { } const auto sd_private_path = - Common::FS::GetSuyuPath(Common::FS::SuyuPath::SDMCDir) / "Nintendo/Contents/private"; + Common::FS::GetYuzuPath(Common::FS::YuzuPath::SDMCDir) / "Nintendo/Contents/private"; const Common::FS::IOFile sd_private{sd_private_path, Common::FS::FileAccessMode::Read, Common::FS::FileType::BinaryFile}; @@ -640,7 +640,7 @@ KeyManager::KeyManager() { void KeyManager::ReloadKeys() { // Initialize keys - const auto yuzu_keys_dir = Common::FS::GetSuyuPath(Common::FS::SuyuPath::KeysDir); + const auto yuzu_keys_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir); if (!Common::FS::CreateDir(yuzu_keys_dir)) { LOG_ERROR(Core, "Failed to create the keys directory."); @@ -648,17 +648,13 @@ void KeyManager::ReloadKeys() { if (Settings::values.use_dev_keys) { dev_mode = true; - LoadFromFile(yuzu_keys_dir / "dev.keys_autogenerated", false); LoadFromFile(yuzu_keys_dir / "dev.keys", false); } else { dev_mode = false; - LoadFromFile(yuzu_keys_dir / "prod.keys_autogenerated", false); LoadFromFile(yuzu_keys_dir / "prod.keys", false); } - LoadFromFile(yuzu_keys_dir / "title.keys_autogenerated", true); LoadFromFile(yuzu_keys_dir / "title.keys", true); - LoadFromFile(yuzu_keys_dir / "console.keys_autogenerated", false); LoadFromFile(yuzu_keys_dir / "console.keys", false); } @@ -844,8 +840,6 @@ Key256 KeyManager::GetBISKey(u8 partition_id) const { return out; } -template - void KeyManager::SetKey(S128KeyType id, Key128 key, u64 field1, u64 field2) { if (s128_keys.find({id, field1, field2}) != s128_keys.end() || key == Key128{}) { return; @@ -856,29 +850,6 @@ void KeyManager::SetKey(S128KeyType id, Key128 key, u64 field1, u64 field2) { std::memcpy(rights_id.data() + sizeof(u64), &field1, sizeof(u64)); } - auto category = KeyCategory::Standard; - if (id == S128KeyType::Keyblob || id == S128KeyType::KeyblobMAC || id == S128KeyType::TSEC || - id == S128KeyType::SecureBoot || id == S128KeyType::SDSeed || id == S128KeyType::BIS) { - category = KeyCategory::Console; - } - - const auto iter2 = std::find_if( - s128_file_id.begin(), s128_file_id.end(), [&id, &field1, &field2](const auto& elem) { - return std::tie(elem.second.type, elem.second.field1, elem.second.field2) == - std::tie(id, field1, field2); - }); - if (iter2 != s128_file_id.end()) { - } - - // Variable cases - if (id == S128KeyType::KeyArea) { - static constexpr std::array kak_names = { - "key_area_key_application_{:02X}", - "key_area_key_ocean_{:02X}", - "key_area_key_system_{:02X}", - }; - } - s128_keys[{id, field1, field2}] = key; } @@ -886,16 +857,11 @@ void KeyManager::SetKey(S256KeyType id, Key256 key, u64 field1, u64 field2) { if (s256_keys.find({id, field1, field2}) != s256_keys.end() || key == Key256{}) { return; } - const auto iter = std::find_if( - s256_file_id.begin(), s256_file_id.end(), [&id, &field1, &field2](const auto& elem) { - return std::tie(elem.second.type, elem.second.field1, elem.second.field2) == - std::tie(id, field1, field2); - }); s256_keys[{id, field1, field2}] = key; } bool KeyManager::KeyFileExists(bool title) { - const auto yuzu_keys_dir = Common::FS::GetSuyuPath(Common::FS::SuyuPath::KeysDir); + const auto yuzu_keys_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::KeysDir); if (title) { return Common::FS::Exists(yuzu_keys_dir / "title.keys"); @@ -1142,7 +1108,7 @@ void KeyManager::PopulateTickets() { std::vector tickets; const auto system_save_e1_path = - Common::FS::GetSuyuPath(Common::FS::SuyuPath::NANDDir) / "system/save/80000000000000e1"; + Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/80000000000000e1"; if (Common::FS::Exists(system_save_e1_path)) { const Common::FS::IOFile save_e1{system_save_e1_path, Common::FS::FileAccessMode::Read, Common::FS::FileType::BinaryFile}; @@ -1151,7 +1117,7 @@ void KeyManager::PopulateTickets() { } const auto system_save_e2_path = - Common::FS::GetSuyuPath(Common::FS::SuyuPath::NANDDir) / "system/save/80000000000000e2"; + Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/80000000000000e2"; if (Common::FS::Exists(system_save_e2_path)) { const Common::FS::IOFile save_e2{system_save_e2_path, Common::FS::FileAccessMode::Read, Common::FS::FileType::BinaryFile}; diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h index a1a7cb0e86..005062345e 100644 --- a/src/core/crypto/key_manager.h +++ b/src/core/crypto/key_manager.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project & 2024 suyu Emulator Project +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -314,8 +314,6 @@ private: bool dev_mode; void LoadFromFile(const std::filesystem::path& file_path, bool is_title_keys); - template - void DeriveGeneralPurposeKeys(std::size_t crypto_revision); void DeriveETicketRSAKey();