From c1f343d052a54feb522457ac4a11e7aa112cad95 Mon Sep 17 00:00:00 2001 From: jakcron Date: Mon, 21 May 2018 23:03:28 +0800 Subject: [PATCH] [nstool] Add flag to signal hash calc aligning. --- programs/nstool/source/HashTreeMeta.cpp | 25 +++++++++++++++++++++---- programs/nstool/source/HashTreeMeta.h | 6 +++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/programs/nstool/source/HashTreeMeta.cpp b/programs/nstool/source/HashTreeMeta.cpp index 049bd3c..d1e9abd 100644 --- a/programs/nstool/source/HashTreeMeta.cpp +++ b/programs/nstool/source/HashTreeMeta.cpp @@ -3,7 +3,8 @@ HashTreeMeta::HashTreeMeta() : mLayerInfo(), mDataLayer(), - mMasterHashList() + mMasterHashList(), + mDoAlignHashToBlock(false) { } @@ -11,7 +12,8 @@ HashTreeMeta::HashTreeMeta() : HashTreeMeta::HashTreeMeta(const nx::HierarchicalIntegrityHeader& hdr) : mLayerInfo(), mDataLayer(), - mMasterHashList() + mMasterHashList(), + mDoAlignHashToBlock(false) { importHierarchicalIntergityHeader(hdr); } @@ -19,7 +21,8 @@ HashTreeMeta::HashTreeMeta(const nx::HierarchicalIntegrityHeader& hdr) : HashTreeMeta::HashTreeMeta(const nx::HierarchicalSha256Header& hdr) : mLayerInfo(), mDataLayer(), - mMasterHashList() + mMasterHashList(), + mDoAlignHashToBlock(false) { importHierarchicalSha256Header(hdr); } @@ -41,6 +44,7 @@ void HashTreeMeta::operator=(const HashTreeMeta& other) void HashTreeMeta::importHierarchicalIntergityHeader(const nx::HierarchicalIntegrityHeader& hdr) { + mDoAlignHashToBlock = true; for (size_t i = 0; i < hdr.getLayerInfo().getSize(); i++) { sLayer layer; @@ -61,6 +65,7 @@ void HashTreeMeta::importHierarchicalIntergityHeader(const nx::HierarchicalInteg void HashTreeMeta::importHierarchicalSha256Header(const nx::HierarchicalSha256Header& hdr) { + mDoAlignHashToBlock = false; for (size_t i = 0; i < hdr.getLayerInfo().getSize(); i++) { sLayer layer; @@ -109,11 +114,22 @@ void HashTreeMeta::setMasterHashList(const fnd::List& mMasterHashList = master_hash_list; } +bool HashTreeMeta::getAlignHashToBlock() const +{ + return mDoAlignHashToBlock; +} + +void HashTreeMeta::setAlignHashToBlock(bool doAlign) +{ + mDoAlignHashToBlock = doAlign; +} + bool HashTreeMeta::isEqual(const HashTreeMeta& other) const { return (mLayerInfo == other.mLayerInfo) \ && (mDataLayer == other.mDataLayer) \ - && (mMasterHashList == other.mMasterHashList); + && (mMasterHashList == other.mMasterHashList) \ + && (mDoAlignHashToBlock == other.mDoAlignHashToBlock); } void HashTreeMeta::copyFrom(const HashTreeMeta& other) @@ -121,4 +137,5 @@ void HashTreeMeta::copyFrom(const HashTreeMeta& other) mLayerInfo = other.mLayerInfo; mDataLayer = other.mDataLayer; mMasterHashList = other.mMasterHashList; + mDoAlignHashToBlock = other.mDoAlignHashToBlock; } diff --git a/programs/nstool/source/HashTreeMeta.h b/programs/nstool/source/HashTreeMeta.h index 12d9e54..474be89 100644 --- a/programs/nstool/source/HashTreeMeta.h +++ b/programs/nstool/source/HashTreeMeta.h @@ -48,12 +48,16 @@ public: const fnd::List& getMasterHashList() const; void setMasterHashList(const fnd::List& master_hash_list); + + bool getAlignHashToBlock() const; + void setAlignHashToBlock(bool doAlign); private: // data fnd::List mLayerInfo; sLayer mDataLayer; - fnd::List mMasterHashList; + fnd::List mMasterHashList; + bool mDoAlignHashToBlock; bool isEqual(const HashTreeMeta& other) const; void copyFrom(const HashTreeMeta& other);