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

Trivial changes.

This commit is contained in:
Pablo Curiel 2020-07-23 17:30:01 -04:00
parent e7f2c927c2
commit ee5a08f5d9
2 changed files with 8 additions and 4 deletions

View file

@ -320,10 +320,10 @@ void ncaWriteHierarchicalIntegrityPatchToMemoryBuffer(NcaContext *ctx, NcaHierar
void ncaRemoveTitlekeyCrypto(NcaContext *ctx) void ncaRemoveTitlekeyCrypto(NcaContext *ctx)
{ {
if (!ctx || !ctx->rights_id_available || !ctx->titlekey_retrieved) return; if (!ctx || ctx->content_size < NCA_FULL_HEADER_LENGTH || !ctx->rights_id_available || !ctx->titlekey_retrieved) return;
/* Copy decrypted titlekey to the decrypted NCA key area. */ /* Copy decrypted titlekey to the decrypted NCA key area. */
/* This will be reecrypted at a later stage. */ /* This will be reencrypted at a later stage. */
for(u8 i = 0; i < NCA_FS_HEADER_COUNT; i++) for(u8 i = 0; i < NCA_FS_HEADER_COUNT; i++)
{ {
/* AES-128-XTS is not used in FS sections from NCAs with titlekey crypto. */ /* AES-128-XTS is not used in FS sections from NCAs with titlekey crypto. */
@ -342,12 +342,15 @@ void ncaRemoveTitlekeyCrypto(NcaContext *ctx)
bool ncaEncryptHeader(NcaContext *ctx) bool ncaEncryptHeader(NcaContext *ctx)
{ {
if (!ctx || !strlen(ctx->content_id_str)) if (!ctx || !strlen(ctx->content_id_str) || ctx->content_size < NCA_FULL_HEADER_LENGTH)
{ {
LOGFILE("Invalid NCA context!"); LOGFILE("Invalid NCA context!");
return false; return false;
} }
/* Safety check: don't encrypt the header if we don't need to. */
if (!ctx->dirty_header) return true;
size_t crypt_res = 0; size_t crypt_res = 0;
const u8 *header_key = keysGetNcaHeaderKey(); const u8 *header_key = keysGetNcaHeaderKey();
Aes128XtsContext hdr_aes_ctx = {0}, nca0_fs_header_ctx = {0}; Aes128XtsContext hdr_aes_ctx = {0}, nca0_fs_header_ctx = {0};
@ -406,7 +409,7 @@ NX_INLINE bool ncaIsFsInfoEntryValid(NcaFsInfo *fs_info)
static bool ncaDecryptHeader(NcaContext *ctx) static bool ncaDecryptHeader(NcaContext *ctx)
{ {
if (!ctx || !strlen(ctx->content_id_str)) if (!ctx || !strlen(ctx->content_id_str) || ctx->content_size < NCA_FULL_HEADER_LENGTH)
{ {
LOGFILE("Invalid NCA context!"); LOGFILE("Invalid NCA context!");
return false; return false;

View file

@ -1,6 +1,7 @@
todo: todo:
nca: function to write re-encrypted nca headers / nca fs headers (don't forget nca0 please) nca: function to write re-encrypted nca headers / nca fs headers (don't forget nca0 please)
nca: function to patch the private npdm acid signature from a program nca + patch the acid signature from the nca header
tik: make sure the common crypto cert (XS20, XS22) is available when fakesigning a ticket tik: make sure the common crypto cert (XS20, XS22) is available when fakesigning a ticket
tik: automatically dump tickets to the SD card? tik: automatically dump tickets to the SD card?