diff options
| author | 2020-12-08 21:58:13 -0800 | |
|---|---|---|
| committer | 2020-12-08 21:58:13 -0800 | |
| commit | 6f41763061082d5fa2ab039c554427152243cb46 (patch) | |
| tree | 158dde17ce9426c21c727f03a6e8651b09a2dade /src/core/file_sys | |
| parent | Merge pull request #5135 from Morph1984/applets-shadow (diff) | |
| parent | core: Remove unnecessary enum casts in log calls (diff) | |
| download | yuzu-6f41763061082d5fa2ab039c554427152243cb46.tar.gz yuzu-6f41763061082d5fa2ab039c554427152243cb46.tar.xz yuzu-6f41763061082d5fa2ab039c554427152243cb46.zip | |
Merge pull request #5166 from lioncash/log-cast
core: Remove unnecessary enum casts in log calls
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/content_archive.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp index 76af47ff9..363ff980f 100644 --- a/src/core/file_sys/content_archive.cpp +++ b/src/core/file_sys/content_archive.cpp | |||
| @@ -410,8 +410,9 @@ u8 NCA::GetCryptoRevision() const { | |||
| 410 | std::optional<Core::Crypto::Key128> NCA::GetKeyAreaKey(NCASectionCryptoType type) const { | 410 | std::optional<Core::Crypto::Key128> NCA::GetKeyAreaKey(NCASectionCryptoType type) const { |
| 411 | const auto master_key_id = GetCryptoRevision(); | 411 | const auto master_key_id = GetCryptoRevision(); |
| 412 | 412 | ||
| 413 | if (!keys.HasKey(Core::Crypto::S128KeyType::KeyArea, master_key_id, header.key_index)) | 413 | if (!keys.HasKey(Core::Crypto::S128KeyType::KeyArea, master_key_id, header.key_index)) { |
| 414 | return {}; | 414 | return std::nullopt; |
| 415 | } | ||
| 415 | 416 | ||
| 416 | std::vector<u8> key_area(header.key_area.begin(), header.key_area.end()); | 417 | std::vector<u8> key_area(header.key_area.begin(), header.key_area.end()); |
| 417 | Core::Crypto::AESCipher<Core::Crypto::Key128> cipher( | 418 | Core::Crypto::AESCipher<Core::Crypto::Key128> cipher( |
| @@ -420,15 +421,17 @@ std::optional<Core::Crypto::Key128> NCA::GetKeyAreaKey(NCASectionCryptoType type | |||
| 420 | cipher.Transcode(key_area.data(), key_area.size(), key_area.data(), Core::Crypto::Op::Decrypt); | 421 | cipher.Transcode(key_area.data(), key_area.size(), key_area.data(), Core::Crypto::Op::Decrypt); |
| 421 | 422 | ||
| 422 | Core::Crypto::Key128 out; | 423 | Core::Crypto::Key128 out; |
| 423 | if (type == NCASectionCryptoType::XTS) | 424 | if (type == NCASectionCryptoType::XTS) { |
| 424 | std::copy(key_area.begin(), key_area.begin() + 0x10, out.begin()); | 425 | std::copy(key_area.begin(), key_area.begin() + 0x10, out.begin()); |
| 425 | else if (type == NCASectionCryptoType::CTR || type == NCASectionCryptoType::BKTR) | 426 | } else if (type == NCASectionCryptoType::CTR || type == NCASectionCryptoType::BKTR) { |
| 426 | std::copy(key_area.begin() + 0x20, key_area.begin() + 0x30, out.begin()); | 427 | std::copy(key_area.begin() + 0x20, key_area.begin() + 0x30, out.begin()); |
| 427 | else | 428 | } else { |
| 428 | LOG_CRITICAL(Crypto, "Called GetKeyAreaKey on invalid NCASectionCryptoType type={:02X}", | 429 | LOG_CRITICAL(Crypto, "Called GetKeyAreaKey on invalid NCASectionCryptoType type={:02X}", |
| 429 | static_cast<u8>(type)); | 430 | type); |
| 431 | } | ||
| 432 | |||
| 430 | u128 out_128{}; | 433 | u128 out_128{}; |
| 431 | memcpy(out_128.data(), out.data(), 16); | 434 | std::memcpy(out_128.data(), out.data(), sizeof(u128)); |
| 432 | LOG_TRACE(Crypto, "called with crypto_rev={:02X}, kak_index={:02X}, key={:016X}{:016X}", | 435 | LOG_TRACE(Crypto, "called with crypto_rev={:02X}, kak_index={:02X}, key={:016X}{:016X}", |
| 433 | master_key_id, header.key_index, out_128[1], out_128[0]); | 436 | master_key_id, header.key_index, out_128[1], out_128[0]); |
| 434 | 437 | ||
| @@ -507,7 +510,7 @@ VirtualFile NCA::Decrypt(const NCASectionHeader& s_header, VirtualFile in, u64 s | |||
| 507 | // TODO(DarkLordZach): Find a test case for XTS-encrypted NCAs | 510 | // TODO(DarkLordZach): Find a test case for XTS-encrypted NCAs |
| 508 | default: | 511 | default: |
| 509 | LOG_ERROR(Crypto, "called with unhandled crypto type={:02X}", | 512 | LOG_ERROR(Crypto, "called with unhandled crypto type={:02X}", |
| 510 | static_cast<u8>(s_header.raw.header.crypto_type)); | 513 | s_header.raw.header.crypto_type); |
| 511 | return nullptr; | 514 | return nullptr; |
| 512 | } | 515 | } |
| 513 | } | 516 | } |