Add proper support for CIA title keys

1. Support for `ticket.db`
2. Support for `gm9/support/encTitleKeys.bin`
3. Set the title key and common key index when building standard CIA
This commit is contained in:
Pengfei
2021-07-09 20:08:42 +08:00
parent 3429d9e965
commit 76b0912a9a
12 changed files with 268 additions and 34 deletions
+44
View File
@@ -0,0 +1,44 @@
// Copyright 2021 threeSD Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <array>
#include <unordered_map>
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/swap.h"
namespace Core {
struct TitleKeysBinHeader {
u32_le num_entries;
INSERT_PADDING_BYTES(12);
};
static_assert(sizeof(TitleKeysBinHeader) == 16);
struct TitleKeysBinEntry {
u32_be common_key_index;
INSERT_PADDING_BYTES(4);
u64_be title_id;
std::array<u8, 16> title_key;
};
static_assert(sizeof(TitleKeysBinEntry) == 32);
// 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;
};
} // namespace Core