diff options
| author | 2018-01-12 19:36:41 -0500 | |
|---|---|---|
| committer | 2018-01-12 19:36:41 -0500 | |
| commit | 8e51c61dbce925e0992e27c2c33311583645bd6f (patch) | |
| tree | 2e868c243b15eaa63b953696775e0b84bab2fd22 /src/core/file_sys | |
| parent | dynarmic: Update to 83afe435 (diff) | |
| download | yuzu-8e51c61dbce925e0992e27c2c33311583645bd6f.tar.gz yuzu-8e51c61dbce925e0992e27c2c33311583645bd6f.tar.xz yuzu-8e51c61dbce925e0992e27c2c33311583645bd6f.zip | |
core: Gut out cryptop, since it doesn't compile with C++17.
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/title_metadata.cpp | 51 |
1 files changed, 1 insertions, 50 deletions
diff --git a/src/core/file_sys/title_metadata.cpp b/src/core/file_sys/title_metadata.cpp index 1ef8840a0..e29ba6064 100644 --- a/src/core/file_sys/title_metadata.cpp +++ b/src/core/file_sys/title_metadata.cpp | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <cinttypes> | 5 | #include <cinttypes> |
| 6 | #include <cryptopp/sha.h> | ||
| 7 | #include "common/alignment.h" | 6 | #include "common/alignment.h" |
| 8 | #include "common/file_util.h" | 7 | #include "common/file_util.h" |
| 9 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| @@ -69,55 +68,7 @@ Loader::ResultStatus TitleMetadata::Load() { | |||
| 69 | } | 68 | } |
| 70 | 69 | ||
| 71 | Loader::ResultStatus TitleMetadata::Save() { | 70 | Loader::ResultStatus TitleMetadata::Save() { |
| 72 | FileUtil::IOFile file(filepath, "wb"); | 71 | UNIMPLEMENTED(); |
| 73 | if (!file.IsOpen()) | ||
| 74 | return Loader::ResultStatus::Error; | ||
| 75 | |||
| 76 | if (!file.WriteBytes(&signature_type, sizeof(u32_be))) | ||
| 77 | return Loader::ResultStatus::Error; | ||
| 78 | |||
| 79 | // Signature lengths are variable, and the body follows the signature | ||
| 80 | u32 signature_size = GetSignatureSize(signature_type); | ||
| 81 | |||
| 82 | if (!file.WriteBytes(tmd_signature.data(), signature_size)) | ||
| 83 | return Loader::ResultStatus::Error; | ||
| 84 | |||
| 85 | // The TMD body start position is rounded to the nearest 0x40 after the signature | ||
| 86 | size_t body_start = Common::AlignUp(signature_size + sizeof(u32), 0x40); | ||
| 87 | file.Seek(body_start, SEEK_SET); | ||
| 88 | |||
| 89 | // Update our TMD body values and hashes | ||
| 90 | tmd_body.content_count = static_cast<u16>(tmd_chunks.size()); | ||
| 91 | |||
| 92 | // TODO(shinyquagsire23): Do TMDs with more than one contentinfo exist? | ||
| 93 | // For now we'll just adjust the first index to hold all content chunks | ||
| 94 | // and ensure that no further content info data exists. | ||
| 95 | tmd_body.contentinfo = {}; | ||
| 96 | tmd_body.contentinfo[0].index = 0; | ||
| 97 | tmd_body.contentinfo[0].command_count = static_cast<u16>(tmd_chunks.size()); | ||
| 98 | |||
| 99 | CryptoPP::SHA256 chunk_hash; | ||
| 100 | for (u16 i = 0; i < tmd_body.content_count; i++) { | ||
| 101 | chunk_hash.Update(reinterpret_cast<u8*>(&tmd_chunks[i]), sizeof(ContentChunk)); | ||
| 102 | } | ||
| 103 | chunk_hash.Final(tmd_body.contentinfo[0].hash.data()); | ||
| 104 | |||
| 105 | CryptoPP::SHA256 contentinfo_hash; | ||
| 106 | for (size_t i = 0; i < tmd_body.contentinfo.size(); i++) { | ||
| 107 | chunk_hash.Update(reinterpret_cast<u8*>(&tmd_body.contentinfo[i]), sizeof(ContentInfo)); | ||
| 108 | } | ||
| 109 | chunk_hash.Final(tmd_body.contentinfo_hash.data()); | ||
| 110 | |||
| 111 | // Write our TMD body, then write each of our ContentChunks | ||
| 112 | if (file.WriteBytes(&tmd_body, sizeof(TitleMetadata::Body)) != sizeof(TitleMetadata::Body)) | ||
| 113 | return Loader::ResultStatus::Error; | ||
| 114 | |||
| 115 | for (u16 i = 0; i < tmd_body.content_count; i++) { | ||
| 116 | ContentChunk chunk = tmd_chunks[i]; | ||
| 117 | if (file.WriteBytes(&chunk, sizeof(ContentChunk)) != sizeof(ContentChunk)) | ||
| 118 | return Loader::ResultStatus::Error; | ||
| 119 | } | ||
| 120 | |||
| 121 | return Loader::ResultStatus::Success; | 72 | return Loader::ResultStatus::Success; |
| 122 | } | 73 | } |
| 123 | 74 | ||