summaryrefslogtreecommitdiff
path: root/src/core/crypto/key_manager.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2019-11-15 12:08:50 -0500
committerGravatar GitHub2019-11-15 12:08:50 -0500
commit3e0e4f146b3f2ad7f1935a61141c38cdce87e04f (patch)
tree75f29ce4bb9d84f9d9722b7aa86d71e805cac8cc /src/core/crypto/key_manager.cpp
parentMerge pull request #3113 from lioncash/semi (diff)
parentexternals: Update httplib (diff)
downloadyuzu-3e0e4f146b3f2ad7f1935a61141c38cdce87e04f.tar.gz
yuzu-3e0e4f146b3f2ad7f1935a61141c38cdce87e04f.tar.xz
yuzu-3e0e4f146b3f2ad7f1935a61141c38cdce87e04f.zip
Merge pull request #3091 from lioncash/core-conversion
core: Make most implicit type conversion warnings errors on MSVC
Diffstat (limited to 'src/core/crypto/key_manager.cpp')
-rw-r--r--src/core/crypto/key_manager.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp
index 487b57053..87e6a1fd3 100644
--- a/src/core/crypto/key_manager.cpp
+++ b/src/core/crypto/key_manager.cpp
@@ -22,6 +22,7 @@
22#include "common/file_util.h" 22#include "common/file_util.h"
23#include "common/hex_util.h" 23#include "common/hex_util.h"
24#include "common/logging/log.h" 24#include "common/logging/log.h"
25#include "common/string_util.h"
25#include "core/core.h" 26#include "core/core.h"
26#include "core/crypto/aes_util.h" 27#include "core/crypto/aes_util.h"
27#include "core/crypto/key_manager.h" 28#include "core/crypto/key_manager.h"
@@ -378,8 +379,9 @@ std::vector<Ticket> GetTicketblob(const FileUtil::IOFile& ticket_save) {
378template <size_t size> 379template <size_t size>
379static std::array<u8, size> operator^(const std::array<u8, size>& lhs, 380static std::array<u8, size> operator^(const std::array<u8, size>& lhs,
380 const std::array<u8, size>& rhs) { 381 const std::array<u8, size>& rhs) {
381 std::array<u8, size> out{}; 382 std::array<u8, size> out;
382 std::transform(lhs.begin(), lhs.end(), rhs.begin(), out.begin(), std::bit_xor<>()); 383 std::transform(lhs.begin(), lhs.end(), rhs.begin(), out.begin(),
384 [](u8 lhs, u8 rhs) { return u8(lhs ^ rhs); });
383 return out; 385 return out;
384} 386}
385 387
@@ -538,7 +540,7 @@ void KeyManager::LoadFromFile(const std::string& filename, bool is_title_keys) {
538 Key128 key = Common::HexStringToArray<16>(out[1]); 540 Key128 key = Common::HexStringToArray<16>(out[1]);
539 s128_keys[{S128KeyType::Titlekey, rights_id[1], rights_id[0]}] = key; 541 s128_keys[{S128KeyType::Titlekey, rights_id[1], rights_id[0]}] = key;
540 } else { 542 } else {
541 std::transform(out[0].begin(), out[0].end(), out[0].begin(), ::tolower); 543 out[0] = Common::ToLower(out[0]);
542 if (s128_file_id.find(out[0]) != s128_file_id.end()) { 544 if (s128_file_id.find(out[0]) != s128_file_id.end()) {
543 const auto index = s128_file_id.at(out[0]); 545 const auto index = s128_file_id.at(out[0]);
544 Key128 key = Common::HexStringToArray<16>(out[1]); 546 Key128 key = Common::HexStringToArray<16>(out[1]);
@@ -948,12 +950,10 @@ void KeyManager::DeriveETicket(PartitionDataManager& data) {
948 return; 950 return;
949 } 951 }
950 952
951 Key128 rsa_oaep_kek{}; 953 const Key128 rsa_oaep_kek = seed3 ^ mask0;
952 std::transform(seed3.begin(), seed3.end(), mask0.begin(), rsa_oaep_kek.begin(), 954 if (rsa_oaep_kek == Key128{}) {
953 std::bit_xor<>());
954
955 if (rsa_oaep_kek == Key128{})
956 return; 955 return;
956 }
957 957
958 SetKey(S128KeyType::Source, rsa_oaep_kek, 958 SetKey(S128KeyType::Source, rsa_oaep_kek,
959 static_cast<u64>(SourceKeyType::RSAOaepKekGeneration)); 959 static_cast<u64>(SourceKeyType::RSAOaepKekGeneration));