CTXT

From 3dbrew
Revision as of 18:10, 27 May 2026 by TimmSkiller (talk | contribs) (Complete documentation of the CTX format)
Jump to navigation Jump to search

This page describes the structure of the .ctx files located at nand:/title/<titlepath>/00000000.ctx.

Title Import Context

This represents an active/pending title installation.

Offset Size Description
0x0 0x10 AES-CMAC over SHA256 of bytes 0x10..0x30, see below for keyslots used
0x10 0x4 Magic "CTXT"
0x14 0x4 CTXT version, must be 1
0x18 0x4 Number of active content imports (X)
0x1C 0x4 padding
0x20 0x8 TitleID
0x28 0x4 Random u32 value generated during creation
0x2C 0x1D4 All-zero

Content Import Context

This represents an active content installation.

Offset Size Description
0x0 0x10 AES-CMAC over the SHA256 of bytes 0x10 to the end, see below for keyslots used
0x10 0x8 TitleID
0x18 0x18 ImportContentContext for this content
0x30 0x3CC Content Import Context State (initially filled with FFs)
0x3FC 0x4 Same random number as in Title Import Context

Paused Content Import State

Offset Size Description
0x0 0x1 bool, is paused
0x1 0x3 padding
0x4 0x4 u32, always 1 (checked to be 1, too)
0x8 0x8 u64, title ID
0x10 0x4 u32, content ID from TMD
0x14 0xA0 SHA-256 state for this content (to continue where hashing left off)
0xB4 0x10 AES-CBC IV for CDN-level decryption (if enabled in the corresponding TMD content chunk record)
0xC4 0x8 u64, current installation offset

Content Import Context State

Offset Size Description
0x0 0xCC Paused Content Import State
0xCC 0x180 APCert
0x24C 0x3C ECDSA signature using SHA-256 over the Paused Content Import State, signed by the APCert
0x288 0x144 Reserved

CTX Files

CTX files, usually found in the root of the title folder of the corresponding title (see Title Data Structure) contain information about an active title installation, as well as data to resume the installation. This is usually one file, called 00000000.ctx which consists of one Title Import Context and one or more Content Import Contexts:

Offset Size Description
0x0 0x200 Title Import Context (contains X)
0x200 0x400 * X Content Import Contexts

CTX files are created during any form of content installation after the TMD has been fully installled and persist for as long as title installation does (this includes pausing installations). When the CTX file is created, a random number is generated and stored in both the title/content import contexts in the CTX file and in the corresponding Title Info Entry in the title database.

When title installation is finalized, this value is compared against the existing value in the title database. If it does not match, error 0xD8A08042 is returned.

After content installation and successful install finalization, the .ctx file is removed from the title directory.

Both title and content import contexts use CMACs over SHA256 hashes for verification:

Media Type Keyslot Used
SD 0x30
NAND 0xB