mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-22 18:55:29 +00:00
[nstool] Fix XCI partition validation.
This commit is contained in:
parent
bd2e1dd927
commit
b42c551a20
|
@ -146,11 +146,11 @@ void PfsProcess::validateHfs()
|
||||||
{
|
{
|
||||||
mCache.alloc(file[i].hash_protected_size);
|
mCache.alloc(file[i].hash_protected_size);
|
||||||
mFile->read(mCache.getBytes(), file[i].offset, file[i].hash_protected_size);
|
mFile->read(mCache.getBytes(), file[i].offset, file[i].hash_protected_size);
|
||||||
crypto::sha::Sha256(mCache.getBytes(), mCache.getSize(), hash.bytes);
|
crypto::sha::Sha256(mCache.getBytes(), file[i].hash_protected_size, hash.bytes);
|
||||||
if (hash != file[i].hash)
|
if (hash != file[i].hash)
|
||||||
{
|
{
|
||||||
if (mCliOutputType >= OUTPUT_MINIMAL)
|
if (mCliOutputType >= OUTPUT_MINIMAL)
|
||||||
printf("[WARNING] HFS0 %s%s%s: FAIL (bad hash)\n", !mMountName.empty()? mMountName.c_str() : "", !mMountName.empty()? "/" : "", file[i].name.c_str());
|
printf("[WARNING] HFS0 %s%s%s: FAIL (bad hash)\n", !mMountName.empty()? mMountName.c_str() : "", (!mMountName.empty() && mMountName.at(mMountName.length()-1) != '/' )? "/" : "", file[i].name.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,16 +225,13 @@ void XciProcess::validateXciSignature()
|
||||||
|
|
||||||
void XciProcess::processRootPfs()
|
void XciProcess::processRootPfs()
|
||||||
{
|
{
|
||||||
if (mVerify)
|
if (mVerify && validateRegionOfFile(mHdr.getPartitionFsAddress(), mHdr.getPartitionFsSize(), mHdr.getPartitionFsHash().bytes) == false)
|
||||||
{
|
{
|
||||||
if (validateRegionOfFile(mHdr.getPartitionFsAddress(), mHdr.getPartitionFsSize(), mHdr.getPartitionFsHash().bytes) == false)
|
printf("[WARNING] XCI Root HFS0: FAIL (bad hash)\n");
|
||||||
{
|
|
||||||
printf("[WARNING] XCI Root HFS0: FAIL (bad hash)\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mRootPfs.setInputFile(new OffsetAdjustedIFile(mFile, SHARED_IFILE, mHdr.getPartitionFsAddress(), mHdr.getPartitionFsSize()), OWN_IFILE);
|
mRootPfs.setInputFile(new OffsetAdjustedIFile(mFile, SHARED_IFILE, mHdr.getPartitionFsAddress(), mHdr.getPartitionFsSize()), OWN_IFILE);
|
||||||
mRootPfs.setListFs(mListFs);
|
mRootPfs.setListFs(mListFs);
|
||||||
mRootPfs.setVerifyMode(mVerify);
|
mRootPfs.setVerifyMode(false);
|
||||||
mRootPfs.setCliOutputMode(mCliOutputType);
|
mRootPfs.setCliOutputMode(mCliOutputType);
|
||||||
mRootPfs.setMountPointName(kXciMountPointName);
|
mRootPfs.setMountPointName(kXciMountPointName);
|
||||||
mRootPfs.process();
|
mRootPfs.process();
|
||||||
|
@ -244,7 +241,13 @@ void XciProcess::processPartitionPfs()
|
||||||
{
|
{
|
||||||
const fnd::List<nx::PfsHeader::sFile>& rootPartitions = mRootPfs.getPfsHeader().getFileList();
|
const fnd::List<nx::PfsHeader::sFile>& rootPartitions = mRootPfs.getPfsHeader().getFileList();
|
||||||
for (size_t i = 0; i < rootPartitions.getSize(); i++)
|
for (size_t i = 0; i < rootPartitions.getSize(); i++)
|
||||||
{
|
{
|
||||||
|
// this must be validated here because only the size of the root partiton header is known at verification time
|
||||||
|
if (mVerify && validateRegionOfFile(mHdr.getPartitionFsAddress() + rootPartitions[i].offset, rootPartitions[i].hash_protected_size, rootPartitions[i].hash.bytes) == false)
|
||||||
|
{
|
||||||
|
printf("[WARNING] XCI %s Partition HFS0: FAIL (bad hash)\n", rootPartitions[i].name.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
PfsProcess tmp;
|
PfsProcess tmp;
|
||||||
tmp.setInputFile(new OffsetAdjustedIFile(mFile, SHARED_IFILE, mHdr.getPartitionFsAddress() + rootPartitions[i].offset, rootPartitions[i].size), OWN_IFILE);
|
tmp.setInputFile(new OffsetAdjustedIFile(mFile, SHARED_IFILE, mHdr.getPartitionFsAddress() + rootPartitions[i].offset, rootPartitions[i].size), OWN_IFILE);
|
||||||
tmp.setListFs(mListFs);
|
tmp.setListFs(mListFs);
|
||||||
|
|
Loading…
Reference in a new issue