2018-05-20 01:18:38 +00:00
|
|
|
#pragma once
|
2018-05-20 13:57:38 +00:00
|
|
|
#include <nx/hierarchicalintegrity.h>
|
2018-06-24 08:18:54 +00:00
|
|
|
#include <fnd/ISerialisable.h>
|
2018-05-20 01:18:38 +00:00
|
|
|
#include <fnd/List.h>
|
2018-06-24 15:01:16 +00:00
|
|
|
#include <crypto/sha.h>
|
2018-05-20 01:18:38 +00:00
|
|
|
|
|
|
|
namespace nx
|
|
|
|
{
|
|
|
|
class HierarchicalIntegrityHeader :
|
2018-06-24 08:18:54 +00:00
|
|
|
public fnd::ISerialisable
|
2018-05-20 01:18:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct sLayer
|
|
|
|
{
|
|
|
|
size_t offset;
|
|
|
|
size_t size;
|
2018-05-20 13:57:38 +00:00
|
|
|
size_t block_size;
|
2018-05-20 01:18:38 +00:00
|
|
|
|
|
|
|
void operator=(const sLayer& other)
|
|
|
|
{
|
|
|
|
offset = other.offset;
|
|
|
|
size = other.size;
|
2018-05-20 13:57:38 +00:00
|
|
|
block_size = other.block_size;
|
2018-05-20 01:18:38 +00:00
|
|
|
}
|
|
|
|
|
2018-05-20 13:57:38 +00:00
|
|
|
bool operator==(const sLayer& other) const
|
2018-05-20 01:18:38 +00:00
|
|
|
{
|
2018-05-20 13:57:38 +00:00
|
|
|
return (offset == other.offset && size == other.size && block_size == other.block_size);
|
2018-05-20 01:18:38 +00:00
|
|
|
}
|
|
|
|
|
2018-05-20 13:57:38 +00:00
|
|
|
bool operator!=(const sLayer& other) const
|
2018-05-20 01:18:38 +00:00
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
HierarchicalIntegrityHeader();
|
|
|
|
HierarchicalIntegrityHeader(const HierarchicalIntegrityHeader& other);
|
|
|
|
|
2018-06-24 08:18:54 +00:00
|
|
|
void operator=(const HierarchicalIntegrityHeader& other);
|
2018-05-20 01:18:38 +00:00
|
|
|
bool operator==(const HierarchicalIntegrityHeader& other) const;
|
|
|
|
bool operator!=(const HierarchicalIntegrityHeader& other) const;
|
|
|
|
|
|
|
|
// export/import binary
|
2018-06-24 08:18:54 +00:00
|
|
|
void toBytes();
|
|
|
|
void fromBytes(const byte_t* bytes, size_t len);
|
|
|
|
const fnd::Vec<byte_t>& getBytes() const;
|
2018-05-20 01:18:38 +00:00
|
|
|
|
|
|
|
// variables
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
const fnd::List<sLayer>& getLayerInfo() const;
|
|
|
|
void setLayerInfo(const fnd::List<sLayer>& layer_info);
|
|
|
|
|
|
|
|
const fnd::List<crypto::sha::sSha256Hash>& getMasterHashList() const;
|
|
|
|
void setMasterHashList(const fnd::List<crypto::sha::sSha256Hash>& master_hash_list);
|
|
|
|
private:
|
|
|
|
const std::string kModuleName = "HIERARCHICAL_INTEGRITY_HEADER";
|
|
|
|
|
|
|
|
// binary
|
2018-06-24 08:18:54 +00:00
|
|
|
fnd::Vec<byte_t> mRawBinary;
|
2018-05-20 01:18:38 +00:00
|
|
|
|
|
|
|
// data
|
|
|
|
fnd::List<sLayer> mLayerInfo;
|
|
|
|
fnd::List<crypto::sha::sSha256Hash> mMasterHashList;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|