From 514e57c1f4da39f90f841df15d410b53f7f77bc4 Mon Sep 17 00:00:00 2001 From: d0k3 Date: Thu, 8 Dec 2016 13:14:20 +0100 Subject: [PATCH] CheckNcchCrypto() -> SetupNcchCrypto() --- source/game/ncch.c | 5 +++-- source/game/ncch.h | 2 +- source/virtual/vgame.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/source/game/ncch.c b/source/game/ncch.c index 5e0fe65..c842073 100644 --- a/source/game/ncch.c +++ b/source/game/ncch.c @@ -193,8 +193,9 @@ u32 SetNcchKey(NcchHeader* ncch, u32 keyid) { return 0; } -u32 CheckNcchCrypto(NcchHeader* ncch) { - return ((SetNcchKey(ncch, 0) == 0) && (SetNcchKey(ncch, 1) == 0)) ? 0 : 1; +u32 SetupNcchCrypto(NcchHeader* ncch) { + return (!NCCH_ENCRYPTED(ncch) || + ((SetNcchKey(ncch, 0) == 0) && (SetNcchKey(ncch, 1) == 0))) ? 0 : 1; } u32 DecryptNcchSection(u8* data, u32 offset_data, u32 size_data, diff --git a/source/game/ncch.h b/source/game/ncch.h index 5ae3e78..1dba4bb 100644 --- a/source/game/ncch.h +++ b/source/game/ncch.h @@ -60,5 +60,5 @@ typedef struct { } __attribute__((packed)) NcchHeader; u32 ValidateNcchHeader(NcchHeader* header); -u32 CheckNcchCrypto(NcchHeader* ncch); +u32 SetupNcchCrypto(NcchHeader* ncch); u32 DecryptNcch(u8* data, u32 offset, u32 size, NcchHeader* ncch, ExeFsHeader* exefs); diff --git a/source/virtual/vgame.c b/source/virtual/vgame.c index 5ac392a..4ba96ff 100644 --- a/source/virtual/vgame.c +++ b/source/virtual/vgame.c @@ -92,7 +92,7 @@ bool BuildVGameNcchDir(void) { u32 n = 0; // NCCH crypto - bool ncch_crypto = (CheckNcchCrypto(ncch) == 0); + bool ncch_crypto = (NCCH_ENCRYPTED(ncch)) && (SetupNcchCrypto(ncch) == 0); // header strncpy(templates[n].name, NAME_NCCH_HEADER, 32);