Title metadata is a format used to store information about a title (a single standalone game, channel, etc.) and all its installed contents, including which contents they consist of and their SHA1 hashes.
Code is available by trap15 to parse the available information from the 3DS format of TMDs.
Structure
All the data in the file represented in Big Endian.
Offset
|
|
Size
|
Description
|
RSA 2048 |
RSA 4096 |
|
|
0x000 |
0x000 |
4 |
Signature type
|
0x004 |
0x004 |
256 / 512 |
Signature
|
0x104 |
0x204 |
60 |
Padding modulo 64
|
0x140 |
0x240 |
64 |
Issuer
|
0x180 |
0x280 |
1 |
Version
|
0x181 |
0x281 |
1 |
ca_crl_version
|
0x182 |
0x282 |
1 |
signer_crl_version
|
0x183 |
0x283 |
1 |
Padding modulo 64
|
0x184 |
0x284 |
8 |
System Version
|
0x18C |
0x28C |
8 |
Title ID
|
0x194 |
0x294 |
4 |
Title type
|
0x198 |
0x298 |
2 |
Group ID
|
0x19A |
0x29A |
62 |
reserved
|
0x1D8 |
0x2D8 |
4 |
Access rights
|
0x1DC |
0x2DC |
2 |
Title version
|
0x1DE |
0x2DE |
2 |
Number of contents (contcount)
|
0x1E0 |
0x2E0 |
2 |
Boot content
|
0x1E2 |
0x2E2 |
2 |
Padding
|
0x1E4 |
0x2E4 |
32 |
SHA-256 hash of the 36*64 byte long content info record blob (next field)
|
0x204 |
0x304 |
36*64 |
Content info records
|
0xB04 |
0xC04 |
48*contcount |
Content chunk records
|
Content info records
Offset
|
Size
|
Description
|
0x00
|
2
|
Content index offset
|
0x02
|
2
|
Content command count [k]
|
0x04
|
32
|
SHA-256 hash of the next k content records that have not been hashed yet
|
Content chunk records
Offset
|
Size
|
Description
|
0x00
|
4
|
Content id
|
0x04
|
2
|
Content index
|
0x06
|
2
|
Content type
|
0x08
|
8
|
Content size
|
0x10
|
32
|
SHA-256 hash
|
Content Index
This indicates the content type:
Index
|
Content Type
|
0000
|
Main Content (.CXI for 3DS executable content/.CFA for 3DS Data Archives/.SRL for TWL content)
|
0001
|
Home Menu Manual (.CFA)
|
0002
|
DLP Child Container (.CFA)
|
Content Type flags
Flags
|
Description
|
1
|
Encrypted
|
2
|
Disc
|
4
|
CFM (abbreviation for?)
|
0x4000
|
Optional
|
0x8000
|
Shared
|
Certificate Chain
If the TMD file is obtained from Nintendo's CDN, then it will have two certificates appended at the end of the file: .
CERTIFICATE
|
SIGNATURE TYPE
|
RETAIL CERT NAME
|
DEBUG CERT NAME
|
DESCRIPTION
|
TMD
|
RSA-2048
|
CP0000000b
|
CP0000000a
|
Used to verify the TMD signature
|
CA
|
RSA-4096
|
CA00000003
|
CA00000004
|
Used to verify the TMD Certificate
|
The CA certificate is issued by 'Root', the public key for which is stored in NATIVE_FIRM.
Example code application
enum sig_type {
RSA_2048_SHA256 = 0x00010004,
RSA_4096_SHA256 = 0x00010003,
RSA_2048_SHA1 = 0x00010001,
RSA_4096_SHA1 = 0x00010000
};
// Sorry I removed the example struct because it is wrong.