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:
const NcmStorageId m_destStorageId;
bool m_ignoreReqFirmVersion = false;
bool declinedValidation = false;
nx::ncm::ContentMeta m_contentMeta;

View File

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

View File

@ -42,7 +42,7 @@ SOFTWARE.
#include "ui/MainApplication.hpp"
namespace inst::ui {
extern MainApplication *mainApp;
extern MainApplication *mainApp;
}
namespace tin::install::nsp
@ -118,7 +118,7 @@ namespace tin::install::nsp
auto ncaFile = m_simpleFileSystem->OpenFile(ncaName);
if (inst::config::validateNCAs)
if (inst::config::validateNCAs && !declinedValidation)
{
tin::install::NcaHeader header;
ncaFile.Read(0, &header, 0xc00);
@ -126,13 +126,14 @@ namespace tin::install::nsp
crypto.decrypt(&header, &header, sizeof(header), 0, 0x200);
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))
{
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)
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);
if (inst::config::validateNCAs)
if (inst::config::validateNCAs && !declinedValidation)
{
tin::install::NcaHeader header;
m_remoteNSP->BufferNCAHeader(&header, ncaId);
@ -101,13 +101,14 @@ namespace tin::install::nsp
crypto.decrypt(&header, &header, sizeof(header), 0, 0x200);
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))
{
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)
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/title_util.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)
{