diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-09-24 02:37:27 +0200 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-10-07 19:15:11 +0200 |
commit | ce05df0a6dea513cf3f32a582535ccff61f6bcee (patch) | |
tree | df8fd7b173545be91bae576ca32f6ef9ca0f717e /src | |
parent | key_manager: Rename KEK to Kek (diff) | |
download | yuzu-ce05df0a6dea513cf3f32a582535ccff61f6bcee.tar yuzu-ce05df0a6dea513cf3f32a582535ccff61f6bcee.tar.gz yuzu-ce05df0a6dea513cf3f32a582535ccff61f6bcee.tar.bz2 yuzu-ce05df0a6dea513cf3f32a582535ccff61f6bcee.tar.lz yuzu-ce05df0a6dea513cf3f32a582535ccff61f6bcee.tar.xz yuzu-ce05df0a6dea513cf3f32a582535ccff61f6bcee.tar.zst yuzu-ce05df0a6dea513cf3f32a582535ccff61f6bcee.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/crypto/key_manager.cpp | 10 | ||||
-rw-r--r-- | src/core/crypto/key_manager.h | 6 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 467eb423e..9f47536d1 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp @@ -138,6 +138,8 @@ KeyManager::KeyManager() { AttemptLoadKeyFile(yuzu_keys_dir, hactool_keys_dir, "title.keys", true); AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, "title.keys_autogenerated", true); + AttemptLoadKeyFile(yuzu_keys_dir, hactool_keys_dir, "console.keys", false); + AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, "console.keys_autogenerated", false); } void KeyManager::LoadFromFile(const std::string& filename, bool is_title_keys) { @@ -213,8 +215,10 @@ void KeyManager::WriteKeyToFile(bool title_key, std::string_view keyname, const std::array<u8, Size>& key) { const std::string yuzu_keys_dir = FileUtil::GetUserPath(FileUtil::UserPath::KeysDir); std::string filename = "title.keys_autogenerated"; - if (!title_key) + if (category == KeyCategory::Standard) filename = dev_mode ? "dev.keys_autogenerated" : "prod.keys_autogenerated"; + else if (category == KeyCategory::Console) + filename = "console.keys_autogenerated"; const auto add_info_text = !FileUtil::Exists(yuzu_keys_dir + DIR_SEP + filename); FileUtil::CreateFullPath(yuzu_keys_dir + DIR_SEP + filename); std::ofstream file(yuzu_keys_dir + DIR_SEP + filename, std::ios::app); @@ -228,7 +232,7 @@ void KeyManager::WriteKeyToFile(bool title_key, std::string_view keyname, } file << fmt::format("\n{} = {}", keyname, Common::HexArrayToString(key)); - AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, filename, title_key); + AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, filename, category == KeyCategory::Title); } void KeyManager::SetKey(S128KeyType id, Key128 key, u64 field1, u64 field2) { @@ -261,7 +265,7 @@ void KeyManager::SetKey(S256KeyType id, Key256 key, u64 field1, u64 field2) { std::tie(id, field1, field2); }); if (iter != s256_file_id.end()) - WriteKeyToFile(false, iter->first, key); + WriteKeyToFile(KeyCategory::Standard, iter->first, key); s256_keys[{id, field1, field2}] = key; } diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h index 8bd33840d..ffc13fa8f 100644 --- a/src/core/crypto/key_manager.h +++ b/src/core/crypto/key_manager.h @@ -26,6 +26,12 @@ using SHA256Hash = std::array<u8, 0x20>; static_assert(sizeof(Key128) == 16, "Key128 must be 128 bytes big."); static_assert(sizeof(Key256) == 32, "Key128 must be 128 bytes big."); +enum class KeyCategory : u8 { + Standard, + Title, + Console, +}; + enum class S256KeyType : u64 { Header, // SDKeySource, // f1=SDKeyType |