Skip to content

feat(nx-object): add the NCA container and its content meta - #12

Merged
LNSD merged 2 commits into
mainfrom
lnsd/nca-and-cnmt-formats
Aug 15, 2026
Merged

LNSD merged 2 commits into
mainfrom
lnsd/nca-and-cnmt-formats

Conversation

@LNSD

@LNSD LNSD commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

An NSP is a set of NCAs plus the CNMT naming them, so packaging a title needs both formats; the builder stops at the plaintext container and names what encryption is still owed, keeping key material out of a crate whose contract is bytes in, bytes out.

  • Add raw::nca and raw::cnmt, covering the NCA header, its four section entries and FS headers, the PFS0 and RomFS superblocks, and the content meta's header, extended header, and content records
  • Add write::nca::NcaBuilder, which lays sections out at fixed indices, derives the IVFC tree or hash table verifying each, and returns a PlainNca whose ctr_sections name the ranges and counters the caller must still encrypt
  • Add write::cnmt::CnmtBuilder, deriving each NCA's name from its own hash and the patch title ID from the title ID, and sorting records so one set of contents produces one set of bytes
  • Gate both behind new nca and cnmt features, and state in the crate docs why encryption and signing stay outside this crate

LNSD added 2 commits August 15, 2026 11:43
An NSP is a set of NCAs plus the CNMT naming them, so packaging a title needs both formats; the builder stops at the plaintext container and names what encryption is still owed, keeping key material out of a crate whose contract is bytes in, bytes out.

- Add `raw::nca` and `raw::cnmt`, covering the NCA header, its four section entries and FS headers, the PFS0 and RomFS superblocks, and the content meta's header, extended header, and content records
- Add `write::nca::NcaBuilder`, which lays sections out at fixed indices, derives the IVFC tree or hash table verifying each, and returns a `PlainNca` whose `ctr_sections` name the ranges and counters the caller must still encrypt
- Add `write::cnmt::CnmtBuilder`, deriving each NCA's name from its own hash and the patch title ID from the title ID, and sorting records so one set of contents produces one set of bytes
- Gate both behind new `nca` and `cnmt` features, and state in the crate docs why encryption and signing stay outside this crate

Signed-off-by: Lorenzo Delgado <lnsdev@proton.me>
Four of the wiki anchors added with the formats pointed at sections that do not exist, and reading the ones that do showed several fields documented as padding are named and used by the format; the layout was right, the description of it was not.

- Repoint `NCA#SectionTableEntry`, `NCA#NcaFsHeader`, `NCA#NcaHeader` and `CNMT#PackagedContentMeta` at `FsEntry`, `FsHeader`, `Header` and `PackagedContentMetaHeader`, and add the references the IVFC and superblock structures were missing
- Rename `IvfcHeader::id` to `version`, its trailing reserved block to `signature_salt`, `Pfs0Superblock::always_2` to `layer_count`, and the application extended header's reserved word to `required_application_version`
- Say what the spans this crate zeroes actually hold: the `PatchInfo` following each superblock, the `Generation` and `SecureValue` making up a section counter, and the content meta's attributes and download floor
- List NCA and CNMT in the README's format table and reference list, record both formats and their features in `AGENTS.md`, and note there that the crate hashes but never encrypts

Signed-off-by: Lorenzo Delgado <lnsdev@proton.me>
@LNSD
LNSD added this pull request to the merge queue Aug 15, 2026
Merged via the queue into main with commit 8e311d0 Aug 15, 2026
5 checks passed
@LNSD
LNSD deleted the lnsd/nca-and-cnmt-formats branch August 15, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant