summaryrefslogtreecommitdiff
path: root/src/core/crypto/key_manager.cpp
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-09-23 20:57:20 -0400
committerGravatar Zach Hilman2018-10-07 13:15:11 -0400
commitd7398283e3cab47bac3571c0a56903415ffa44e6 (patch)
tree5ab94252074459ea311636f2c45a3dc547d548fc /src/core/crypto/key_manager.cpp
parentkey_manager: Add support for more keys (diff)
downloadyuzu-d7398283e3cab47bac3571c0a56903415ffa44e6.tar.gz
yuzu-d7398283e3cab47bac3571c0a56903415ffa44e6.tar.xz
yuzu-d7398283e3cab47bac3571c0a56903415ffa44e6.zip
key_manager: Add BIS key getter
Diffstat (limited to 'src/core/crypto/key_manager.cpp')
-rw-r--r--src/core/crypto/key_manager.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp
index 2a0b0b574..9cb7124d2 100644
--- a/src/core/crypto/key_manager.cpp
+++ b/src/core/crypto/key_manager.cpp
@@ -282,8 +282,23 @@ Key256 KeyManager::GetKey(S256KeyType id, u64 field1, u64 field2) const {
282 return s256_keys.at({id, field1, field2}); 282 return s256_keys.at({id, field1, field2});
283} 283}
284 284
285template <std::size_t Size> 285Key256 KeyManager::GetBISKey(u8 partition_id) const {
286void KeyManager::WriteKeyToFile(bool title_key, std::string_view keyname, 286 Key256 out{};
287
288 for (const auto& bis_type : {BISKeyType::Crypto, BISKeyType::Tweak}) {
289 if (HasKey(S128KeyType::BIS, partition_id, static_cast<u64>(bis_type))) {
290 std::memcpy(
291 out.data() + sizeof(Key128) * static_cast<u64>(bis_type),
292 s128_keys.at({S128KeyType::BIS, partition_id, static_cast<u64>(bis_type)}).data(),
293 sizeof(Key128));
294 }
295 }
296
297 return out;
298}
299
300template <size_t Size>
301void KeyManager::WriteKeyToFile(KeyCategory category, std::string_view keyname,
287 const std::array<u8, Size>& key) { 302 const std::array<u8, Size>& key) {
288 const std::string yuzu_keys_dir = FileUtil::GetUserPath(FileUtil::UserPath::KeysDir); 303 const std::string yuzu_keys_dir = FileUtil::GetUserPath(FileUtil::UserPath::KeysDir);
289 std::string filename = "title.keys_autogenerated"; 304 std::string filename = "title.keys_autogenerated";