From e2003a5b6b9a000e23bab48d8d82aaefbea8ae69 Mon Sep 17 00:00:00 2001 From: Jarrod Norwell Date: Sat, 23 Mar 2024 18:56:57 +0800 Subject: [PATCH] Removed all key autogeneration code --- src/core/crypto/key_manager.cpp | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index c802e18..a7128f0 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp @@ -648,17 +648,13 @@ void KeyManager::ReloadKeys() { if (Settings::values.use_dev_keys) { dev_mode = true; - LoadFromFile(sudachi_keys_dir / "dev.keys_autogenerated", false); LoadFromFile(sudachi_keys_dir / "dev.keys", false); } else { dev_mode = false; - LoadFromFile(sudachi_keys_dir / "prod.keys_autogenerated", false); LoadFromFile(sudachi_keys_dir / "prod.keys", false); } - LoadFromFile(sudachi_keys_dir / "title.keys_autogenerated", true); LoadFromFile(sudachi_keys_dir / "title.keys", true); - LoadFromFile(sudachi_keys_dir / "console.keys_autogenerated", false); LoadFromFile(sudachi_keys_dir / "console.keys", false); } @@ -847,18 +843,11 @@ Key256 KeyManager::GetBISKey(u8 partition_id) const { template void KeyManager::WriteKeyToFile(KeyCategory category, std::string_view keyname, const std::array& key) { - const auto sudachi_keys_dir = Common::FS::GetSudachiPath(Common::FS::SudachiPath::KeysDir); + const auto& sudachi_keys_dir = Common::FS::GetSudachiPath(Common::FS::SudachiPath::KeysDir); - std::string filename = "title.keys_autogenerated"; - - if (category == KeyCategory::Standard) { - filename = dev_mode ? "dev.keys_autogenerated" : "prod.keys_autogenerated"; - } else if (category == KeyCategory::Console) { - filename = "console.keys_autogenerated"; - } + std::string filename = "title.keys"; const auto path = sudachi_keys_dir / filename; - const auto add_info_text = !Common::FS::Exists(path); Common::FS::IOFile file{path, Common::FS::FileAccessMode::Append, Common::FS::FileType::TextFile}; @@ -867,14 +856,6 @@ void KeyManager::WriteKeyToFile(KeyCategory category, std::string_view keyname, return; } - if (add_info_text) { - void(file.WriteString( - "# This file is autogenerated by Sudachi\n" - "# It serves to store keys that were automatically generated from the normal keys\n" - "# If you are experiencing issues involving keys, it may help to delete this file\n")); - } - - void(file.WriteString(fmt::format("\n{} = {}", keyname, Common::HexToString(key)))); LoadFromFile(path, category == KeyCategory::Title); } @@ -883,7 +864,7 @@ void KeyManager::SetKey(S128KeyType id, Key128 key, u64 field1, u64 field2) { return; } if (id == S128KeyType::Titlekey) { - Key128 rights_id; + Key128 rights_id{}; std::memcpy(rights_id.data(), &field2, sizeof(u64)); std::memcpy(rights_id.data() + sizeof(u64), &field1, sizeof(u64)); WriteKeyToFile(KeyCategory::Title, Common::HexToString(rights_id), key);