NCA - Nintendo Switch Brew (2024)

NCA means «Nintendo Content Archive».

The entire raw NCAs are encrypted.

The only known area which is not encrypted in the raw NCA is the logo section, when the NCA includes that section. Everything else documented on this page is for the plaintext version of that data.

Contents

  • 1 Encryption
  • 2 Header
    • 2.1 FsEntry
  • 3 FsHeader
    • 3.1 HashData
      • 3.1.1 HierarchicalSha256Data
        • 3.1.1.1 Region
      • 3.1.2 IntegrityMetaInfo
        • 3.1.2.1 InfoLevelHash
          • 3.1.2.1.1 HierarchicalIntegrityVerificationLevelInformation
    • 3.2 PatchInfo
      • 3.2.1 RomFs Patching
    • 3.3 SparseInfo
    • 3.4 CompressionInfo
    • 3.5 BucketTreeHeader
    • 3.6 MetaDataHashDataInfo
  • 4 Logo Section
  • 5 ExeFS Section
  • 6 Game Updates
  • 7 PFS0
    • 7.1 PartitionEntry

The first 0xC00 bytes are encrypted with AES-XTS with sector size 0x200 with a non-standard "tweak" (endianness is reversed, see here), this encrypted data is an 0x400 NCA header + an 0x200 header for each section in the section table.

For pre-1.0.0 "NCA2" NCAs, the first 0x400 byte are encrypted the same way as in NCA3. However, each section header is individually encrypted as though it were sector 0, instead of the appropriate sector as in NCA3.

OffsetSizeDescription
0x00x100RSA-2048 signature over the header (data from 0x200 to 0x400) using a fixed key
0x1000x100RSA-2048 signature over the header (data from 0x200 to 0x400) using a key from NPDM (or zeroes if not a program)
0x2000x4Magic "NCA3" ("NCA2", "NCA1" or "NCA0" for pre-1.0.0 NCAs)
0x2040x1DistributionType (0x00 = Download, 0x01 = GameCard)
0x2050x1ContentType (0x00 = Program, 0x01 = Meta, 0x02 = Control, 0x03 = Manual, 0x04 = Data, 0x05 = PublicData)
0x2060x1KeyGenerationOld (0x00 = 1.0.0, 0x01 = Unused, 0x02 = 3.0.0)
0x2070x1KeyAreaEncryptionKeyIndex (0x00 = Application, 0x01 = Ocean, 0x02 = System)
0x2080x8ContentSize
0x2100x8ProgramId
0x2180x4ContentIndex
0x21C0x4SdkAddonVersion (used in "FS_ACCESS: { sdk_version: {byte3}.{byte2}.{byte1}, ..." with byte0 set to 0 and compared with a required minimum value: 0x000B0000)
0x2200x1KeyGeneration (0x03 = 3.0.1, 0x04 = 4.0.0, 0x05 = 5.0.0, 0x06 = 6.0.0, 0x07 = 6.2.0, 0x08 = 7.0.0, 0x09 = 8.1.0, 0x0A = 9.0.0, 0x0B = 9.1.0, 0x0C = 12.1.0, 0x0D = 13.0.0, 0x0E = 14.0.0, 0x0F = 15.0.0, 0x10 = 16.0.0, 0x11 = 17.0.0, 0x12 = 18.0.0, 0xFF = Invalid)
0x2210x1[9.0.0+] SignatureKeyGeneration
0x2220xEReserved
0x2300x10RightsId
0x2400x10 * 4Array of FsEntry
0x2800x20 * 4Array of SHA256 hashes (over each FsHeader)
0x3000x10 * 4EncryptedKeyArea

When the above KeyGenerationOld field is 0x2 on >= v3.0, different {crypto/keydata} is used for the sections' data. With system content, this is used with every ncatype except ncatype0. The only other exception is {data-content} for the firm titles: this is required in order for older-system-versions to install it.

KeyGeneration 0x3 (with KeyGenerationOld set to 0x2) is used for all 3.0.1 sysmodules and the System_Version_Title. With 3.0.2, all updated titles use the crypto from 3.0.1 for non-ncatype0, except for firm {data-content}. In some cases various game content uses the above newer crypto as well.

KeyGeneration is always MasterKeyVersion + 1, except for generations 0 and 1 which are both version 0.

The keyindex passed to <key-generation-related code> is determined as follows:

  • Pre-3.0.0: The KeyAreaEncryptionKeyIndex field (0x207) is passed directly.
  • 3.0.0+: It's determined using the KeyAreaEncryptionKeyIndex field (0x207) and the KeyGenerationOld field (0x206). The latter field must be 0, 1 or 2. In each ncahdr_keyindex block, it executes "if(ncahdr_x206>=3)<panic>", but that won't trigger due to the earlier check. The end result is basically the same as pre-3.0.0, except when ncahdr_x206 == 0x2, final_index is new_base_index+ncahdr_keyindex. Actual implementation loads index from u32_array[ncahdr_crypto_type], where the address of u32_array is different for each ncahdr_keyindex.
  • 3.0.1+: The dedicated range check for the KeyGenerationOld field (0x206) was removed, since the updated code no longer needs it. The output from a function masked with 0xFF is now used instead of ncahdr_x206. The range check for that field was changed from {ncahdr_x206 check with panic described above}, to "if(index>=4)final_index=10;"(skips accessing the array and uses 10 directly). The arrays were updated with an additional entry: final_index=v301_base_index+ncahdr_keyindex.
    • The keydata for the above index10 is not(?) known to be initialized.
    • The new function called by the code described above does:
    • if(ncahdr_x206 < ncahdr_x220){ret = ncahdr_x220; } else { ret = ncahdr_x206; } return ret;

FsEntry

OffsetSizeDescription
0x00x4StartOffset (in blocks which are 0x200 bytes)
0x40x4EndOffset (in blocks which are 0x200 bytes)
0x80x8Reserved
OffsetSizeDescription
0x00x2Version (always 2)
0x20x1FsType (0 = RomFS, 1 = PartitionFS)
0x30x1HashType (0 = Auto, 1 = None, 2 = HierarchicalSha256Hash, 3 = HierarchicalIntegrityHash, [14.0.0+] 4 = AutoSha3, [14.0.0+] 5 = HierarchicalSha3256Hash, [14.0.0+] 6 = HierarchicalIntegritySha3Hash)
0x40x1EncryptionType (0 = Auto, 1 = None, 2 = AesXts, 3 = AesCtr, 4 = AesCtrEx, [14.0.0+] 5 = AesCtrSkipLayerHash, [14.0.0+] 6 = AesCtrExSkipLayerHash)
0x50x1[14.0.0+] MetaDataHashType (0 = None, 1 = HierarchicalIntegrity)
0x60x2Reserved
0x80xF8HashData
0x1000x40PatchInfo (only used with game updates RomFs)
0x1400x4Generation
0x1440x4SecureValue
0x1480x30SparseInfo (only used in sections with sparse storage)
0x1780x28[12.0.0+] CompressionInfo
0x1A00x30[14.0.0+] MetaDataHashDataInfo
0x1D00x30Reserved

The FsHeader for each section is at absoluteoffset+0x400+(sectionid*0x200), where sectionid corresponds to the index used with the entry/hash tables.

HashData

This contains information specific to the hash type in use.

HierarchicalSha256Data

OffsetSizeDescription
0x00x20MasterHash (SHA256 hash over the hash-table at section-start+0 with the below hash-table size)
0x200x4BlockSize
0x240x4LayerCount (always 2)
0x280x50LayerRegions (one region for the hash-table and another for PFS0 filesystem)
0x780x80Reserved

Region

OffsetSizeDescription
0x00x8Offset
0x80x8Size

IntegrityMetaInfo

OffsetSizeDescription
0x00x4Magic ("IVFC")
0x40x4Version
0x80x4MasterHashSize
0xC0xB4InfoLevelHash
0xC00x20MasterHash
0xE00x18Reserved

InfoLevelHash

OffsetSizeDescription
0x00x4MaxLayers
0x40x90Levels
0x940x20SignatureSalt
HierarchicalIntegrityVerificationLevelInformation
OffsetSizeDescription
0x00x8LogicalOffset
0x80x8HashDataSize
0x100x4BlockSize (in log2)
0x140x4Reserved

PatchInfo

OffsetSizeDescription
0x00x8IndirectOffset
0x80x8IndirectSize
0x100x10IndirectHeader
0x200x8AesCtrExOffset
0x280x8AesCtrExSize
0x300x10AesCtrExHeader

The above byte-offsets are relative to the start of the section-data.

The two sections specified by the two BKTR entries are usually(?) at the very end of the section data(section_endoffset-{size of BKTR sections}).

RomFs Patching

The PatchInfo section enables combining data from an update NCA with the RomFs from a base NCA to create a single patched RomFS image.

The first BKTR entry describes how to map regions of the two RomFs images to create the patched RomFs. It has the following format:

OffsetSizeDescription
0x00x4Padding/Unused?
0x40x4Number of Buckets
0x80x8Total Size of the Virtual RomFS Image
0x100x3FF0Base Virtual Offset for each Bucket (u64s, padded with 0s until end)
0x40000x4000*XRelocation Buckets

Where relocation buckets are as follows:

OffsetSizeDescription
0x00x4Padding/Unused?
0x40x4Number of Entries
0x80x8End offset for this Bucket
0x100x3FF0Relocation Entries

Where relocation entries are as follows:

OffsetSizeDescription
0x00x8Address in Patched RomFs
0x80x8Address in Source RomFs
0x100x41=Is from Patch RomFS, 0=Is from Base RomFS

The second BKTR entry describes the subsections within the Patch RomFs. It has the following format:

OffsetSizeDescription
0x00x4Padding/Unused?
0x40x4Number of Buckets
0x80x8Total Size of the Physical Patch Image
0x100x3FF0Base Physical Offset for each Bucket (u64s, padded with 0s until end)
0x40000x4000*XSubsection Buckets

Where subsection buckets are as follows:

OffsetSizeDescription
0x00x4Padding/Unused?
0x40x4Number of Entries
0x80x8End offset for this Bucket
0x100x3FF0Subsection Entries

Where subsection entries are as follows:

OffsetSizeDescription
0x00x8Address in Patch RomFs
0x80x4Padding/Unused?
0xC0x4Value for subsection AES-CTR

Official code assumes the relocation entries are sorted, and performs a binary search when determining where to read from. Each subsection in the Patch RomFs has its CTR calculated separately from the others based on the value in its entry (the BKTR entries use normal crypto). Thus decrypting a Patch RomFS requires decrypting and parsing the BKTR entries before anything else.

SparseInfo

OffsetSizeDescription
0x00x8TableOffset
0x80x8TableSize
0x100x10TableHeader
0x200x8PhysicalOffset
0x280x2Generation
0x2A0x6Reserved

CompressionInfo

OffsetSizeDescription
0x00x8TableOffset
0x80x8TableSize
0x100x10TableHeader
0x200x8Reserved

BucketTreeHeader

OffsetSizeDescription
0x00x4Magic ("BKTR")
0x40x4Version
0x80x4EntryCount
0xC0x4Reserved

MetaDataHashDataInfo

OffsetSizeDescription
0x00x8TableOffset
0x80x8TableSize
0x100x20TableHash

This is a PFS0.

See here for the mounted-FS logo contents.

This is a PFS0.

See here for mounted-FS ExeFS contents.

The section-data for ncatype1 RomFS section(section1) uses section-crypto-type 0x4.

Game updates also contain multiple ncatype6 content, which contain "section0_pfs0/fragment". Some of these are just NCAs, unknown for the rest(presumably NCAs with additional crypto?). The first ncatype6 content fragment file has a NDV0 header, with the NCA starting at offset 0x44.

OffsetSizeDescription
{Hash-table offset from superblock}{Hash-table size from superblock}Table of SHA256 hashes.
{Hash-table <offset+size> from superblock}Zeros for alignment to {alignment size}.
{PFS0 offset from superblock}{PFS0 size from superblock}The actual PFS0.

This is the FS which has magicnum "PFS0" at header+0. This is very similar to HFS0. A tool for extracting this FS is available here.

The hash table is hashes for every {Block size from superblock} starting at the PFS0 header. The size used for the last hash is {PFS0 filesystem size from superblock} - offset_relativeto_header.

See also the PFS0 superblock above.

OffsetSizeDescription
0x00x4Magic ("PFS0")
0x40x4EntryCount
0x80x4StringTableSize
0xC0x4Reserved
0x10XPartitionEntryTable
0x10 + XYStringTable
0x10 + X + YZFileData

PartitionEntry

OffsetSizeDescription
0x00x8Offset
0x80x8Size
0x100x4StringOffset
0x140x4Reserved
NCA - Nintendo Switch Brew (2024)

FAQs

What is nca Nintendo Switch? ›

NCA means «Nintendo Content Archive».

Is it legal to homebrew a Switch? ›

Well, they do have one exception – you can break digital locks, only to replace a broken disk drive, as long as you then put the digital lock back afterwards. So, believe it or not, modding your Nintendo Switch in any capacity, under DMCA Section 1201, is actually illegal in the United States.

Is it possible to homebrew a Nintendo Switch? ›

Homebrew can include original games, emulators, save-editing tools, and much, much more! On the Switch in particular, you need CFW to run almost all available homebrew. Some first-gen ("V1") consoles can run homebrew for free, while all other ("patched") consoles require specialized hardware installation beforehand.

What is NCA used for? ›

Lithium Nickel-Cobalt-Aluminum Oxide (NCA) is used as the cathode material for lithium ion secondary batteries, and is mainly used in electric automobiles.

What does NCA mean in electrical? ›

NCA = No Color Associated.

How risky is homebrewing your Switch? ›

By installing the incorrect firmware, there is a fair chance you could inadvertently brick your Switch. Similarly, because of the third-party nature of hacking your Switch and using Homebrew, there are exploratory versions of the custom firmware required to hack your Switch that can also brick your console.

Will I get banned if I homebrew my Switch? ›

The following actions will cause an immediate ban of your Nintendo Switch: Piracy of any sort. Homebrew NSPs (installed to the home menu) Changing user icon through Homebrew.

Can Nintendo sue for mods? ›

Highlights. Nintendo has sued Switch modding company Modded Hardware and individual Ryan Daly for selling pirated devices. Daly previously agreed to stop but continued selling the devices, leading to the lawsuit. Nintendo also sued James Williams for alleged piracy involvement.

Is it safe to install homebrew on Switch? ›

Running untrusted homebrew could potentially damage your Switch, and will void your warranty. You are doing this at your own risk!

Is downloading Switch games illegal? ›

Online Piracy

The uploading and downloading of pirate copies of Nintendo games is illegal.

Why is it called homebrew? ›

Homebrew, when applied to video games, refers to software produced by hobbyists for proprietary video game consoles which are not intended to be user-programmable.

Can I add themes to my Switch? ›

In the Theme Shop you can view all the available themes and purchase any themes you like using Nintendo eShop funds. It's as simple as that!

How do I add apps to my homebrew Switch? ›

Installing. Applications are installed by copying the necessary files directly to the switch/ folder in the root of the SD card, or in a subdirectory of switch/ , in which case said subfolder must be named identically to its executable. Normally the former should be used.

How to install fizeau Switch? ›

Installation. Download the latest zip from the release page, unzip it to the root of your sd card (be careful to merge and not overwrite folders), and reboot. Only the latest version of the Atmosphère CFW is supported. If you want to use the overlay, you will need to set up Tesla (install Tesla-Menu and ovlloader).

Should I install unsigned code? ›

Unfortunately, it's pretty easy, and downloading unsigned codes can only increase the chance of being infected with some kind of ransomware malware (e.g., LockBit, BlackCat, or Black Basta).

What does NAT mean on Nintendo Switch? ›

A user's NAT (Network Address Translation) type determines what users they can connect to during this process.

What is NCA in networking? ›

Rather than each application determining the network state or network topology, the Real-Time Network Connectivity Analysis (NCA) calculates the real-time energization state to be used by all of the applications as well as by the user interface to colorize network maps based on various criteria.

What is NSP and XCI Nintendo? ›

Xci is what you get from dumping a physical cartridge. Nsp is what the Nintendo eshop uses to install eshop games and dlc updates. If possible, yuzu recommends you use xci. If not available, nsp is fine.

References

Top Articles
Works Aimed At Soil Improvement Figgerit
2024 U-Haul Truck Rental Review | Move.org
Words With Friends Cheat Board Layout 11X11
Texas Roadhouse On Siegen Lane
NO CLUE: deutsche Übersetzung von NCT 127
Transfer and Pay with Wells Fargo Online®
Greater Keene Men's Softball
I Feel Pretty (2018) | Rotten Tomatoes
Walmart Front Door Wreaths
Paul Mccombs Nashville Tn
John W Creasy Died December 16 2003
Yoworld Price Guide 2022
All classes in Pathfinder: Wrath of the Righteous
BugBitten Jiggers: a painful infestation
Shae Cornette Bikini
My Sagu Blackboard
The Perfect Couple Episode 5 Cast & Characters - Eve Hewson, Nicole Kidman & More (Photos)
Www.binghamton Craigslist.com
Troy Bilt Belt Diagram
Weird Al.setlist
Craigslist Parsippany Nj Rooms For Rent
Crazy Rays Price List
Wdl Nursing Abbreviation
Appraisalport Com Dashboard /# Orders
Nicolas Alexander Portobanco
Sour Animal Strain Leafly
Greensboro, NC Breaking News Headlines Today | Ground News
Insulated Dancing Insoles
Craigslist Vt Heavy Equipment - Craigslist Near You
My Fico Forums
How To Pause Tamagotchi Gen 2
O'reilly Car Parts Near Me
Lids Locker Room Vacaville Photos
Apple Watch 9 vs. 10 im Vergleich: Unterschiede & Neuerungen
When Is The Next Va Millionaire Raffle 2023
Southeast Ia Craigslist
18443168434
Body Rubs Austin Texas
Joe Bartlett Wor Salary
Candy Land Santa Ana
Netdania.com Gold
Milepslit Ga
Fuzz Bugs Factory Number Bonds
Honda Fury Forums
Ap Bio Unit 2 Progress Check Mcq
Detroit Area Craigslist
Nusl Symplicity Login
Richard Sambade Obituary
Best Of Clinton Inc Used Cars
Poopybarbz
Art Labeling Activity The Big Picture Of Nutrient Catabolism — I Hate CBT's
Fayetteville Arkansas Craigslist
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated:

Views: 5976

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.