CheckNcchCrypto() -> SetupNcchCrypto()

This commit is contained in:
d0k3 2016-12-08 13:14:20 +01:00
parent 310159f0cb
commit 514e57c1f4
3 changed files with 5 additions and 4 deletions

View File

@ -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,

View File

@ -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);

View File

@ -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);