diff options
| author | 2019-04-17 11:29:21 -0400 | |
|---|---|---|
| committer | 2019-07-07 21:38:33 -0400 | |
| commit | d9ef20e5a53166fe3ecdca5ed225232eb7ad2f64 (patch) | |
| tree | 25854c9201231a9b94cd884ea288f0ed84a6f790 /src/core | |
| parent | key_manager: Add structure for Ticket parsing (diff) | |
| download | yuzu-d9ef20e5a53166fe3ecdca5ed225232eb7ad2f64.tar.gz yuzu-d9ef20e5a53166fe3ecdca5ed225232eb7ad2f64.tar.xz yuzu-d9ef20e5a53166fe3ecdca5ed225232eb7ad2f64.zip | |
es: Populate/synthesize tickets on construction
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/crypto/key_manager.cpp | 26 | ||||
| -rw-r--r-- | src/core/crypto/key_manager.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/es/es.cpp | 5 |
3 files changed, 17 insertions, 15 deletions
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 558790a49..3c51e3dc2 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp | |||
| @@ -406,9 +406,7 @@ std::optional<std::pair<Key128, Key128>> ParseTicket(const Ticket& ticket, | |||
| 406 | if (issuer == std::array<u8, 0x40>{}) | 406 | if (issuer == std::array<u8, 0x40>{}) |
| 407 | return {}; | 407 | return {}; |
| 408 | if (issuer[0] != 'R' || issuer[1] != 'o' || issuer[2] != 'o' || issuer[3] != 't') { | 408 | if (issuer[0] != 'R' || issuer[1] != 'o' || issuer[2] != 'o' || issuer[3] != 't') { |
| 409 | LOG_INFO(Crypto, | 409 | LOG_INFO(Crypto, "Attempting to parse ticket with non-standard certificate authority."); |
| 410 | "Attempting to parse ticket with non-standard certificate authority {:08X}.", | ||
| 411 | issuer); | ||
| 412 | } | 410 | } |
| 413 | 411 | ||
| 414 | Key128 rights_id = ticket.GetData().rights_id; | 412 | Key128 rights_id = ticket.GetData().rights_id; |
| @@ -481,16 +479,6 @@ KeyManager::KeyManager() { | |||
| 481 | AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, "title.keys_autogenerated", true); | 479 | AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, "title.keys_autogenerated", true); |
| 482 | AttemptLoadKeyFile(yuzu_keys_dir, hactool_keys_dir, "console.keys", false); | 480 | AttemptLoadKeyFile(yuzu_keys_dir, hactool_keys_dir, "console.keys", false); |
| 483 | AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, "console.keys_autogenerated", false); | 481 | AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, "console.keys_autogenerated", false); |
| 484 | |||
| 485 | for (const auto& key : s128_keys) { | ||
| 486 | if (key.first.type == S128KeyType::Titlekey) { | ||
| 487 | u128 rights_id{key.first.field1, key.first.field2}; | ||
| 488 | Key128 rights_id_2; | ||
| 489 | std::memcpy(rights_id_2.data(), rights_id.data(), rights_id_2.size()); | ||
| 490 | const auto ticket = Ticket::SynthesizeCommon(key.second, rights_id_2); | ||
| 491 | common_tickets.insert_or_assign(rights_id, ticket); | ||
| 492 | } | ||
| 493 | } | ||
| 494 | } | 482 | } |
| 495 | 483 | ||
| 496 | static bool ValidCryptoRevisionString(std::string_view base, size_t begin, size_t length) { | 484 | static bool ValidCryptoRevisionString(std::string_view base, size_t begin, size_t length) { |
| @@ -1011,6 +999,18 @@ void KeyManager::PopulateTickets() { | |||
| 1011 | } | 999 | } |
| 1012 | } | 1000 | } |
| 1013 | 1001 | ||
| 1002 | void KeyManager::SynthesizeTickets() { | ||
| 1003 | for (const auto& key : s128_keys) { | ||
| 1004 | if (key.first.type == S128KeyType::Titlekey) { | ||
| 1005 | u128 rights_id{key.first.field1, key.first.field2}; | ||
| 1006 | Key128 rights_id_2; | ||
| 1007 | std::memcpy(rights_id_2.data(), rights_id.data(), rights_id_2.size()); | ||
| 1008 | const auto ticket = Ticket::SynthesizeCommon(key.second, rights_id_2); | ||
| 1009 | common_tickets.insert_or_assign(rights_id, ticket); | ||
| 1010 | } | ||
| 1011 | } | ||
| 1012 | } | ||
| 1013 | |||
| 1014 | void KeyManager::SetKeyWrapped(S128KeyType id, Key128 key, u64 field1, u64 field2) { | 1014 | void KeyManager::SetKeyWrapped(S128KeyType id, Key128 key, u64 field1, u64 field2) { |
| 1015 | if (key == Key128{}) | 1015 | if (key == Key128{}) |
| 1016 | return; | 1016 | return; |
diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h index ff6bd08e1..d4e89d35c 100644 --- a/src/core/crypto/key_manager.h +++ b/src/core/crypto/key_manager.h | |||
| @@ -236,6 +236,7 @@ public: | |||
| 236 | void DeriveBase(); | 236 | void DeriveBase(); |
| 237 | void DeriveETicket(PartitionDataManager& data); | 237 | void DeriveETicket(PartitionDataManager& data); |
| 238 | void PopulateTickets(); | 238 | void PopulateTickets(); |
| 239 | void SynthesizeTickets(); | ||
| 239 | 240 | ||
| 240 | void PopulateFromPartitionData(PartitionDataManager& data); | 241 | void PopulateFromPartitionData(PartitionDataManager& data); |
| 241 | 242 | ||
diff --git a/src/core/hle/service/es/es.cpp b/src/core/hle/service/es/es.cpp index 7e01f88b9..92fa2bef8 100644 --- a/src/core/hle/service/es/es.cpp +++ b/src/core/hle/service/es/es.cpp | |||
| @@ -56,6 +56,9 @@ public: | |||
| 56 | }; | 56 | }; |
| 57 | // clang-format on | 57 | // clang-format on |
| 58 | RegisterHandlers(functions); | 58 | RegisterHandlers(functions); |
| 59 | |||
| 60 | keys.PopulateTickets(); | ||
| 61 | keys.SynthesizeTickets(); | ||
| 59 | } | 62 | } |
| 60 | 63 | ||
| 61 | private: | 64 | private: |
| @@ -125,7 +128,6 @@ private: | |||
| 125 | void CountCommonTicket(Kernel::HLERequestContext& ctx) { | 128 | void CountCommonTicket(Kernel::HLERequestContext& ctx) { |
| 126 | LOG_DEBUG(Service_ETicket, "called"); | 129 | LOG_DEBUG(Service_ETicket, "called"); |
| 127 | 130 | ||
| 128 | keys.PopulateTickets(); | ||
| 129 | const auto count = keys.GetCommonTickets().size(); | 131 | const auto count = keys.GetCommonTickets().size(); |
| 130 | 132 | ||
| 131 | IPC::ResponseBuilder rb{ctx, 3}; | 133 | IPC::ResponseBuilder rb{ctx, 3}; |
| @@ -136,7 +138,6 @@ private: | |||
| 136 | void CountPersonalizedTicket(Kernel::HLERequestContext& ctx) { | 138 | void CountPersonalizedTicket(Kernel::HLERequestContext& ctx) { |
| 137 | LOG_DEBUG(Service_ETicket, "called"); | 139 | LOG_DEBUG(Service_ETicket, "called"); |
| 138 | 140 | ||
| 139 | keys.PopulateTickets(); | ||
| 140 | const auto count = keys.GetPersonalizedTickets().size(); | 141 | const auto count = keys.GetPersonalizedTickets().size(); |
| 141 | 142 | ||
| 142 | IPC::ResponseBuilder rb{ctx, 3}; | 143 | IPC::ResponseBuilder rb{ctx, 3}; |