mirror of
https://github.com/jakcron/nstool
synced 2024-11-15 02:06:40 +00:00
[nstool] Fix XCI partition validation.
This commit is contained in:
parent
bd2e1dd927
commit
b42c551a20
2 changed files with 12 additions and 9 deletions
|
@ -146,11 +146,11 @@ void PfsProcess::validateHfs()
|
|||
{
|
||||
mCache.alloc(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 (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()
|
||||
{
|
||||
if (mVerify)
|
||||
{
|
||||
if (validateRegionOfFile(mHdr.getPartitionFsAddress(), mHdr.getPartitionFsSize(), mHdr.getPartitionFsHash().bytes) == false)
|
||||
if (mVerify && validateRegionOfFile(mHdr.getPartitionFsAddress(), mHdr.getPartitionFsSize(), mHdr.getPartitionFsHash().bytes) == false)
|
||||
{
|
||||
printf("[WARNING] XCI Root HFS0: FAIL (bad hash)\n");
|
||||
}
|
||||
}
|
||||
mRootPfs.setInputFile(new OffsetAdjustedIFile(mFile, SHARED_IFILE, mHdr.getPartitionFsAddress(), mHdr.getPartitionFsSize()), OWN_IFILE);
|
||||
mRootPfs.setListFs(mListFs);
|
||||
mRootPfs.setVerifyMode(mVerify);
|
||||
mRootPfs.setVerifyMode(false);
|
||||
mRootPfs.setCliOutputMode(mCliOutputType);
|
||||
mRootPfs.setMountPointName(kXciMountPointName);
|
||||
mRootPfs.process();
|
||||
|
@ -245,6 +242,12 @@ void XciProcess::processPartitionPfs()
|
|||
const fnd::List<nx::PfsHeader::sFile>& rootPartitions = mRootPfs.getPfsHeader().getFileList();
|
||||
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;
|
||||
tmp.setInputFile(new OffsetAdjustedIFile(mFile, SHARED_IFILE, mHdr.getPartitionFsAddress() + rootPartitions[i].offset, rootPartitions[i].size), OWN_IFILE);
|
||||
tmp.setListFs(mListFs);
|
||||
|
|
Loading…
Reference in a new issue