pyctr.type.cdn module
Module for interacting with contents in CDN layout.
- exception pyctr.type.cdn.CDNError[source]
Bases:
PyCTRError
Generic error for CDN operations.
- class pyctr.type.cdn.CDNSection(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
- Ticket = -2
Contains the title key used to decrypt the contents, as well as a content index describing which contents are enabled (mostly used for DLC).
- TitleMetadata = -1
Contains information about all the possible contents.
- Application = 0
Main application CXI.
- Manual = 1
Manual CFA. It has a RomFS with a single “Manual.bcma” file inside.
- DownloadPlayChild = 2
Download Play Child CFA. It has a RomFS with CIA files that are sent to other Nintendo 3DS systems using Download Play. Most games only contain one.
- class pyctr.type.cdn.CDNRegion(section, iv)[source]
Bases:
NamedTuple
- Parameters:
section (Union[int, CDNSection]) –
iv (bytes) –
- section: int | CDNSection
Index of the section.
- class pyctr.type.cdn.CDNReader(file, *, fs=None, case_insensitive=False, crypto=None, dev=False, seed=None, titlekey=None, decrypted_titlekey=None, common_key_index=0, load_contents=True)[source]
Bases:
object
Reads the contents of files in a CDN file layout.
Only NCCH contents are supported. SRL (DSiWare) contents are currently ignored.
Note that a custom
CryptoEngine
object is only used for encryption on the CDN contents. EachNCCHReader
must use their own object, as it can only store keys for a single NCCH container. To use a custom one, set load_contents to False, then load each section manually with open_raw_section.- Parameters:
file (FilePath) – A path to a tmd file. All the contents should be in the same directory.
case_insensitive (bool) – Use case-insensitive paths for the RomFS of each NCCH container.
crypto (CryptoEngine) – A custom
CryptoEngine
object to be used. Defaults to None, which causes a new one to be created. This is only used to decrypt the CIA, not the NCCH contents.dev (bool) – Use devunit keys.
seed (bytes) – Seed to use. This is a quick way to add a seed using
add_seed()
.titlekey (bytes) – Encrypted titlekey to use. Used over the ticket file if specified.
decrypted_titlekey (bytes) – Decrypted titlekey to use. Used over the encrypted titlekey or ticket if specified.
common_key_index (int) – Common key index to decrypt the titlekey with. Only used if titlekey is specified. Defaults to 0 for an eShop application.
load_contents (bool) – Load each partition with
NCCHReader
.fs (Optional[FS]) –
- fs
- available_sections: List[CDNSection | int]
A list of sections available, including contents, ticket, and title metadata.
- contents: Dict[int, NCCHReader]
A dict of
NCCHReader
objects for each active NCCH content.
- content_info: List[ContentChunkRecord]
A list of
ContentChunkRecord
objects for each content found in the directory at the time of object initialization.
- tmd: TitleMetadataReader
The
TitleMetadataReader
object with information from the TMD section.
- open_raw_section(section)[source]
Open a raw CDN content for reading with on-the-fly decryption.
- Parameters:
section (Union[int, CDNSection]) – The content to open.
- Returns:
A file-like object that reads from the content.
- Return type:
io.BufferedIOBase | CBCFileIO