diff --git a/include/install/remote_nsp.hpp b/include/install/remote_nsp.hpp index 4551a13..fe254a4 100755 --- a/include/install/remote_nsp.hpp +++ b/include/install/remote_nsp.hpp @@ -45,7 +45,6 @@ namespace tin::install::nsp virtual void RetrieveHeader(); virtual const PFS0BaseHeader* GetBaseHeader(); - virtual void BufferNCAHeader(void* buf, NcmContentId placeholderId); virtual u64 GetDataOffset(); virtual const PFS0FileEntry* GetFileEntry(unsigned int index); diff --git a/source/install/install_nsp_remote.cpp b/source/install/install_nsp_remote.cpp index 7cfafe8..67d621e 100755 --- a/source/install/install_nsp_remote.cpp +++ b/source/install/install_nsp_remote.cpp @@ -94,15 +94,16 @@ namespace tin::install::nsp if (inst::config::validateNCAs && !declinedValidation) { - tin::install::NcaHeader header; - m_remoteNSP->BufferNCAHeader(&header, ncaId); - Crypto::AesXtr crypto(Crypto::Keys().headerKey); - crypto.decrypt(&header, &header, sizeof(header), 0, 0x200); + tin::install::NcaHeader* header = new NcaHeader; + m_remoteNSP->BufferData(header, m_remoteNSP->GetDataOffset() + fileEntry->dataOffset, sizeof(tin::install::NcaHeader)); - if (header.magic != MAGIC_NCA3) + Crypto::AesXtr crypto(Crypto::Keys().headerKey); + crypto.decrypt(header, header, sizeof(tin::install::NcaHeader), 0, 0x200); + + if (header->magic != MAGIC_NCA3) THROW_FORMAT("Invalid NCA magic"); - if (!Crypto::rsa2048PssVerify(&header.magic, 0x200, header.fixed_key_sig, Crypto::NCAHeaderSignature)) + if (!Crypto::rsa2048PssVerify(&header->magic, 0x200, header->fixed_key_sig, Crypto::NCAHeaderSignature)) { int rc = inst::ui::mainApp->CreateShowDialog("Invalid NCA signature detected!", "The software you are trying to install may contain malicious contents!\nOnly install improperly signed software from trustworthy sources!\nThis warning can be disabled in Awoo Installer's settings.\n\nAre you sure you want to continue the installation?", {"Cancel", "Yes, I want a brick"}, false); if (rc != 1) diff --git a/source/install/remote_nsp.cpp b/source/install/remote_nsp.cpp index 4e07303..19ae879 100755 --- a/source/install/remote_nsp.cpp +++ b/source/install/remote_nsp.cpp @@ -134,13 +134,6 @@ namespace tin::install::nsp return reinterpret_cast(m_headerBytes.data()); } - void RemoteNSP::BufferNCAHeader(void* buf, NcmContentId placeholderId) - { - const PFS0FileEntry* fileEntry = this->GetFileEntryByNcaId(placeholderId); - u64 pfs0Offset = this->GetDataOffset() + fileEntry->dataOffset; - this->BufferData(buf, pfs0Offset, 0xc00); - } - u64 RemoteNSP::GetDataOffset() { if (m_headerBytes.empty())