smooth out validation process

This commit is contained in:
HookedBehemoth 2019-11-16 16:54:27 +01:00
parent 83f2d7670c
commit 9d02fbe3e8
5 changed files with 11 additions and 12 deletions

View file

@ -44,6 +44,7 @@ namespace tin::install
protected: protected:
const NcmStorageId m_destStorageId; const NcmStorageId m_destStorageId;
bool m_ignoreReqFirmVersion = false; bool m_ignoreReqFirmVersion = false;
bool declinedValidation = false;
nx::ncm::ContentMeta m_contentMeta; nx::ncm::ContentMeta m_contentMeta;

View file

@ -174,6 +174,7 @@ namespace tin::install
//consoleUpdate(NULL); //consoleUpdate(NULL);
this->InstallNCA(record.content_id); this->InstallNCA(record.content_id);
} }
declinedValidation = false;
printf("Post Install Records: \n"); printf("Post Install Records: \n");
//this->DebugPrintInstallData(); //this->DebugPrintInstallData();

View file

@ -42,7 +42,7 @@ SOFTWARE.
#include "ui/MainApplication.hpp" #include "ui/MainApplication.hpp"
namespace inst::ui { namespace inst::ui {
extern MainApplication *mainApp; extern MainApplication *mainApp;
} }
namespace tin::install::nsp namespace tin::install::nsp
@ -118,7 +118,7 @@ namespace tin::install::nsp
auto ncaFile = m_simpleFileSystem->OpenFile(ncaName); auto ncaFile = m_simpleFileSystem->OpenFile(ncaName);
if (inst::config::validateNCAs) if (inst::config::validateNCAs && !declinedValidation)
{ {
tin::install::NcaHeader header; tin::install::NcaHeader header;
ncaFile.Read(0, &header, 0xc00); ncaFile.Read(0, &header, 0xc00);
@ -126,13 +126,14 @@ namespace tin::install::nsp
crypto.decrypt(&header, &header, sizeof(header), 0, 0x200); crypto.decrypt(&header, &header, sizeof(header), 0, 0x200);
if (header.magic != MAGIC_NCA3) if (header.magic != MAGIC_NCA3)
throw "Invalid NCA magic"; 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("NCA validation failed", "The followings NCA's signature failed:\n" + tin::util::GetNcaIdString(ncaId) + "\n\nDo you really want to risk bricking your switch?", {"No", "Of cause not", "*sigh* Yes", "Cancel"}, true); int rc = inst::ui::mainApp->CreateShowDialog("NCA validation failed", "The followings NCA's signature failed:\n" + tin::util::GetNcaIdString(ncaId) + "\n\nDo you really want to risk bricking your switch?", {"No", "Of cause not", "*sigh* Yes", "Cancel"}, true);
if (rc != 2) if (rc != 2)
return;// should be a throw but that will get stuck and idk sh my head... THROW_FORMAT("Unsigned NCA");
declinedValidation = true;
} }
} }

View file

@ -93,7 +93,7 @@ namespace tin::install::nsp
printf("Size: 0x%lx\n", ncaSize); printf("Size: 0x%lx\n", ncaSize);
if (inst::config::validateNCAs) if (inst::config::validateNCAs && !declinedValidation)
{ {
tin::install::NcaHeader header; tin::install::NcaHeader header;
m_remoteNSP->BufferNCAHeader(&header, ncaId); m_remoteNSP->BufferNCAHeader(&header, ncaId);
@ -101,13 +101,14 @@ namespace tin::install::nsp
crypto.decrypt(&header, &header, sizeof(header), 0, 0x200); crypto.decrypt(&header, &header, sizeof(header), 0, 0x200);
if (header.magic != MAGIC_NCA3) if (header.magic != MAGIC_NCA3)
throw "Invalid NCA magic"; 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("NCA validation failed", "The followings NCA's signature failed:\n" + tin::util::GetNcaIdString(ncaId) + "\n\nDo you really want to risk bricking your switch?", {"No", "Of cause not", "*sigh* Yes", "Cancel"}, true); int rc = inst::ui::mainApp->CreateShowDialog("NCA validation failed", "The followings NCA's signature failed:\n" + tin::util::GetNcaIdString(ncaId) + "\n\nDo you really want to risk bricking your switch?", {"No", "Of cause not", "*sigh* Yes", "Cancel"}, true);
if (rc != 2) if (rc != 2)
return;// should be a throw but that will get stuck and idk sh my head... THROW_FORMAT("Unsigned NCA");
declinedValidation = true;
} }
} }

View file

@ -27,11 +27,6 @@ SOFTWARE.
#include "util/config.hpp" #include "util/config.hpp"
#include "util/title_util.hpp" #include "util/title_util.hpp"
#include "install/nca.hpp" #include "install/nca.hpp"
#include "ui/MainApplication.hpp"
namespace inst::ui {
extern MainApplication *mainApp;
}
void append(std::vector<u8>& buffer, const u8* ptr, u64 sz) void append(std::vector<u8>& buffer, const u8* ptr, u64 sz)
{ {