<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://switchbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rikikoo</id>
	<title>Nintendo Switch Brew - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://switchbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rikikoo"/>
	<link rel="alternate" type="text/html" href="https://switchbrew.org/wiki/Special:Contributions/Rikikoo"/>
	<updated>2026-05-08T03:31:05Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=XCI&amp;diff=4961</id>
		<title>XCI</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=XCI&amp;diff=4961"/>
		<updated>2018-09-01T06:58:10Z</updated>

		<summary type="html">&lt;p&gt;Rikikoo: Fix mixed up numbers&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Known internally as &amp;quot;XCI&amp;quot; (NX Card Image), this is the format used for storing the contents of a Nintendo Switch Gamecard. &lt;br /&gt;
&lt;br /&gt;
= Gamecard Header =&lt;br /&gt;
This header is 0x200 bytes and is located at offset 0 in the Gamecard.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x100&lt;br /&gt;
| RSA-2048 PKCS #1 signature over the header (data from 0x100 to 0x200)&lt;br /&gt;
|-&lt;br /&gt;
| 0x100&lt;br /&gt;
| 0x4&lt;br /&gt;
| Magicnum &amp;quot;HEAD&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 0x104&lt;br /&gt;
| 0x4&lt;br /&gt;
| Secure Area Start Address (in Media Units which are 0x200 bytes)&lt;br /&gt;
|-&lt;br /&gt;
| 0x108&lt;br /&gt;
| 0x4&lt;br /&gt;
| Backup Area Start Address (always 0xFFFFFFFF)&lt;br /&gt;
|-&lt;br /&gt;
| 0x10C&lt;br /&gt;
| 0x1&lt;br /&gt;
| Title KEK Index (high nibble) and KEK Index (low nibble)&lt;br /&gt;
|-&lt;br /&gt;
| 0x10D&lt;br /&gt;
| 0x1&lt;br /&gt;
| Gamecard Size (0xFA = 1GB, 0xF8 = 2GB, 0xF0 = 4GB, 0xE0 = 8GB, 0xE1 = 16GB, 0xE2 = 32GB)&lt;br /&gt;
|-&lt;br /&gt;
| 0x10E&lt;br /&gt;
| 0x1&lt;br /&gt;
| Gamecard Header Version&lt;br /&gt;
|-&lt;br /&gt;
| 0x10F&lt;br /&gt;
| 0x1&lt;br /&gt;
| Gamecard Flags (bit0 = AutoBoot, bit1 = HistoryErase)&lt;br /&gt;
|-&lt;br /&gt;
| 0x110&lt;br /&gt;
| 0x8&lt;br /&gt;
| Package Id (used for challenge–response authentication)&lt;br /&gt;
|-&lt;br /&gt;
| 0x118&lt;br /&gt;
| 0x8&lt;br /&gt;
| Valid Data End Address (in Media Units which are 0x200 bytes)&lt;br /&gt;
|-&lt;br /&gt;
| 0x120&lt;br /&gt;
| 0x10&lt;br /&gt;
| Gamecard Info IV (reversed)&lt;br /&gt;
|-&lt;br /&gt;
| 0x130&lt;br /&gt;
| 0x8&lt;br /&gt;
| HFS0 partition offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x138&lt;br /&gt;
| 0x8&lt;br /&gt;
| HFS0 header size&lt;br /&gt;
|-&lt;br /&gt;
| 0x140&lt;br /&gt;
| 0x20&lt;br /&gt;
| SHA-256 hash of the [[#HFS0 Header|HFS0 Header]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x160&lt;br /&gt;
| 0x20&lt;br /&gt;
| SHA-256 hash of the [[#Initial Data|Initial Data]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x180&lt;br /&gt;
| 0x4&lt;br /&gt;
| Secure Mode Flag (always 1, which means Secure Mode is available)&lt;br /&gt;
|-&lt;br /&gt;
| 0x184&lt;br /&gt;
| 0x4&lt;br /&gt;
| Title Key Flag (always 2)&lt;br /&gt;
|-&lt;br /&gt;
| 0x188&lt;br /&gt;
| 0x4&lt;br /&gt;
| Key Flag (always 0)&lt;br /&gt;
|-&lt;br /&gt;
| 0x18C&lt;br /&gt;
| 0x4&lt;br /&gt;
| Normal Area End Address (in Media Units which are 0x200 bytes)&lt;br /&gt;
|-&lt;br /&gt;
| 0x190&lt;br /&gt;
| 0x70&lt;br /&gt;
| [[#Gamecard Info|Gamecard Info]] (AES-128-CBC encrypted)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Gamecard Info ==&lt;br /&gt;
When decrypted, this 0x70 byte region is as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Firmware Version (0x01 for old Gamecards, 0x02 for new Gamecards with the &amp;quot;logo&amp;quot; partition)&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Access Control Flags (0x00A10011 for 25MHz access or 0x00A10010 for 50MHz access)&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Read Wait Time (always 0x1388)&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x4&lt;br /&gt;
| Read Wait Time2 (always 0)&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x4&lt;br /&gt;
| Write Wait Time (always 0)&lt;br /&gt;
|-&lt;br /&gt;
| 0x18&lt;br /&gt;
| 0x4&lt;br /&gt;
| Write Wait Time2 (always 0)&lt;br /&gt;
|-&lt;br /&gt;
| 0x1C&lt;br /&gt;
| 0x4&lt;br /&gt;
| Firmware Mode&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x4&lt;br /&gt;
| CUP Version&lt;br /&gt;
|-&lt;br /&gt;
| 0x24&lt;br /&gt;
| 0x4&lt;br /&gt;
| Empty&lt;br /&gt;
|-&lt;br /&gt;
| 0x28&lt;br /&gt;
| 0x8&lt;br /&gt;
| Update Partition Hash&lt;br /&gt;
|-&lt;br /&gt;
| 0x30&lt;br /&gt;
| 0x8&lt;br /&gt;
| CUP Id (always 0x0100000000000816, which is the title-listing data archive&#039;s title ID)&lt;br /&gt;
|-&lt;br /&gt;
| 0x38&lt;br /&gt;
| 0x38&lt;br /&gt;
| Empty&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Gamecard Certificate =&lt;br /&gt;
This is the Gamecard&#039;s unique certificate and is located at offset 0x7000.&lt;br /&gt;
&lt;br /&gt;
[[Filesystem_services|FS]] IDeviceOperator cmd 206 &amp;quot;GetGameCardDeviceCertificate&amp;quot; retrieves this data.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x100&lt;br /&gt;
| RSA-2048 PKCS #1 signature over the data from 0x100 to 0x200&lt;br /&gt;
|-&lt;br /&gt;
| 0x100&lt;br /&gt;
| 0x4&lt;br /&gt;
| Magicnum &amp;quot;CERT&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 0x110&lt;br /&gt;
| 0x10&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x120&lt;br /&gt;
| 0xA&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x12A&lt;br /&gt;
| 0xD6&lt;br /&gt;
| Encrypted data. Some kind of key?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The data between the Gamecard Certificate and the start of the HFS0 region is all 0xFF.&lt;br /&gt;
&lt;br /&gt;
= Initial Data =&lt;br /&gt;
This data is used for challenge–response authentication when changing to the Gamecard&#039;s secure mode.&lt;br /&gt;
&lt;br /&gt;
[[Filesystem_services|FS]] calculates a SHA-256 hash over the whole 0x200 bytes and compares it with the hash stored at offset 0x160 in the [[#Gamecard Header|Gamecard Header]].&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Package Id from [[#Gamecard Header|Gamecard Header]] at offset 0x110&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Empty&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x10&lt;br /&gt;
| Challenge–response authentication data&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x10&lt;br /&gt;
| Challenge–response authentication MAC&lt;br /&gt;
|-&lt;br /&gt;
| 0x30&lt;br /&gt;
| 0xC&lt;br /&gt;
| Challenge–response authentication Nonce&lt;br /&gt;
|-&lt;br /&gt;
| 0x3C&lt;br /&gt;
| 0x1C4&lt;br /&gt;
| Reserved (must be empty)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= HFS0 =&lt;br /&gt;
This is the Gamecard file system which starts with magicnum &amp;quot;HFS0&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Header ==&lt;br /&gt;
The &amp;quot;SHA-256 File System&amp;quot; or &amp;quot;HFS0&amp;quot; starts at offset 0xF000 in the Gamecard. The first 0x200 bytes act as a global header and represent the root partition which points to the other partitions (&amp;quot;normal&amp;quot;, &amp;quot;logo&amp;quot;, &amp;quot;update&amp;quot; and &amp;quot;secure).&lt;br /&gt;
&lt;br /&gt;
A hash for this header is stored at offset 0x140 in the [[#Gamecard Header|Gamecard Header]].&lt;br /&gt;
&lt;br /&gt;
== File System ==&lt;br /&gt;
The actual file system is as follows (also valid for the root partition):&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| Magicnum &amp;quot;HFS0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Number of files&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Size of the string table&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Zero/Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| X&lt;br /&gt;
| File Entry Table&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 + X&lt;br /&gt;
| Y&lt;br /&gt;
| String Table&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 + X + Y&lt;br /&gt;
| Z&lt;br /&gt;
| Raw File Data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Where File Entry Table consists of Number of Files FileEntries:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Offset of file in Data&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Size of file in Data&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x4&lt;br /&gt;
| Offset of filename in String Table&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x4&lt;br /&gt;
| Size of Hashed region of file (for HFS0s, this is the size of the pre-filedata portion, for NCAs this is usually 0x200)&lt;br /&gt;
|-&lt;br /&gt;
| 0x18&lt;br /&gt;
| 8&lt;br /&gt;
| Zero/Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x20&lt;br /&gt;
| SHA-256 hash of the first (size of hashed region) bytes of filedata&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The string table is 00-padded to align the start of raw filedata with a sector/media unit boundary (usually?).&lt;br /&gt;
&lt;br /&gt;
= Cartridge Layout =&lt;br /&gt;
Observed gamecards contain three partitions: &amp;quot;update&amp;quot;, &amp;quot;normal&amp;quot;, and &amp;quot;secure&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The update partition (Gamecard partition 0 for fsp-srv cmd 31) contains .cnmt.nca + .nca files for the entire system update required to play the game. Launch day carts contain a full copy of 1.0 ncas, newer carts contain newer sysupdate NCAs etc.&lt;br /&gt;
&lt;br /&gt;
The normal partition contains the .cnmt.nca and the game icondata nca. This is presumably for future compatibility so that if a future update changes the cryptographic protocol for the secure partition, Game icon data can still be shown in the home menu on old firmwares.&lt;br /&gt;
&lt;br /&gt;
The secure partition contains an identical copy of the .cnmt.nca and game icondata nca, as well as all other ncas required for the game.&lt;br /&gt;
&lt;br /&gt;
The entire rest of the Gamecard after the secure partition ends is all FF padding.&lt;br /&gt;
&lt;br /&gt;
[4.0.0+] The &amp;quot;normal&amp;quot; partition is now empty and a new partition &amp;quot;logo&amp;quot; was added.&lt;/div&gt;</summary>
		<author><name>Rikikoo</name></author>
	</entry>
</feed>