<?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=Chainswordcs</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=Chainswordcs"/>
	<link rel="alternate" type="text/html" href="https://switchbrew.org/wiki/Special:Contributions/Chainswordcs"/>
	<updated>2026-05-17T04:06:58Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=NAX0&amp;diff=14710</id>
		<title>NAX0</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=NAX0&amp;diff=14710"/>
		<updated>2026-05-16T00:48:44Z</updated>

		<summary type="html">&lt;p&gt;Chainswordcs: link to SystemSaveData instead of Flash_Filesystem#SystemSaveData&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the format on the files stored on [[SD_Filesystem|SD]] (Nintendo Aes Xts -- official name is AesXtsFilesystem/AesXtsFile).&lt;br /&gt;
&lt;br /&gt;
The data between this header and offset 0x4000 is unused/uninitialized it appears. The actual content which is encrypted, starts at offset 0x4000 with the size from the header.&lt;br /&gt;
&lt;br /&gt;
When a NAX0 file is recreated, the header and raw content in NAX0 are completely different except for the magicnum and size-field. This is the case when a title is redownloaded/reinstalled, and when &amp;quot;save/&amp;quot; files are recreated after manual deletion.&lt;br /&gt;
&lt;br /&gt;
[[Error_codes|Error]] 0x250E02 is returned by NCM when attempting to access a NcaId where the NAX0 header HMAC validation fails.&lt;br /&gt;
&lt;br /&gt;
[S2] This is now NAX1, with +0x10 size 0x10-bytes being all-zero.&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;
| 0x20&lt;br /&gt;
| Header HMAC&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x8&lt;br /&gt;
| Magicnum &amp;quot;NAX0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 0x28&lt;br /&gt;
| 0x20&lt;br /&gt;
| Encrypted AES-XTS Keys&lt;br /&gt;
|-&lt;br /&gt;
| 0x48&lt;br /&gt;
| 0x8&lt;br /&gt;
| Size of the file relative to offset 0x4000.&lt;br /&gt;
|-&lt;br /&gt;
| 0x50&lt;br /&gt;
| 0x30&lt;br /&gt;
| Padding&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Encryption =&lt;br /&gt;
&lt;br /&gt;
The actual content uses AES-XTS with the same non-standard tweak (endianness swap) as usual, and sector size 0x4000.&lt;br /&gt;
&lt;br /&gt;
Key derivation is as follows:&lt;br /&gt;
&lt;br /&gt;
First, FS retrieves the 16-byte console-unique seed that NS registered (data originates from the ns_appman:/private [[SystemSaveData|system savegame]]). Next, FS calculates encryptedSeedKeys = &amp;lt;0x20 hardcoded keydata depending on if this NAX0 is a save or an NCA&amp;gt; XORed with the system seed, calculates kek = [[SPL_services#GenerateAesKek|GenerateAesKek]](&amp;lt;hardcoded keydata&amp;gt;, 0, 0), and then calculates decryptedSeedKeys by doing decryptedSeedKeys[i] = [[SPL_services#GenerateAesKey|GenerateAesKey]](kek, encryptedSeedKeys[i]); for both keys.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once the decryptedSeedKeys are calculated, FS calculates naxSpecificKeys = hmac-sha256(key=decryptedSeedKeys[0], data=&amp;lt;NAX0 path, relative to /Nintendo/Contents&amp;gt;); (example path: &#039;/registered/000000FF/cafebabecafebabecafebabecafebabe.nca&#039;). Then, FS does the following decryptions in place: aes128_ecb_decrypt(key=naxSpecificKeys[0], data=Header + 0x28); aes128_ecb_decrypt(key=naxSpecificKeys[1], data=Header + 0x38); Finally, hmac-sha256(key=Header[0x20:0x60], data=decryptedSeedKeys[1]) is calculated, and compared using a constant-time memcmp to the hmac stored at Header + 0x0. If it matches, decryption proceeds using the two decrypted keys at Header + 0x28 as an AES-XTS keypair.&lt;/div&gt;</summary>
		<author><name>Chainswordcs</name></author>
	</entry>
</feed>