[nx] Update XciHeader

This commit is contained in:
jakcron 2018-03-31 08:07:53 +08:00
parent 7167477874
commit 427cdbb059

View file

@ -15,6 +15,18 @@ namespace nx
private: private:
#pragma pack (push, 1) #pragma pack (push, 1)
enum RomSize
{
ROM_SIZE_1GB = 0xFA,
ROM_SIZE_2GB = 0xF8,
ROM_SIZE_4GB = 0xF0,
ROM_SIZE_8GB = 0xE0,
ROM_SIZE_16GB = 0xE1,
ROM_SIZE_32GB = 0xE2
};
enum ContentMetaType enum ContentMetaType
{ {
SYSTEM_PROGRAM = 1, SYSTEM_PROGRAM = 1,
@ -61,30 +73,63 @@ namespace nx
byte_t reserved; byte_t reserved;
}; };
/*
public const int InitialDataSize = 512;
public const int InitialDataASize = 16;
public const int InitialDataMacSize = 16;
public const int InitialDataNonceSize = 12;
*/
struct sInitialData
{
byte_t key_source[16]; // { package_id[8], zeros[8]}
byte_t title_key_enc[16];
byte_t ccm_mac[16];
byte_t ccm_nonce[12];
};
/*
decrypt key_source
*/
struct sXciHeader struct sXciHeader
{ {
byte_t signature[4]; char signature[4]; // 0x00 // "HEAD"
uint32_t rom_area_start_page; le_uint32_t rom_area_start_page; // 0x04
uint32_t backup_area_start_page; le_uint32_t backup_area_start_page; // 0x08
byte_t key_flag; // bit0-3 = KekIndex, bit4-7 = TitleKeyDecIndex byte_t key_flag; // 0x0C // bit0-3 = KekIndex, bit4-7 = TitleKeyDecIndex
byte_t rom_size; // this is an enum byte_t rom_size; // 0x0D // this is an enum
byte_t flags; byte_t card_header_version; // 0x0E // CardHeaderVersion
byte_t package_id[8]; // stylised as 0x{0:x2}{1:x2}{2:x2}{3:x2}_{4:x2}{5:x2}{6:x2}{7:x2} byte_t flags; // 0x0F
uint32_t valid_data_end_page; byte_t package_id[8]; // 0x10 // stylised as 0x{0:x2}{1:x2}{2:x2}{3:x2}_{4:x2}{5:x2}{6:x2}{7:x2}
byte_t reserved_0[100]; le_uint32_t valid_data_end_page; // 0x18
uint32_t sel_sec; byte_t reserved_01[4]; // 0x1C
uint32_t sel_t1_key; byte_t encryption_iv[16]; // 0x20
uint32_t sel_key; le_uint64_t partition_fs_header_address; // 0x30
uint32_t lim_area; le_uint64_t partition_fs_header_size; // 0x38
uint32_t fw_version[2]; // [0]=minor, [1]=major byte_t partition_fs_header_hash[0x20]; // 0x40
uint32_t acc_ctrl_1; byte_t initial_data_hash[0x20]; // 0x60
byte_t reserved_1[0x10]; le_uint32_t sel_sec; // 0x80
uint32_t fw_mode; le_uint32_t sel_t1_key; // 0x84 // SelT1Key
uint32_t cup_version; le_uint32_t sel_key; // 0x88 // SelKey
byte_t reserved_2[0x4]; le_uint32_t lim_area; // 0x8C
byte_t upp_hash[8]; // stylised as 0x{0:x2}{1:x2}{2:x2}{3:x2}_{4:x2}{5:x2}{6:x2}{7:x2} // START ENCRYPTION
uint64_t cup_id; // cup programID? le_uint32_t fw_version[2]; // 0x90 // [0]=minor, [1]=major
le_uint32_t acc_ctrl_1; // 0x98
le_uint32_t wait_1_time_read; // 0x9C // Wait1TimeRead
le_uint32_t wait_2_time_read; // 0xA0 // Wait2TimeRead
le_uint32_t wait_1_time_write; // 0xA4 // Wait1TimeWrite
le_uint32_t wait_2_time_write; // 0xA8 // Wait2TimeWrite
le_uint32_t fw_mode; // 0xAC
le_uint32_t cup_version; // 0xB0
byte_t reserved_03[0x4]; // 0xB4
byte_t upp_hash[8]; // 0xB8 // stylised as 0x{0:x2}{1:x2}{2:x2}{3:x2}_{4:x2}{5:x2}{6:x2}{7:x2}
le_uint64_t cup_id; // 0xC0 // cup programID?
byte_t reserved_04[0x38];
// END ENCRYPTION
}; };
#pragma pack (pop) #pragma pack (pop)
}; };