diff options
| author | 2018-09-20 10:13:10 -0400 | |
|---|---|---|
| committer | 2018-09-20 10:13:10 -0400 | |
| commit | b02a1e38fa14613122c69bc4e708785d28416ea7 (patch) | |
| tree | 46be6c81a0dbec6578cb4a11c13e2f5c1acd2632 /src/core/file_sys | |
| parent | Merge pull request #1366 from ogniK5377/splat-fix (diff) | |
| parent | xts_archive: Remove unused variables from CalculateHMAC256() (diff) | |
| download | yuzu-b02a1e38fa14613122c69bc4e708785d28416ea7.tar.gz yuzu-b02a1e38fa14613122c69bc4e708785d28416ea7.tar.xz yuzu-b02a1e38fa14613122c69bc4e708785d28416ea7.zip | |
Merge pull request #1361 from lioncash/nax
xts_archive/nax: Minor interface changes
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/xts_archive.cpp | 11 | ||||
| -rw-r--r-- | src/core/file_sys/xts_archive.h | 4 |
2 files changed, 6 insertions, 9 deletions
diff --git a/src/core/file_sys/xts_archive.cpp b/src/core/file_sys/xts_archive.cpp index 0173f71c1..e937d1403 100644 --- a/src/core/file_sys/xts_archive.cpp +++ b/src/core/file_sys/xts_archive.cpp | |||
| @@ -30,9 +30,6 @@ static bool CalculateHMAC256(Destination* out, const SourceKey* key, std::size_t | |||
| 30 | mbedtls_md_context_t context; | 30 | mbedtls_md_context_t context; |
| 31 | mbedtls_md_init(&context); | 31 | mbedtls_md_init(&context); |
| 32 | 32 | ||
| 33 | const auto key_f = reinterpret_cast<const u8*>(key); | ||
| 34 | const std::vector<u8> key_v(key_f, key_f + key_length); | ||
| 35 | |||
| 36 | if (mbedtls_md_setup(&context, mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), 1) || | 33 | if (mbedtls_md_setup(&context, mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), 1) || |
| 37 | mbedtls_md_hmac_starts(&context, reinterpret_cast<const u8*>(key), key_length) || | 34 | mbedtls_md_hmac_starts(&context, reinterpret_cast<const u8*>(key), key_length) || |
| 38 | mbedtls_md_hmac_update(&context, reinterpret_cast<const u8*>(data), data_length) || | 35 | mbedtls_md_hmac_update(&context, reinterpret_cast<const u8*>(data), data_length) || |
| @@ -45,7 +42,7 @@ static bool CalculateHMAC256(Destination* out, const SourceKey* key, std::size_t | |||
| 45 | return true; | 42 | return true; |
| 46 | } | 43 | } |
| 47 | 44 | ||
| 48 | NAX::NAX(VirtualFile file_) : file(std::move(file_)), header(std::make_unique<NAXHeader>()) { | 45 | NAX::NAX(VirtualFile file_) : header(std::make_unique<NAXHeader>()), file(std::move(file_)) { |
| 49 | std::string path = FileUtil::SanitizePath(file->GetFullPath()); | 46 | std::string path = FileUtil::SanitizePath(file->GetFullPath()); |
| 50 | static const std::regex nax_path_regex("/registered/(000000[0-9A-F]{2})/([0-9A-F]{32})\\.nca", | 47 | static const std::regex nax_path_regex("/registered/(000000[0-9A-F]{2})/([0-9A-F]{32})\\.nca", |
| 51 | std::regex_constants::ECMAScript | | 48 | std::regex_constants::ECMAScript | |
| @@ -65,7 +62,7 @@ NAX::NAX(VirtualFile file_) : file(std::move(file_)), header(std::make_unique<NA | |||
| 65 | } | 62 | } |
| 66 | 63 | ||
| 67 | NAX::NAX(VirtualFile file_, std::array<u8, 0x10> nca_id) | 64 | NAX::NAX(VirtualFile file_, std::array<u8, 0x10> nca_id) |
| 68 | : file(std::move(file_)), header(std::make_unique<NAXHeader>()) { | 65 | : header(std::make_unique<NAXHeader>()), file(std::move(file_)) { |
| 69 | Core::Crypto::SHA256Hash hash{}; | 66 | Core::Crypto::SHA256Hash hash{}; |
| 70 | mbedtls_sha256(nca_id.data(), nca_id.size(), hash.data(), 0); | 67 | mbedtls_sha256(nca_id.data(), nca_id.size(), hash.data(), 0); |
| 71 | status = Parse(fmt::format("/registered/000000{:02X}/{}.nca", hash[0], | 68 | status = Parse(fmt::format("/registered/000000{:02X}/{}.nca", hash[0], |
| @@ -138,9 +135,9 @@ VirtualFile NAX::GetDecrypted() const { | |||
| 138 | return dec_file; | 135 | return dec_file; |
| 139 | } | 136 | } |
| 140 | 137 | ||
| 141 | std::shared_ptr<NCA> NAX::AsNCA() const { | 138 | std::unique_ptr<NCA> NAX::AsNCA() const { |
| 142 | if (type == NAXContentType::NCA) | 139 | if (type == NAXContentType::NCA) |
| 143 | return std::make_shared<NCA>(GetDecrypted()); | 140 | return std::make_unique<NCA>(GetDecrypted()); |
| 144 | return nullptr; | 141 | return nullptr; |
| 145 | } | 142 | } |
| 146 | 143 | ||
diff --git a/src/core/file_sys/xts_archive.h b/src/core/file_sys/xts_archive.h index 55d2154a6..6e2fc4d2e 100644 --- a/src/core/file_sys/xts_archive.h +++ b/src/core/file_sys/xts_archive.h | |||
| @@ -38,7 +38,7 @@ public: | |||
| 38 | 38 | ||
| 39 | VirtualFile GetDecrypted() const; | 39 | VirtualFile GetDecrypted() const; |
| 40 | 40 | ||
| 41 | std::shared_ptr<NCA> AsNCA() const; | 41 | std::unique_ptr<NCA> AsNCA() const; |
| 42 | 42 | ||
| 43 | NAXContentType GetContentType() const; | 43 | NAXContentType GetContentType() const; |
| 44 | 44 | ||
| @@ -60,7 +60,7 @@ private: | |||
| 60 | 60 | ||
| 61 | VirtualFile file; | 61 | VirtualFile file; |
| 62 | Loader::ResultStatus status; | 62 | Loader::ResultStatus status; |
| 63 | NAXContentType type; | 63 | NAXContentType type{}; |
| 64 | 64 | ||
| 65 | VirtualFile dec_file; | 65 | VirtualFile dec_file; |
| 66 | 66 | ||