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/crypto/key_manager.cpp | |
| 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/crypto/key_manager.cpp')
| -rw-r--r-- | src/core/crypto/key_manager.cpp | 26 |
1 files changed, 13 insertions, 13 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; |