1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-22 18:26:39 +00:00

Some small NACP and Ticket fixes.

Thanks to @0Liam
This commit is contained in:
Pablo Curiel 2021-12-01 18:35:19 +01:00
parent ffd2d8f8a4
commit 132fa3c6f0
3 changed files with 14 additions and 6 deletions

View file

@ -335,8 +335,8 @@ typedef struct {
u8 logo_handling; ///< NacpLogoHandling. u8 logo_handling; ///< NacpLogoHandling.
u8 runtime_add_on_content_install; ///< NacpRuntimeAddOnContentInstall. u8 runtime_add_on_content_install; ///< NacpRuntimeAddOnContentInstall.
u8 runtime_parameter_delivery; ///< NacpRuntimeParameterDelivery. u8 runtime_parameter_delivery; ///< NacpRuntimeParameterDelivery.
u8 undecided_parameter_75b8b; ///< NacpUndecidedParameter75b8b.
u8 reserved_1; u8 reserved_1;
u8 undecided_parameter_75b8b; ///< NacpUndecidedParameter75b8b.
u8 crash_report; ///< NacpCrashReport. u8 crash_report; ///< NacpCrashReport.
u8 hdcp; ///< NacpHdcp. u8 hdcp; ///< NacpHdcp.
u64 seed_for_pseudo_device_id; u64 seed_for_pseudo_device_id;

View file

@ -83,7 +83,7 @@ typedef enum {
NcaKeyGeneration_Since900NUP = 10, ///< 9.0.0 - 9.0.1. NcaKeyGeneration_Since900NUP = 10, ///< 9.0.0 - 9.0.1.
NcaKeyGeneration_Since910NUP = 11, ///< 9.1.0 - 12.0.3. NcaKeyGeneration_Since910NUP = 11, ///< 9.1.0 - 12.0.3.
NcaKeyGeneration_Since1210NUP = 12, ///< 12.1.0. NcaKeyGeneration_Since1210NUP = 12, ///< 12.1.0.
NcaKeyGeneration_Since1300NUP = 13, ///< 13.0.0. NcaKeyGeneration_Since1300NUP = 13, ///< 13.0.0 - 13.2.0.
NcaKeyGeneration_Current = NcaKeyGeneration_Since1300NUP, NcaKeyGeneration_Current = NcaKeyGeneration_Since1300NUP,
NcaKeyGeneration_Max = 32 NcaKeyGeneration_Max = 32
} NcaKeyGeneration; } NcaKeyGeneration;

View file

@ -108,6 +108,7 @@ bool tikRetrieveTicketByRightsId(Ticket *dst, const FsRightsId *id, bool use_gam
return false; return false;
} }
u8 key_generation = id->c[0xF];
TikCommonBlock *tik_common_block = NULL; TikCommonBlock *tik_common_block = NULL;
/* Check if this ticket has already been retrieved. */ /* Check if this ticket has already been retrieved. */
@ -135,16 +136,23 @@ bool tikRetrieveTicketByRightsId(Ticket *dst, const FsRightsId *id, bool use_gam
return false; return false;
} }
/* Even though tickets do have a proper key_generation field, we'll just retrieve it from the rights_id field. */ /* Get common ticket block. */
/* Old custom tools used to wipe the key_generation field or save its value to a different offset. */ tik_common_block = tikGetCommonBlock(dst->data);
if (!tikGetDecryptedTitleKey(dst->dec_titlekey, dst->enc_titlekey, id->c[0xF]))
/* Get proper key generation value. */
/* Nintendo didn't start putting the key generation value into the rights ID until HOS 3.0.1. */
/* If this is the case, we'll just use the key generation value from the common ticket block. */
/* However, old custom tools used to wipe the key generation field or save its value to a different offset, so this may fail with titles with custom/modified tickets. */
if (key_generation < NcaKeyGeneration_Since301NUP || key_generation > NcaKeyGeneration_Max) key_generation = tik_common_block->key_generation;
/* Get decrypted titlekey. */
if (!tikGetDecryptedTitleKey(dst->dec_titlekey, dst->enc_titlekey, key_generation))
{ {
LOG_MSG("Unable to decrypt titlekey!"); LOG_MSG("Unable to decrypt titlekey!");
return false; return false;
} }
/* Generate rights ID string. */ /* Generate rights ID string. */
tik_common_block = tikGetCommonBlock(dst->data);
utilsGenerateHexStringFromData(dst->rights_id_str, sizeof(dst->rights_id_str), tik_common_block->rights_id.c, sizeof(tik_common_block->rights_id.c), false); utilsGenerateHexStringFromData(dst->rights_id_str, sizeof(dst->rights_id_str), tik_common_block->rights_id.c, sizeof(tik_common_block->rights_id.c), false);
return true; return true;