mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2024-11-22 18:26:39 +00:00
Codestyle fixes.
This commit is contained in:
parent
e2b4ebc5d4
commit
91fdff7816
7 changed files with 49 additions and 34 deletions
|
@ -286,8 +286,6 @@ static u8 certGetCertificateType(const void *data, u64 data_size)
|
|||
return type;
|
||||
}
|
||||
|
||||
offset += MEMBER_SIZE(CertCommonBlock, issuer);
|
||||
|
||||
memcpy(&pub_key_type, data_u8 + offset, sizeof(u32));
|
||||
pub_key_type = __builtin_bswap32(pub_key_type);
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ typedef struct {
|
|||
|
||||
/// Placed after the certificate signature block.
|
||||
typedef struct {
|
||||
char issuer[0x40];
|
||||
u32 pub_key_type; ///< CertPubKeyType.
|
||||
char name[0x40];
|
||||
u32 date;
|
||||
|
|
|
@ -49,12 +49,12 @@ typedef enum {
|
|||
GameCardRomSize_32GiB = 0xE2
|
||||
} GameCardRomSize;
|
||||
|
||||
typedef struct {
|
||||
u8 autoboot : 1;
|
||||
u8 history_erase : 1;
|
||||
u8 repair_tool : 1;
|
||||
u8 different_region_cup_to_terra_device : 1;
|
||||
u8 different_region_cup_to_global_device : 1;
|
||||
typedef enum {
|
||||
GameCardFlags_AutoBoot = BIT(0),
|
||||
GameCardFlags_HistoryErase = BIT(1),
|
||||
GameCardFlags_RepairTool = BIT(2),
|
||||
GameCardFlags_DifferentRegionCupToTerraDevice = BIT(3),
|
||||
GameCardFlags_DifferentRegionCupToGlobalDevice = BIT(4)
|
||||
} GameCardFlags;
|
||||
|
||||
typedef enum {
|
||||
|
@ -102,7 +102,7 @@ typedef struct {
|
|||
GameCardKeyFlags key_flags;
|
||||
u8 rom_size; ///< GameCardRomSize.
|
||||
u8 header_version;
|
||||
GameCardFlags flags;
|
||||
u8 flags; ///< GameCardFlags.
|
||||
u64 package_id;
|
||||
u32 valid_data_end_address; ///< Expressed in GAMECARD_MEDIA_UNIT_SIZE blocks.
|
||||
u8 reserved[0x4];
|
||||
|
|
16
source/nca.h
16
source/nca.h
|
@ -52,12 +52,12 @@ typedef enum {
|
|||
} NcaDistributionType;
|
||||
|
||||
typedef enum {
|
||||
NcaContentType_Program = 0,
|
||||
NcaContentType_Meta = 1,
|
||||
NcaContentType_Control = 2,
|
||||
NcaContentType_Manual = 3,
|
||||
NcaContentType_Data = 4,
|
||||
NcaContentType_PublicData = 5
|
||||
NcaContentType_Program = 0,
|
||||
NcaContentType_Meta = 1,
|
||||
NcaContentType_Control = 2,
|
||||
NcaContentType_Manual = 3,
|
||||
NcaContentType_Data = 4,
|
||||
NcaContentType_PublicData = 5
|
||||
} NcaContentType;
|
||||
|
||||
typedef enum {
|
||||
|
@ -88,8 +88,8 @@ typedef enum {
|
|||
NcaKeyGeneration_700_801 = 8,
|
||||
NcaKeyGeneration_810_811 = 9,
|
||||
NcaKeyGeneration_900_901 = 10,
|
||||
NcaKeyGeneration_910_1001 = 11,
|
||||
NcaKeyGeneration_Current = NcaKeyGeneration_910_1001
|
||||
NcaKeyGeneration_910_1002 = 11,
|
||||
NcaKeyGeneration_Current = NcaKeyGeneration_910_1002
|
||||
} NcaKeyGeneration;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -33,24 +33,28 @@ typedef struct {
|
|||
u32 sig_type; ///< SignatureType_Rsa4096Sha1, SignatureType_Rsa4096Sha256.
|
||||
u8 signature[0x200];
|
||||
u8 padding[0x3C];
|
||||
char issuer[0x40];
|
||||
} SignatureBlockRsa4096;
|
||||
|
||||
typedef struct {
|
||||
u32 sig_type; ///< SignatureType_Rsa2048Sha1, SignatureType_Rsa2048Sha256.
|
||||
u8 signature[0x100];
|
||||
u8 padding[0x3C];
|
||||
char issuer[0x40];
|
||||
} SignatureBlockRsa2048;
|
||||
|
||||
typedef struct {
|
||||
u32 sig_type; ///< SignatureType_Ecc480Sha1, SignatureType_Ecc480Sha256.
|
||||
u8 signature[0x3C];
|
||||
u8 padding[0x40];
|
||||
char issuer[0x40];
|
||||
} SignatureBlockEcc480;
|
||||
|
||||
typedef struct {
|
||||
u32 sig_type; ///< SignatureType_Hmac160Sha1.
|
||||
u8 signature[0x14];
|
||||
u8 padding[0x28];
|
||||
char issuer[0x40];
|
||||
} SignatureBlockHmac160;
|
||||
|
||||
#endif /* __SIGNATURE_H__ */
|
||||
|
|
29
source/tik.c
29
source/tik.c
|
@ -151,6 +151,13 @@ void tikConvertPersonalizedTicketToCommonTicket(Ticket *tik)
|
|||
bool dev_cert = false;
|
||||
TikCommonBlock *tik_common_blk = NULL;
|
||||
|
||||
SignatureBlockRsa4096 *sig_rsa_4096 = NULL;
|
||||
SignatureBlockRsa2048 *sig_rsa_2048 = NULL;
|
||||
SignatureBlockEcc480 *sig_ecc_480 = NULL;
|
||||
SignatureBlockHmac160 *sig_hmac_160 = NULL;
|
||||
|
||||
char *sig_issuer = NULL;
|
||||
|
||||
tik_common_blk = tikGetCommonBlockFromTicket(tik);
|
||||
if (!tik_common_blk || tik_common_blk->titlekey_type != TikTitleKeyType_Personalized) return;
|
||||
|
||||
|
@ -158,28 +165,36 @@ void tikConvertPersonalizedTicketToCommonTicket(Ticket *tik)
|
|||
{
|
||||
case TikType_SigRsa4096:
|
||||
tik->size = sizeof(TikSigRsa4096);
|
||||
memset(tik->data + 4, 0xFF, MEMBER_SIZE(SignatureBlockRsa4096, signature));
|
||||
sig_rsa_4096 = (SignatureBlockRsa4096*)tik->data;
|
||||
memset(sig_rsa_4096->signature, 0xFF, sizeof(sig_rsa_4096->signature));
|
||||
sig_issuer = sig_rsa_4096->issuer;
|
||||
break;
|
||||
case TikType_SigRsa2048:
|
||||
tik->size = sizeof(TikSigRsa2048);
|
||||
memset(tik->data + 4, 0xFF, MEMBER_SIZE(SignatureBlockRsa2048, signature));
|
||||
sig_rsa_2048 = (SignatureBlockRsa2048*)tik->data;
|
||||
memset(sig_rsa_2048->signature, 0xFF, sizeof(sig_rsa_2048->signature));
|
||||
sig_issuer = sig_rsa_2048->issuer;
|
||||
break;
|
||||
case TikType_SigEcc480:
|
||||
tik->size = sizeof(TikSigEcc480);
|
||||
memset(tik->data + 4, 0xFF, MEMBER_SIZE(SignatureBlockEcc480, signature));
|
||||
sig_ecc_480 = (SignatureBlockEcc480*)tik->data;
|
||||
memset(sig_ecc_480->signature, 0xFF, sizeof(sig_ecc_480->signature));
|
||||
sig_issuer = sig_ecc_480->issuer;
|
||||
break;
|
||||
case TikType_SigHmac160:
|
||||
tik->size = sizeof(TikSigHmac160);
|
||||
memset(tik->data + 4, 0xFF, MEMBER_SIZE(SignatureBlockHmac160, signature));
|
||||
sig_hmac_160 = (SignatureBlockHmac160*)tik->data;
|
||||
memset(sig_hmac_160->signature, 0xFF, sizeof(sig_hmac_160->signature));
|
||||
sig_issuer = sig_hmac_160->issuer;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
dev_cert = (strstr(tik_common_blk->issuer, "CA00000004") != NULL);
|
||||
dev_cert = (strstr(sig_issuer, "CA00000004") != NULL);
|
||||
|
||||
memset(tik_common_blk->issuer, 0, sizeof(tik_common_blk->issuer));
|
||||
sprintf(tik_common_blk->issuer, "Root-CA%08X-XS00000020", dev_cert ? 4 : 3);
|
||||
memset(sig_issuer, 0, MEMBER_SIZE(SignatureBlockRsa4096, issuer));
|
||||
sprintf(sig_issuer, "Root-CA%08X-XS00000020", dev_cert ? 4 : 3);
|
||||
|
||||
memset(tik_common_blk->titlekey_block, 0, sizeof(tik_common_blk->titlekey_block));
|
||||
memcpy(tik_common_blk->titlekey_block, tik->enc_titlekey, 0x10);
|
||||
|
|
17
source/tik.h
17
source/tik.h
|
@ -47,13 +47,13 @@ typedef enum {
|
|||
TikLicenseType_Service = 5
|
||||
} TikLicenseType;
|
||||
|
||||
typedef struct {
|
||||
u8 preinstallation : 1;
|
||||
u8 shared_title : 1;
|
||||
u8 all_contents : 1;
|
||||
u8 device_link_independent : 1;
|
||||
u8 _volatile : 1;
|
||||
u8 elicense_required : 1;
|
||||
typedef enum {
|
||||
TikPropertyMask_PreInstallation = BIT(0),
|
||||
TikPropertyMask_SharedTitle = BIT(1),
|
||||
TikPropertyMask_AllContents = BIT(2),
|
||||
TikPropertyMask_DeviceLinkIndepedent = BIT(3),
|
||||
TikPropertyMask_Volatile = BIT(4),
|
||||
TikPropertyMask_ELicenseRequired = BIT(5)
|
||||
} TikPropertyMask;
|
||||
|
||||
typedef enum {
|
||||
|
@ -67,14 +67,13 @@ typedef enum {
|
|||
|
||||
/// Placed after the ticket signature block.
|
||||
typedef struct {
|
||||
char issuer[0x40];
|
||||
u8 titlekey_block[0x100];
|
||||
u8 format_version;
|
||||
u8 titlekey_type; ///< TikTitleKeyType.
|
||||
u16 ticket_version;
|
||||
u8 license_type; ///< TikLicenseType.
|
||||
u8 key_generation;
|
||||
TikPropertyMask property_mask;
|
||||
u8 property_mask; ///< TikPropertyMask.
|
||||
u8 reserved_1[0x9];
|
||||
u64 ticket_id;
|
||||
u64 device_id;
|
||||
|
|
Loading…
Reference in a new issue