summaryrefslogtreecommitdiffstats
path: root/src/core/crypto/key_manager.cpp
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2018-08-25 17:43:27 +0200
committerZach Hilman <zachhilman@gmail.com>2018-09-04 20:25:54 +0200
commitd770c602052a9016f4577ed8c993a8f78f8e5507 (patch)
treeeabd3a7f286669d357dfd2d545f06db30245b473 /src/core/crypto/key_manager.cpp
parentMerge pull request #1238 from lioncash/explicit (diff)
downloadyuzu-d770c602052a9016f4577ed8c993a8f78f8e5507.tar
yuzu-d770c602052a9016f4577ed8c993a8f78f8e5507.tar.gz
yuzu-d770c602052a9016f4577ed8c993a8f78f8e5507.tar.bz2
yuzu-d770c602052a9016f4577ed8c993a8f78f8e5507.tar.lz
yuzu-d770c602052a9016f4577ed8c993a8f78f8e5507.tar.xz
yuzu-d770c602052a9016f4577ed8c993a8f78f8e5507.tar.zst
yuzu-d770c602052a9016f4577ed8c993a8f78f8e5507.zip
Diffstat (limited to 'src/core/crypto/key_manager.cpp')
-rw-r--r--src/core/crypto/key_manager.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp
index f768533da..bd4b3d7c7 100644
--- a/src/core/crypto/key_manager.cpp
+++ b/src/core/crypto/key_manager.cpp
@@ -231,18 +231,28 @@ void KeyManager::WriteKeyToFile(bool title_key, std::string_view keyname,
}
void KeyManager::SetKey(S128KeyType id, Key128 key, u64 field1, u64 field2) {
- const auto iter = std::find_if(
+ if (s128_keys.find({id, field1, field2}) != s128_keys.end())
+ return;
+ if (id == S128KeyType::Titlekey) {
+ Key128 rights_id;
+ std::memcpy(rights_id.data(), &field2, sizeof(u64));
+ std::memcpy(rights_id.data() + sizeof(u64), &field1, sizeof(u64));
+ WriteKeyToFile(true, fmt::format("{}", Common::HexArrayToString(rights_id)), key);
+ }
+ const auto iter2 = std::find_if(
s128_file_id.begin(), s128_file_id.end(),
[&id, &field1, &field2](const std::pair<std::string, KeyIndex<S128KeyType>> elem) {
return std::tie(elem.second.type, elem.second.field1, elem.second.field2) ==
std::tie(id, field1, field2);
});
- if (iter != s128_file_id.end())
- WriteKeyToFile(id == S128KeyType::Titlekey, iter->first, key);
+ if (iter2 != s128_file_id.end())
+ WriteKeyToFile(false, iter2->first, key);
s128_keys[{id, field1, field2}] = key;
}
void KeyManager::SetKey(S256KeyType id, Key256 key, u64 field1, u64 field2) {
+ if (s256_keys.find({id, field1, field2}) != s256_keys.end())
+ return;
const auto iter = std::find_if(
s256_file_id.begin(), s256_file_id.end(),
[&id, &field1, &field2](const std::pair<std::string, KeyIndex<S256KeyType>> elem) {