mirror of
https://github.com/Dark98/threeSD.git
synced 2026-07-03 00:38:58 +00:00
Simplify TitleKeysBin implementation to a simple function
This commit is contained in:
@@ -154,10 +154,11 @@ bool CIABuilder::WriteTicket(const std::string& ticket_db_path,
|
||||
ticket.body.common_key_index = legit_ticket.body.common_key_index;
|
||||
ticket.body.title_key = legit_ticket.body.title_key;
|
||||
|
||||
} else if (TitleKeysBin enc_title_keys(enc_title_keys_bin_path);
|
||||
enc_title_keys.IsGood() && enc_title_keys.entries.count(title_id)) { // support files
|
||||
} else if (TitleKeysMap enc_title_keys;
|
||||
LoadTitleKeysBin(enc_title_keys, enc_title_keys_bin_path) &&
|
||||
enc_title_keys.count(title_id)) { // support files
|
||||
|
||||
const auto& entry = enc_title_keys.entries.at(title_id);
|
||||
const auto& entry = enc_title_keys.at(title_id);
|
||||
ticket.body.common_key_index = entry.common_key_index;
|
||||
ticket.body.title_key = entry.title_key;
|
||||
} else {
|
||||
|
||||
@@ -7,17 +7,7 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
TitleKeysBin::TitleKeysBin(const std::string& path) {
|
||||
is_good = Load(path);
|
||||
}
|
||||
|
||||
TitleKeysBin::~TitleKeysBin() = default;
|
||||
|
||||
bool TitleKeysBin::IsGood() const {
|
||||
return is_good;
|
||||
}
|
||||
|
||||
bool TitleKeysBin::Load(const std::string& path) {
|
||||
bool LoadTitleKeysBin(TitleKeysMap& out, const std::string& path) {
|
||||
FileUtil::IOFile file(path, "rb");
|
||||
if (!file) {
|
||||
LOG_ERROR(Core, "Could not open file {}", path);
|
||||
@@ -36,7 +26,7 @@ bool TitleKeysBin::Load(const std::string& path) {
|
||||
LOG_ERROR(Core, "Could not read entry {} from {}", i, path);
|
||||
return false;
|
||||
}
|
||||
entries.emplace(entry.title_id, entry);
|
||||
out.emplace(entry.title_id, entry);
|
||||
}
|
||||
|
||||
if (file.Tell() != file.GetSize()) {
|
||||
|
||||
@@ -26,19 +26,9 @@ struct TitleKeysBinEntry {
|
||||
};
|
||||
static_assert(sizeof(TitleKeysBinEntry) == 32);
|
||||
|
||||
using TitleKeysMap = std::unordered_map<u64, TitleKeysBinEntry>;
|
||||
|
||||
// GM9 support files encTitleKeys.bin and decTitleKeys.bin.
|
||||
class TitleKeysBin {
|
||||
public:
|
||||
explicit TitleKeysBin(const std::string& path);
|
||||
~TitleKeysBin();
|
||||
|
||||
bool IsGood() const;
|
||||
|
||||
std::unordered_map<u64, TitleKeysBinEntry> entries;
|
||||
|
||||
private:
|
||||
bool Load(const std::string& path);
|
||||
bool is_good = false;
|
||||
};
|
||||
bool LoadTitleKeysBin(TitleKeysMap& out, const std::string& path);
|
||||
|
||||
} // namespace Core
|
||||
|
||||
Reference in New Issue
Block a user