diff options
| author | 2019-11-12 04:13:17 -0500 | |
|---|---|---|
| committer | 2019-11-12 07:55:22 -0500 | |
| commit | 581d2e36e5af4de9c35b9b5753a6458299eb3926 (patch) | |
| tree | 2b6c72ecfe45e972ec13af9585c58b0716e6b040 | |
| parent | result: Resolve sign-coversion warnings (diff) | |
| download | yuzu-581d2e36e5af4de9c35b9b5753a6458299eb3926.tar.gz yuzu-581d2e36e5af4de9c35b9b5753a6458299eb3926.tar.xz yuzu-581d2e36e5af4de9c35b9b5753a6458299eb3926.zip | |
crypto: Resolve sign-conversion warnings
| -rw-r--r-- | src/core/crypto/key_manager.cpp | 16 | ||||
| -rw-r--r-- | src/core/crypto/partition_data_manager.cpp | 7 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 222fc95ba..023325292 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include "common/common_paths.h" | 21 | #include "common/common_paths.h" |
| 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/string_util.h" | ||
| 24 | #include "common/logging/log.h" | 25 | #include "common/logging/log.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" |
| @@ -378,8 +379,9 @@ std::vector<Ticket> GetTicketblob(const FileUtil::IOFile& ticket_save) { | |||
| 378 | template <size_t size> | 379 | template <size_t size> |
| 379 | static std::array<u8, size> operator^(const std::array<u8, size>& lhs, | 380 | static 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]); |
| @@ -944,12 +946,10 @@ void KeyManager::DeriveETicket(PartitionDataManager& data) { | |||
| 944 | return; | 946 | return; |
| 945 | } | 947 | } |
| 946 | 948 | ||
| 947 | Key128 rsa_oaep_kek{}; | 949 | const Key128 rsa_oaep_kek = seed3 ^ mask0; |
| 948 | std::transform(seed3.begin(), seed3.end(), mask0.begin(), rsa_oaep_kek.begin(), | 950 | if (rsa_oaep_kek == Key128{}) { |
| 949 | std::bit_xor<>()); | ||
| 950 | |||
| 951 | if (rsa_oaep_kek == Key128{}) | ||
| 952 | return; | 951 | return; |
| 952 | } | ||
| 953 | 953 | ||
| 954 | SetKey(S128KeyType::Source, rsa_oaep_kek, | 954 | SetKey(S128KeyType::Source, rsa_oaep_kek, |
| 955 | static_cast<u64>(SourceKeyType::RSAOaepKekGeneration)); | 955 | static_cast<u64>(SourceKeyType::RSAOaepKekGeneration)); |
diff --git a/src/core/crypto/partition_data_manager.cpp b/src/core/crypto/partition_data_manager.cpp index 594cd82c5..e82522756 100644 --- a/src/core/crypto/partition_data_manager.cpp +++ b/src/core/crypto/partition_data_manager.cpp | |||
| @@ -204,11 +204,12 @@ static std::array<Key128, 0x20> FindEncryptedMasterKeyFromHex(const std::vector< | |||
| 204 | 204 | ||
| 205 | FileSys::VirtualFile FindFileInDirWithNames(const FileSys::VirtualDir& dir, | 205 | FileSys::VirtualFile FindFileInDirWithNames(const FileSys::VirtualDir& dir, |
| 206 | const std::string& name) { | 206 | const std::string& name) { |
| 207 | auto upper = name; | 207 | const auto upper = Common::ToUpper(name); |
| 208 | std::transform(upper.begin(), upper.end(), upper.begin(), [](u8 c) { return std::toupper(c); }); | 208 | |
| 209 | for (const auto& fname : {name, name + ".bin", upper, upper + ".BIN"}) { | 209 | for (const auto& fname : {name, name + ".bin", upper, upper + ".BIN"}) { |
| 210 | if (dir->GetFile(fname) != nullptr) | 210 | if (dir->GetFile(fname) != nullptr) { |
| 211 | return dir->GetFile(fname); | 211 | return dir->GetFile(fname); |
| 212 | } | ||
| 212 | } | 213 | } |
| 213 | 214 | ||
| 214 | return nullptr; | 215 | return nullptr; |