mirror of
https://github.com/jakcron/nstool
synced 2024-11-15 02:06:40 +00:00
Update NcaProcess to support new libnintendo-hac
This commit is contained in:
parent
406c590129
commit
273ba3d14e
2 changed files with 28 additions and 28 deletions
2
deps/libnintendo-hac
vendored
2
deps/libnintendo-hac
vendored
|
@ -1 +1 @@
|
|||
Subproject commit a9950422a3484a1b2aba89ad7cd5a6b382f13491
|
||||
Subproject commit 70f9986819c74c230fd72811b0b246bb6d067ae3
|
|
@ -265,7 +265,7 @@ void NcaProcess::generatePartitionConfiguration()
|
|||
info.format_type = (nn::hac::nca::FormatType)fs_header.format_type;
|
||||
info.hash_type = (nn::hac::nca::HashType)fs_header.hash_type;
|
||||
info.enc_type = (nn::hac::nca::EncryptionType)fs_header.encryption_type;
|
||||
if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_SHA256)
|
||||
if (info.hash_type == nn::hac::nca::HashType::HierarchicalSha256)
|
||||
{
|
||||
// info.hash_tree_meta.importData(fs_header.hash_superblock, nn::hac::nca::kFsHeaderHashSuperblockLen, LayeredIntegrityMetadata::HASH_TYPE_SHA256);
|
||||
nn::hac::HierarchicalSha256Header hdr;
|
||||
|
@ -298,7 +298,7 @@ void NcaProcess::generatePartitionConfiguration()
|
|||
info.layered_intergrity_metadata.setDataLayerInfo(data_layer);
|
||||
info.layered_intergrity_metadata.setMasterHashList(master_hash_list);
|
||||
}
|
||||
else if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_INTERGRITY)
|
||||
else if (info.hash_type == nn::hac::nca::HashType::HierarchicalIntegrity)
|
||||
{
|
||||
// info.hash_tree_meta.importData(fs_header.hash_superblock, nn::hac::nca::kFsHeaderHashSuperblockLen, LayeredIntegrityMetadata::HASH_TYPE_INTEGRITY);
|
||||
nn::hac::HierarchicalIntegrityHeader hdr;
|
||||
|
@ -336,27 +336,27 @@ void NcaProcess::generatePartitionConfiguration()
|
|||
// filter out unrecognised format types
|
||||
switch (info.format_type)
|
||||
{
|
||||
case (nn::hac::nca::FORMAT_PFS0):
|
||||
case (nn::hac::nca::FORMAT_ROMFS):
|
||||
case (nn::hac::nca::FormatType::PartitionFs):
|
||||
case (nn::hac::nca::FormatType::RomFs):
|
||||
break;
|
||||
default:
|
||||
error.clear();
|
||||
error << "FormatType(" << info.format_type << "): UNKNOWN";
|
||||
error << "FormatType(" << nn::hac::ContentArchiveUtil::getFormatTypeAsString(info.format_type) << "): UNKNOWN";
|
||||
throw fnd::Exception(kModuleName, error.str());
|
||||
}
|
||||
|
||||
// create reader based on encryption type0
|
||||
if (info.enc_type == nn::hac::nca::CRYPT_NONE)
|
||||
if (info.enc_type == nn::hac::nca::EncryptionType::None)
|
||||
{
|
||||
info.reader = new fnd::OffsetAdjustedIFile(mFile, info.offset, info.size);
|
||||
}
|
||||
else if (info.enc_type == nn::hac::nca::CRYPT_AESCTR)
|
||||
else if (info.enc_type == nn::hac::nca::EncryptionType::AesCtr)
|
||||
{
|
||||
if (mContentKey.aes_ctr.isSet == false)
|
||||
throw fnd::Exception(kModuleName, "AES-CTR Key was not determined");
|
||||
info.reader = new fnd::OffsetAdjustedIFile(new fnd::AesCtrWrappedIFile(mFile, mContentKey.aes_ctr.var, info.aes_ctr), info.offset, info.size);
|
||||
}
|
||||
else if (info.enc_type == nn::hac::nca::CRYPT_AESXTS || info.enc_type == nn::hac::nca::CRYPT_AESCTREX)
|
||||
else if (info.enc_type == nn::hac::nca::EncryptionType::AesXts || info.enc_type == nn::hac::nca::EncryptionType::AesCtrEx)
|
||||
{
|
||||
error.clear();
|
||||
error << "EncryptionType(" << nn::hac::ContentArchiveUtil::getEncryptionTypeAsString(info.enc_type) << "): UNSUPPORTED";
|
||||
|
@ -365,19 +365,19 @@ void NcaProcess::generatePartitionConfiguration()
|
|||
else
|
||||
{
|
||||
error.clear();
|
||||
error << "EncryptionType(" << info.enc_type << "): UNKNOWN";
|
||||
error << "EncryptionType(" << nn::hac::ContentArchiveUtil::getEncryptionTypeAsString(info.enc_type) << "): UNKNOWN";
|
||||
throw fnd::Exception(kModuleName, error.str());
|
||||
}
|
||||
|
||||
// filter out unrecognised hash types, and hash based readers
|
||||
if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_SHA256 || info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_INTERGRITY)
|
||||
if (info.hash_type == nn::hac::nca::HashType::HierarchicalSha256 || info.hash_type == nn::hac::nca::HashType::HierarchicalIntegrity)
|
||||
{
|
||||
info.reader = new fnd::LayeredIntegrityWrappedIFile(info.reader, info.layered_intergrity_metadata);
|
||||
}
|
||||
else if (info.hash_type != nn::hac::nca::HASH_NONE)
|
||||
else if (info.hash_type != nn::hac::nca::HashType::None)
|
||||
{
|
||||
error.clear();
|
||||
error << "HashType(" << info.hash_type << "): UNKNOWN";
|
||||
error << "HashType(" << nn::hac::ContentArchiveUtil::getHashTypeAsString(info.hash_type) << "): UNKNOWN";
|
||||
throw fnd::Exception(kModuleName, error.str());
|
||||
}
|
||||
}
|
||||
|
@ -399,9 +399,9 @@ void NcaProcess::validateNcaSignatures()
|
|||
}
|
||||
|
||||
// validate signature[1]
|
||||
if (mHdr.getContentType() == nn::hac::nca::TYPE_PROGRAM)
|
||||
if (mHdr.getContentType() == nn::hac::nca::ContentType::Program)
|
||||
{
|
||||
if (mPartitions[nn::hac::nca::PARTITION_CODE].format_type == nn::hac::nca::FORMAT_PFS0)
|
||||
if (mPartitions[nn::hac::nca::PARTITION_CODE].format_type == nn::hac::nca::FormatType::PartitionFs)
|
||||
{
|
||||
if (*mPartitions[nn::hac::nca::PARTITION_CODE].reader != nullptr)
|
||||
{
|
||||
|
@ -503,14 +503,14 @@ void NcaProcess::displayHeader()
|
|||
std::cout << " Format Type: " << nn::hac::ContentArchiveUtil::getFormatTypeAsString(info.format_type) << std::endl;
|
||||
std::cout << " Hash Type: " << nn::hac::ContentArchiveUtil::getHashTypeAsString(info.hash_type) << std::endl;
|
||||
std::cout << " Enc. Type: " << nn::hac::ContentArchiveUtil::getEncryptionTypeAsString(info.enc_type) << std::endl;
|
||||
if (info.enc_type == nn::hac::nca::CRYPT_AESCTR)
|
||||
if (info.enc_type == nn::hac::nca::EncryptionType::AesCtr)
|
||||
{
|
||||
fnd::aes::sAesIvCtr ctr;
|
||||
fnd::aes::AesIncrementCounter(info.aes_ctr.iv, info.offset>>4, ctr.iv);
|
||||
std::cout << " AesCtr Counter:" << std::endl;
|
||||
std::cout << " " << fnd::SimpleTextOutput::arrayToString(ctr.iv, sizeof(fnd::aes::sAesIvCtr), true, ":") << std::endl;
|
||||
}
|
||||
if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_INTERGRITY)
|
||||
if (info.hash_type == nn::hac::nca::HashType::HierarchicalIntegrity)
|
||||
{
|
||||
fnd::LayeredIntegrityMetadata& hash_hdr = info.layered_intergrity_metadata;
|
||||
std::cout << " HierarchicalIntegrity Header:" << std::endl;
|
||||
|
@ -533,7 +533,7 @@ void NcaProcess::displayHeader()
|
|||
std::cout << " " << fnd::SimpleTextOutput::arrayToString(hash_hdr.getMasterHashList()[j].bytes+0x10, 0x10, true, ":") << std::endl;
|
||||
}
|
||||
}
|
||||
else if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_SHA256)
|
||||
else if (info.hash_type == nn::hac::nca::HashType::HierarchicalSha256)
|
||||
{
|
||||
fnd::LayeredIntegrityMetadata& hash_hdr = info.layered_intergrity_metadata;
|
||||
std::cout << " HierarchicalSha256 Header:" << std::endl;
|
||||
|
@ -572,13 +572,13 @@ void NcaProcess::processPartitions()
|
|||
continue;
|
||||
}
|
||||
|
||||
if (partition.format_type == nn::hac::nca::FORMAT_PFS0)
|
||||
if (partition.format_type == nn::hac::nca::FormatType::PartitionFs)
|
||||
{
|
||||
PfsProcess pfs;
|
||||
pfs.setInputFile(partition.reader);
|
||||
pfs.setCliOutputMode(mCliOutputMode);
|
||||
pfs.setListFs(mListFs);
|
||||
if (mHdr.getContentType() == nn::hac::nca::TYPE_PROGRAM)
|
||||
if (mHdr.getContentType() == nn::hac::nca::ContentType::Program)
|
||||
{
|
||||
pfs.setMountPointName(std::string(getContentTypeForMountStr(mHdr.getContentType())) + ":/" + nn::hac::ContentArchiveUtil::getProgramContentParititionIndexAsString((nn::hac::nca::ProgramContentPartitionIndex)index));
|
||||
}
|
||||
|
@ -591,13 +591,13 @@ void NcaProcess::processPartitions()
|
|||
pfs.setExtractPath(mPartitionPath[index].path);
|
||||
pfs.process();
|
||||
}
|
||||
else if (partition.format_type == nn::hac::nca::FORMAT_ROMFS)
|
||||
else if (partition.format_type == nn::hac::nca::FormatType::RomFs)
|
||||
{
|
||||
RomfsProcess romfs;
|
||||
romfs.setInputFile(partition.reader);
|
||||
romfs.setCliOutputMode(mCliOutputMode);
|
||||
romfs.setListFs(mListFs);
|
||||
if (mHdr.getContentType() == nn::hac::nca::TYPE_PROGRAM)
|
||||
if (mHdr.getContentType() == nn::hac::nca::ContentType::Program)
|
||||
{
|
||||
romfs.setMountPointName(std::string(getContentTypeForMountStr(mHdr.getContentType())) + ":/" + nn::hac::ContentArchiveUtil::getProgramContentParititionIndexAsString((nn::hac::nca::ProgramContentPartitionIndex)index));
|
||||
}
|
||||
|
@ -619,22 +619,22 @@ const char* NcaProcess::getContentTypeForMountStr(nn::hac::nca::ContentType cont
|
|||
|
||||
switch (cont_type)
|
||||
{
|
||||
case (nn::hac::nca::TYPE_PROGRAM):
|
||||
case (nn::hac::nca::ContentType::Program):
|
||||
str = "program";
|
||||
break;
|
||||
case (nn::hac::nca::TYPE_META):
|
||||
case (nn::hac::nca::ContentType::Meta):
|
||||
str = "meta";
|
||||
break;
|
||||
case (nn::hac::nca::TYPE_CONTROL):
|
||||
case (nn::hac::nca::ContentType::Control):
|
||||
str = "control";
|
||||
break;
|
||||
case (nn::hac::nca::TYPE_MANUAL):
|
||||
case (nn::hac::nca::ContentType::Manual):
|
||||
str = "manual";
|
||||
break;
|
||||
case (nn::hac::nca::TYPE_DATA):
|
||||
case (nn::hac::nca::ContentType::Data):
|
||||
str = "data";
|
||||
break;
|
||||
case (nn::hac::nca::TYPE_PUBLIC_DATA):
|
||||
case (nn::hac::nca::ContentType::PublicData):
|
||||
str = "publicdata";
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue