diff options
| author | 2020-05-12 20:46:14 +0200 | |
|---|---|---|
| committer | 2020-07-18 02:02:39 +0200 | |
| commit | 4d4bbe756f94c3bfc2df5265283596ee96cce9f9 (patch) | |
| tree | 0db0f4b064caacc529b24ed9eb8a7bcd21307bfb /src | |
| parent | Merge pull request #4344 from VolcaEM/c3 (diff) | |
| download | yuzu-4d4bbe756f94c3bfc2df5265283596ee96cce9f9.tar.gz yuzu-4d4bbe756f94c3bfc2df5265283596ee96cce9f9.tar.xz yuzu-4d4bbe756f94c3bfc2df5265283596ee96cce9f9.zip | |
file_sys/nsp: Make SetTicketKeys actually do something
Previously, the method wasn't modifying any class state and therefore not having any effects when called.
Since this has been the case for a very long time now, I'm not sure if we couldn't just remove this method altogether.
Diffstat (limited to '')
| -rw-r--r-- | src/core/file_sys/submission_package.cpp | 61 | ||||
| -rw-r--r-- | src/core/file_sys/submission_package.h | 1 |
2 files changed, 30 insertions, 32 deletions
diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp index 175a8266a..a6637fa39 100644 --- a/src/core/file_sys/submission_package.cpp +++ b/src/core/file_sys/submission_package.cpp | |||
| @@ -19,38 +19,6 @@ | |||
| 19 | #include "core/loader/loader.h" | 19 | #include "core/loader/loader.h" |
| 20 | 20 | ||
| 21 | namespace FileSys { | 21 | namespace FileSys { |
| 22 | namespace { | ||
| 23 | void SetTicketKeys(const std::vector<VirtualFile>& files) { | ||
| 24 | auto& keys = Core::Crypto::KeyManager::Instance(); | ||
| 25 | |||
| 26 | for (const auto& ticket_file : files) { | ||
| 27 | if (ticket_file == nullptr) { | ||
| 28 | continue; | ||
| 29 | } | ||
| 30 | |||
| 31 | if (ticket_file->GetExtension() != "tik") { | ||
| 32 | continue; | ||
| 33 | } | ||
| 34 | |||
| 35 | if (ticket_file->GetSize() < | ||
| 36 | Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET + sizeof(Core::Crypto::Key128)) { | ||
| 37 | continue; | ||
| 38 | } | ||
| 39 | |||
| 40 | Core::Crypto::Key128 key{}; | ||
| 41 | ticket_file->Read(key.data(), key.size(), Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET); | ||
| 42 | |||
| 43 | // We get the name without the extension in order to create the rights ID. | ||
| 44 | std::string name_only(ticket_file->GetName()); | ||
| 45 | name_only.erase(name_only.size() - 4); | ||
| 46 | |||
| 47 | const auto rights_id_raw = Common::HexStringToArray<16>(name_only); | ||
| 48 | u128 rights_id; | ||
| 49 | std::memcpy(rights_id.data(), rights_id_raw.data(), sizeof(u128)); | ||
| 50 | keys.SetKey(Core::Crypto::S128KeyType::Titlekey, key, rights_id[1], rights_id[0]); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | } // Anonymous namespace | ||
| 54 | 22 | ||
| 55 | NSP::NSP(VirtualFile file_) | 23 | NSP::NSP(VirtualFile file_) |
| 56 | : file(std::move(file_)), status{Loader::ResultStatus::Success}, | 24 | : file(std::move(file_)), status{Loader::ResultStatus::Success}, |
| @@ -232,6 +200,35 @@ VirtualDir NSP::GetParentDirectory() const { | |||
| 232 | return file->GetContainingDirectory(); | 200 | return file->GetContainingDirectory(); |
| 233 | } | 201 | } |
| 234 | 202 | ||
| 203 | void NSP::SetTicketKeys(const std::vector<VirtualFile>& files) { | ||
| 204 | for (const auto& ticket_file : files) { | ||
| 205 | if (ticket_file == nullptr) { | ||
| 206 | continue; | ||
| 207 | } | ||
| 208 | |||
| 209 | if (ticket_file->GetExtension() != "tik") { | ||
| 210 | continue; | ||
| 211 | } | ||
| 212 | |||
| 213 | if (ticket_file->GetSize() < | ||
| 214 | Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET + sizeof(Core::Crypto::Key128)) { | ||
| 215 | continue; | ||
| 216 | } | ||
| 217 | |||
| 218 | Core::Crypto::Key128 key{}; | ||
| 219 | ticket_file->Read(key.data(), key.size(), Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET); | ||
| 220 | |||
| 221 | // We get the name without the extension in order to create the rights ID. | ||
| 222 | std::string name_only(ticket_file->GetName()); | ||
| 223 | name_only.erase(name_only.size() - 4); | ||
| 224 | |||
| 225 | const auto rights_id_raw = Common::HexStringToArray<16>(name_only); | ||
| 226 | u128 rights_id; | ||
| 227 | std::memcpy(rights_id.data(), rights_id_raw.data(), sizeof(u128)); | ||
| 228 | keys.SetKey(Core::Crypto::S128KeyType::Titlekey, key, rights_id[1], rights_id[0]); | ||
| 229 | } | ||
| 230 | } | ||
| 231 | |||
| 235 | void NSP::InitializeExeFSAndRomFS(const std::vector<VirtualFile>& files) { | 232 | void NSP::InitializeExeFSAndRomFS(const std::vector<VirtualFile>& files) { |
| 236 | exefs = pfs; | 233 | exefs = pfs; |
| 237 | 234 | ||
diff --git a/src/core/file_sys/submission_package.h b/src/core/file_sys/submission_package.h index cf89de6a9..6d54bd807 100644 --- a/src/core/file_sys/submission_package.h +++ b/src/core/file_sys/submission_package.h | |||
| @@ -59,6 +59,7 @@ public: | |||
| 59 | VirtualDir GetParentDirectory() const override; | 59 | VirtualDir GetParentDirectory() const override; |
| 60 | 60 | ||
| 61 | private: | 61 | private: |
| 62 | void SetTicketKeys(const std::vector<VirtualFile>& files); | ||
| 62 | void InitializeExeFSAndRomFS(const std::vector<VirtualFile>& files); | 63 | void InitializeExeFSAndRomFS(const std::vector<VirtualFile>& files); |
| 63 | void ReadNCAs(const std::vector<VirtualFile>& files); | 64 | void ReadNCAs(const std::vector<VirtualFile>& files); |
| 64 | 65 | ||