[nstool] Add definitons and code for recognising INI/KIP files.

This commit is contained in:
jakcron 2018-11-05 14:54:30 +08:00
parent 8f9694a769
commit 5af7558a1b
2 changed files with 16 additions and 2 deletions

View file

@ -24,6 +24,8 @@
#include <nn/hac/define/nacp.h> #include <nn/hac/define/nacp.h>
#include <nn/hac/define/nso.h> #include <nn/hac/define/nso.h>
#include <nn/hac/define/nro.h> #include <nn/hac/define/nro.h>
#include <nn/hac/define/ini.h>
#include <nn/hac/define/kip.h>
#include <nn/hac/define/aset.h> #include <nn/hac/define/aset.h>
#include <nn/pki/SignedData.h> #include <nn/pki/SignedData.h>
#include <nn/pki/CertificateBody.h> #include <nn/pki/CertificateBody.h>
@ -52,7 +54,7 @@ void UserSettings::showHelp()
printf("\n General Options:\n"); printf("\n General Options:\n");
printf(" -d, --dev Use devkit keyset.\n"); printf(" -d, --dev Use devkit keyset.\n");
printf(" -k, --keyset Specify keyset file.\n"); printf(" -k, --keyset Specify keyset file.\n");
printf(" -t, --type Specify input file type. [xci, pfs, romfs, nca, meta, cnmt, nso, nro, nacp, aset, cert, tik]\n"); printf(" -t, --type Specify input file type. [xci, pfs, romfs, nca, meta, cnmt, nso, nro, ini, kip, nacp, aset, cert, tik]\n");
printf(" -y, --verify Verify file.\n"); printf(" -y, --verify Verify file.\n");
printf("\n Output Options:\n"); printf("\n Output Options:\n");
printf(" --showkeys Show keys generated.\n"); printf(" --showkeys Show keys generated.\n");
@ -610,6 +612,10 @@ FileType UserSettings::getFileTypeFromString(const std::string& type_str)
type = FILE_NSO; type = FILE_NSO;
else if (str == "nro") else if (str == "nro")
type = FILE_NRO; type = FILE_NRO;
else if (str == "ini")
type = FILE_INI;
else if (str == "kip")
type = FILE_KIP;
else if (str == "nacp") else if (str == "nacp")
type = FILE_NACP; type = FILE_NACP;
else if (str == "cert") else if (str == "cert")
@ -665,9 +671,15 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path)
// test nso // test nso
else if (_ASSERT_SIZE(sizeof(nn::hac::sNsoHeader)) && _TYPE_PTR(nn::hac::sNsoHeader)->st_magic.get() == nn::hac::nso::kNsoStructMagic) else if (_ASSERT_SIZE(sizeof(nn::hac::sNsoHeader)) && _TYPE_PTR(nn::hac::sNsoHeader)->st_magic.get() == nn::hac::nso::kNsoStructMagic)
file_type = FILE_NSO; file_type = FILE_NSO;
// test nso // test nro
else if (_ASSERT_SIZE(sizeof(nn::hac::sNroHeader)) && _TYPE_PTR(nn::hac::sNroHeader)->st_magic.get() == nn::hac::nro::kNroStructMagic) else if (_ASSERT_SIZE(sizeof(nn::hac::sNroHeader)) && _TYPE_PTR(nn::hac::sNroHeader)->st_magic.get() == nn::hac::nro::kNroStructMagic)
file_type = FILE_NRO; file_type = FILE_NRO;
// test ini
else if (_ASSERT_SIZE(sizeof(nn::hac::sIniHeader)) && _TYPE_PTR(nn::hac::sIniHeader)->st_magic.get() == nn::hac::ini::kIniStructMagic)
file_type = FILE_INI;
// test kip
else if (_ASSERT_SIZE(sizeof(nn::hac::sKipHeader)) && _TYPE_PTR(nn::hac::sKipHeader)->st_magic.get() == nn::hac::kip::kKipStructMagic)
file_type = FILE_KIP;
// test pki certificate // test pki certificate
else if (determineValidEsCertFromSample(scratch)) else if (determineValidEsCertFromSample(scratch))
file_type = FILE_PKI_CERT; file_type = FILE_PKI_CERT;

View file

@ -20,6 +20,8 @@ enum FileType
FILE_NSO, FILE_NSO,
FILE_NRO, FILE_NRO,
FILE_NACP, FILE_NACP,
FILE_INI,
FILE_KIP,
FILE_PKI_CERT, FILE_PKI_CERT,
FILE_ES_TIK, FILE_ES_TIK,
FILE_HB_ASSET, FILE_HB_ASSET,