diff options
| author | 2018-07-30 12:46:23 -0400 | |
|---|---|---|
| committer | 2018-08-01 00:16:54 -0400 | |
| commit | 187d8e215fb157edaa9f3976bebba9a9a7ed103d (patch) | |
| tree | 140cbfbd109281adc87c9c79ee07976ba54888cd /src/core/crypto/key_manager.cpp | |
| parent | Use static const instead of const static (diff) | |
| download | yuzu-187d8e215fb157edaa9f3976bebba9a9a7ed103d.tar.gz yuzu-187d8e215fb157edaa9f3976bebba9a9a7ed103d.tar.xz yuzu-187d8e215fb157edaa9f3976bebba9a9a7ed103d.zip | |
Use more descriptive error codes and messages
Diffstat (limited to 'src/core/crypto/key_manager.cpp')
| -rw-r--r-- | src/core/crypto/key_manager.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 33633de7e..678ac5752 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp | |||
| @@ -53,8 +53,8 @@ std::array<u8, 32> operator""_array32(const char* str, size_t len) { | |||
| 53 | 53 | ||
| 54 | KeyManager::KeyManager() { | 54 | KeyManager::KeyManager() { |
| 55 | // Initialize keys | 55 | // Initialize keys |
| 56 | std::string hactool_keys_dir = FileUtil::GetHactoolConfigurationPath(); | 56 | const std::string hactool_keys_dir = FileUtil::GetHactoolConfigurationPath(); |
| 57 | std::string yuzu_keys_dir = FileUtil::GetUserPath(FileUtil::UserPath::KeysDir); | 57 | const std::string yuzu_keys_dir = FileUtil::GetUserPath(FileUtil::UserPath::KeysDir); |
| 58 | if (Settings::values.use_dev_keys) { | 58 | if (Settings::values.use_dev_keys) { |
| 59 | dev_mode = true; | 59 | dev_mode = true; |
| 60 | AttemptLoadKeyFile(yuzu_keys_dir, hactool_keys_dir, "dev.keys", false); | 60 | AttemptLoadKeyFile(yuzu_keys_dir, hactool_keys_dir, "dev.keys", false); |
| @@ -109,9 +109,9 @@ void KeyManager::LoadFromFile(std::string_view filename_, bool is_title_keys) { | |||
| 109 | 109 | ||
| 110 | void KeyManager::AttemptLoadKeyFile(std::string_view dir1_, std::string_view dir2_, | 110 | void KeyManager::AttemptLoadKeyFile(std::string_view dir1_, std::string_view dir2_, |
| 111 | std::string_view filename_, bool title) { | 111 | std::string_view filename_, bool title) { |
| 112 | std::string dir1(dir1_); | 112 | const std::string dir1(dir1_); |
| 113 | std::string dir2(dir2_); | 113 | const std::string dir2(dir2_); |
| 114 | std::string filename(filename_); | 114 | const std::string filename(filename_); |
| 115 | if (FileUtil::Exists(dir1 + DIR_SEP + filename)) | 115 | if (FileUtil::Exists(dir1 + DIR_SEP + filename)) |
| 116 | LoadFromFile(dir1 + DIR_SEP + filename, title); | 116 | LoadFromFile(dir1 + DIR_SEP + filename, title); |
| 117 | else if (FileUtil::Exists(dir2 + DIR_SEP + filename)) | 117 | else if (FileUtil::Exists(dir2 + DIR_SEP + filename)) |
| @@ -146,6 +146,23 @@ void KeyManager::SetKey(S256KeyType id, Key256 key, u64 field1, u64 field2) { | |||
| 146 | s256_keys[{id, field1, field2}] = key; | 146 | s256_keys[{id, field1, field2}] = key; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | bool KeyManager::KeyFileExists(bool title) { | ||
| 150 | const std::string hactool_keys_dir = FileUtil::GetHactoolConfigurationPath(); | ||
| 151 | const std::string yuzu_keys_dir = FileUtil::GetUserPath(FileUtil::UserPath::KeysDir); | ||
| 152 | if (title) { | ||
| 153 | return FileUtil::Exists(hactool_keys_dir + DIR_SEP + "title.keys") || | ||
| 154 | FileUtil::Exists(yuzu_keys_dir + DIR_SEP + "title.keys"); | ||
| 155 | } | ||
| 156 | |||
| 157 | if (Settings::values.use_dev_keys) { | ||
| 158 | return FileUtil::Exists(hactool_keys_dir + DIR_SEP + "dev.keys") || | ||
| 159 | FileUtil::Exists(yuzu_keys_dir + DIR_SEP + "dev.keys"); | ||
| 160 | } | ||
| 161 | |||
| 162 | return FileUtil::Exists(hactool_keys_dir + DIR_SEP + "prod.keys") || | ||
| 163 | FileUtil::Exists(yuzu_keys_dir + DIR_SEP + "prod.keys"); | ||
| 164 | } | ||
| 165 | |||
| 149 | const std::unordered_map<std::string, KeyIndex<S128KeyType>> KeyManager::s128_file_id = { | 166 | const std::unordered_map<std::string, KeyIndex<S128KeyType>> KeyManager::s128_file_id = { |
| 150 | {"master_key_00", {S128KeyType::Master, 0, 0}}, | 167 | {"master_key_00", {S128KeyType::Master, 0, 0}}, |
| 151 | {"master_key_01", {S128KeyType::Master, 1, 0}}, | 168 | {"master_key_01", {S128KeyType::Master, 1, 0}}, |