[nx] Rename and move location of NCA embedded FS structs and consts.

This commit is contained in:
jakcron 2018-04-21 17:23:55 +08:00
parent b81c742e18
commit 02514cf72b
3 changed files with 48 additions and 29 deletions

View file

@ -93,15 +93,6 @@ namespace nx
private: private:
const std::string kModuleName = "NCA_HEADER"; const std::string kModuleName = "NCA_HEADER";
//static const uint32_t kDefaultSdkAddonVersion = 721920;
enum ProgramPartitionId
{
PARTITION_CODE,
PARTITION_DATA,
PARTITION_LOGO,
};
// binary // binary
fnd::MemoryBlob mBinaryBlob; fnd::MemoryBlob mBinaryBlob;

View file

@ -0,0 +1,36 @@
#pragma once
#include <string>
#include <fnd/types.h>
#include <crypto/aes.h>
#include <crypto/sha.h>
#include <fnd/ISerialiseableBinary.h>
namespace nx
{
// Also known as HierarchicalIntegrity
namespace ivfc
{
const std::string kIvfcSig = "IVFC";
static const size_t kMaxIvfcLevel = 4;
static const uint32_t kIvfcId = 0x20000;
}
#pragma pack(push,1)
struct sIvfcHeader
{
char signature[4];
le_uint32_t id;
le_uint32_t master_hash_size;
le_uint32_t level_num;
struct sIvfcLevelHeader
{
uint64_t logical_offset;
uint64_t hash_data_size;
uint32_t block_size;
byte_t reserved[4];
} level_header[ivfc::kMaxIvfcLevel];
byte_t unk_0xA0[0x20];
byte_t master_hash[0x20];
};
#pragma pack(pop)
}

View file

@ -1,8 +1,10 @@
#pragma once
#include <string> #include <string>
#include <fnd/types.h> #include <fnd/types.h>
#include <crypto/aes.h> #include <crypto/aes.h>
#include <crypto/sha.h> #include <crypto/sha.h>
#include <fnd/ISerialiseableBinary.h> #include <fnd/ISerialiseableBinary.h>
#include <nx/ivfc.h>
namespace nx namespace nx
{ {
@ -16,6 +18,14 @@ namespace nx
static const size_t kHeaderSize = kSectorSize * kHeaderSectorNum; static const size_t kHeaderSize = kSectorSize * kHeaderSectorNum;
static const size_t kAesKeyNum = 16; static const size_t kAesKeyNum = 16;
static const size_t kRightsIdLen = 0x10; static const size_t kRightsIdLen = 0x10;
static const size_t kKeyAreaEncryptionKeyNum = 3;
enum ProgramPartitionId
{
PARTITION_CODE,
PARTITION_DATA,
PARTITION_LOGO,
};
enum DistributionType enum DistributionType
{ {
@ -59,7 +69,7 @@ namespace nx
HASH_AUTO, HASH_AUTO,
HASH_UNK1, HASH_UNK1,
HASH_HIERARCHICAL_SHA256, HASH_HIERARCHICAL_SHA256,
HASH_HIERARCHICAL_INTERGRITY HASH_HIERARCHICAL_INTERGRITY // IVFC
}; };
enum EncryptionType enum EncryptionType
@ -107,7 +117,7 @@ namespace nx
byte_t reserved[3]; byte_t reserved[3];
}; };
struct sPfsSuperBlock struct sHierarchicalSha256Header
{ {
byte_t master_hash[0x20]; byte_t master_hash[0x20];
le_uint32_t hash_block_size; le_uint32_t hash_block_size;
@ -119,23 +129,5 @@ namespace nx
} hash_data, hash_target; } hash_data, hash_target;
}; };
static const size_t kMaxIvfcLevel = 4;
struct sIvfcHeader
{
le_uint32_t magic;
le_uint32_t id;
le_uint32_t master_hash_size;
le_uint32_t level_num;
struct sIvfcLevelHeader
{
uint64_t logical_offset;
uint64_t hash_data_size;
uint32_t block_size;
byte_t reserved[4];
} level_header[kMaxIvfcLevel];
byte_t unk_0xA0[0x20];
byte_t master_hash[0x20];
};
#pragma pack(pop) #pragma pack(pop)
} }