mirror of
https://github.com/Dark98/threeSD.git
synced 2026-07-03 00:38:58 +00:00
core/ncch: Add ticket
Added structure and fake ticket building (from GodMode9)
This commit is contained in:
@@ -17,6 +17,8 @@ add_library(core STATIC
|
||||
ncch/seed_db.h
|
||||
ncch/smdh.cpp
|
||||
ncch/smdh.h
|
||||
ncch/ticket.cpp
|
||||
ncch/ticket.h
|
||||
ncch/title_metadata.cpp
|
||||
ncch/title_metadata.h
|
||||
quick_decryptor.cpp
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright 2020 Pengfei Zhu
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <cstring>
|
||||
#include <string_view>
|
||||
#include "core/ncch/ticket.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
constexpr std::string_view TicketIssuer = "Root-CA00000003-XS0000000c";
|
||||
|
||||
// TODO: Make use of this?
|
||||
constexpr std::string_view TicketIssuerDev = "Root-CA00000004-XS00000009";
|
||||
|
||||
// From GodMode9
|
||||
constexpr std::array<u8, 44> TicketContentIndex{
|
||||
{0x00, 0x01, 0x00, 0x14, 0x00, 0x00, 0x00, 0xAC, 0x00, 0x00, 0x00, 0x14, 0x00, 0x01, 0x00,
|
||||
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
|
||||
0x00, 0x84, 0x00, 0x00, 0x00, 0x84, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
|
||||
|
||||
// Values taken from GodMode9
|
||||
Ticket BuildFakeTicket(u64 title_id) {
|
||||
Ticket ticket{};
|
||||
ticket.signature_type = 0x10004; // RSA_2048 SHA256
|
||||
std::memset(ticket.signature.data(), 0xFF, ticket.signature.size());
|
||||
std::memcpy(ticket.issuer.data(), TicketIssuer.data(), TicketIssuer.size());
|
||||
std::memset(ticket.ecc_public_key.data(), 0xFF, ticket.ecc_public_key.size());
|
||||
ticket.version = 0x01;
|
||||
std::memset(ticket.title_key.data(), 0xFF, ticket.title_key.size());
|
||||
ticket.title_id = title_id;
|
||||
ticket.common_key_index = 0x00;
|
||||
ticket.audit = 0x01;
|
||||
std::memset(ticket.content_index.data(), 0xFF, ticket.content_index.size());
|
||||
std::memcpy(ticket.content_index.data(), TicketContentIndex.data(), TicketContentIndex.size());
|
||||
return ticket;
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright 2018 Citra Emulator Project / 2020 Pengfei Zhu
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/swap.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
/**
|
||||
* Structure of the ticket.
|
||||
* The ticket we are using is RSA_2048 SHA256.
|
||||
*/
|
||||
#pragma pack(push, 1)
|
||||
struct Ticket {
|
||||
u32_be signature_type;
|
||||
std::array<u8, 0x100> signature;
|
||||
INSERT_PADDING_BYTES(0x3C);
|
||||
std::array<u8, 0x40> issuer;
|
||||
std::array<u8, 0x3C> ecc_public_key;
|
||||
u8 version;
|
||||
u8 ca_crl_version;
|
||||
u8 signer_crl_version;
|
||||
std::array<u8, 0x10> title_key;
|
||||
INSERT_PADDING_BYTES(1);
|
||||
u64_be ticket_id;
|
||||
u32_be console_id;
|
||||
u64_be title_id;
|
||||
INSERT_PADDING_BYTES(2);
|
||||
u16_be ticket_title_version;
|
||||
INSERT_PADDING_BYTES(8);
|
||||
u8 license_type;
|
||||
u8 common_key_index;
|
||||
INSERT_PADDING_BYTES(0x2A);
|
||||
u32_be eshop_account_id;
|
||||
INSERT_PADDING_BYTES(1);
|
||||
u8 audit;
|
||||
INSERT_PADDING_BYTES(0x42);
|
||||
std::array<u8, 0x40> limits;
|
||||
std::array<u8, 0xAC> content_index;
|
||||
};
|
||||
static_assert(sizeof(Ticket) == 0x350, "Ticket size is wrong");
|
||||
#pragma pack(pop)
|
||||
|
||||
Ticket BuildFakeTicket(u64 title_id);
|
||||
|
||||
} // namespace Core
|
||||
Reference in New Issue
Block a user