mirror of
https://github.com/starr-dusT/yuzu-mainline
synced 2024-03-05 21:12:25 -08:00
es: Populate/synthesize tickets on construction
This commit is contained in:
parent
f8718ae779
commit
d9ef20e5a5
@ -406,9 +406,7 @@ std::optional<std::pair<Key128, Key128>> ParseTicket(const Ticket& ticket,
|
|||||||
if (issuer == std::array<u8, 0x40>{})
|
if (issuer == std::array<u8, 0x40>{})
|
||||||
return {};
|
return {};
|
||||||
if (issuer[0] != 'R' || issuer[1] != 'o' || issuer[2] != 'o' || issuer[3] != 't') {
|
if (issuer[0] != 'R' || issuer[1] != 'o' || issuer[2] != 'o' || issuer[3] != 't') {
|
||||||
LOG_INFO(Crypto,
|
LOG_INFO(Crypto, "Attempting to parse ticket with non-standard certificate authority.");
|
||||||
"Attempting to parse ticket with non-standard certificate authority {:08X}.",
|
|
||||||
issuer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Key128 rights_id = ticket.GetData().rights_id;
|
Key128 rights_id = ticket.GetData().rights_id;
|
||||||
@ -481,16 +479,6 @@ KeyManager::KeyManager() {
|
|||||||
AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, "title.keys_autogenerated", true);
|
AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, "title.keys_autogenerated", true);
|
||||||
AttemptLoadKeyFile(yuzu_keys_dir, hactool_keys_dir, "console.keys", false);
|
AttemptLoadKeyFile(yuzu_keys_dir, hactool_keys_dir, "console.keys", false);
|
||||||
AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, "console.keys_autogenerated", false);
|
AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, "console.keys_autogenerated", false);
|
||||||
|
|
||||||
for (const auto& key : s128_keys) {
|
|
||||||
if (key.first.type == S128KeyType::Titlekey) {
|
|
||||||
u128 rights_id{key.first.field1, key.first.field2};
|
|
||||||
Key128 rights_id_2;
|
|
||||||
std::memcpy(rights_id_2.data(), rights_id.data(), rights_id_2.size());
|
|
||||||
const auto ticket = Ticket::SynthesizeCommon(key.second, rights_id_2);
|
|
||||||
common_tickets.insert_or_assign(rights_id, ticket);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ValidCryptoRevisionString(std::string_view base, size_t begin, size_t length) {
|
static bool ValidCryptoRevisionString(std::string_view base, size_t begin, size_t length) {
|
||||||
@ -1011,6 +999,18 @@ void KeyManager::PopulateTickets() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KeyManager::SynthesizeTickets() {
|
||||||
|
for (const auto& key : s128_keys) {
|
||||||
|
if (key.first.type == S128KeyType::Titlekey) {
|
||||||
|
u128 rights_id{key.first.field1, key.first.field2};
|
||||||
|
Key128 rights_id_2;
|
||||||
|
std::memcpy(rights_id_2.data(), rights_id.data(), rights_id_2.size());
|
||||||
|
const auto ticket = Ticket::SynthesizeCommon(key.second, rights_id_2);
|
||||||
|
common_tickets.insert_or_assign(rights_id, ticket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void KeyManager::SetKeyWrapped(S128KeyType id, Key128 key, u64 field1, u64 field2) {
|
void KeyManager::SetKeyWrapped(S128KeyType id, Key128 key, u64 field1, u64 field2) {
|
||||||
if (key == Key128{})
|
if (key == Key128{})
|
||||||
return;
|
return;
|
||||||
|
@ -236,6 +236,7 @@ public:
|
|||||||
void DeriveBase();
|
void DeriveBase();
|
||||||
void DeriveETicket(PartitionDataManager& data);
|
void DeriveETicket(PartitionDataManager& data);
|
||||||
void PopulateTickets();
|
void PopulateTickets();
|
||||||
|
void SynthesizeTickets();
|
||||||
|
|
||||||
void PopulateFromPartitionData(PartitionDataManager& data);
|
void PopulateFromPartitionData(PartitionDataManager& data);
|
||||||
|
|
||||||
|
@ -56,6 +56,9 @@ public:
|
|||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
|
|
||||||
|
keys.PopulateTickets();
|
||||||
|
keys.SynthesizeTickets();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -125,7 +128,6 @@ private:
|
|||||||
void CountCommonTicket(Kernel::HLERequestContext& ctx) {
|
void CountCommonTicket(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_ETicket, "called");
|
LOG_DEBUG(Service_ETicket, "called");
|
||||||
|
|
||||||
keys.PopulateTickets();
|
|
||||||
const auto count = keys.GetCommonTickets().size();
|
const auto count = keys.GetCommonTickets().size();
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
@ -136,7 +138,6 @@ private:
|
|||||||
void CountPersonalizedTicket(Kernel::HLERequestContext& ctx) {
|
void CountPersonalizedTicket(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_ETicket, "called");
|
LOG_DEBUG(Service_ETicket, "called");
|
||||||
|
|
||||||
keys.PopulateTickets();
|
|
||||||
const auto count = keys.GetPersonalizedTickets().size();
|
const auto count = keys.GetPersonalizedTickets().size();
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
Loading…
Reference in New Issue
Block a user