Changes

Jump to: navigation, search

WAD files

10,232 bytes removed, 00:29, 20 June 2008
updated.
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x007
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Header type WAD Type (0x49730000 'Is\0\0' or 0x69620000'ib\0\0' or 'Bk\0\0')
|- style="background-color: #ddd;"
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x008
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x01B
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | APP data size
|- style="background-color: #ddd;"
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x01C
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x01F
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Trailer Footer size
|}
The files contents are stored in the WAD in the same order that as in the headerTMD. After each Each block (header, filescontents), the file is aligned to 0x40 bytes.
=== Chain The contents are encrypted using the title key (decrypt it from the [[Ticket|ticket]]) and the content index (in the TMD, the 2 first bytes of Certificates ===the IV are the index, the last 14 bytes are zeroes) as IV. The SHA1 of the decrypted content must match that stored in the TMD.
'''<span style="color: red;">It's recommended to read the [[Certificate chain|certificate chain]] article and using the header information instead of that info and constant offsets.</span>''' {| style="border-collapse: collapse; padding: 0.2em 0.2em 0.2em 0.2em;"|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #cdc;" | '''Start'''| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ccd;" | '''End'''| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ccc;" | '''Length'''| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dcc;" | '''Description'''|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x040| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x043| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | signature type (0x00010001 RSA2048, 0x00010000 RSA4096)|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x044| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x143+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 256 for RSA2048 (d=0x000), 512 for RSA4096 (d=0x100)| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | signature|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x144+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x17F+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 60| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | zero filled|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x180+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x1BF+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 64| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | issuer|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x1C0+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x1C3+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | ? subject type (0x00000000, 0x00000001)|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x1C4+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x203+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 64| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | subject|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x204+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x307+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 260| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | ? public key|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x308+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x30B+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | ?? unknown (0x00010001)|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x30C+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x33F+d| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 52| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | zero filled|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | ...| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | ...| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | ...| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | ...|} === Key and IV === '''<span style="color: red;">It's recommended to read the [[Ticket|ticket]] article and using the header information instead of that info and constant offsets.</span>''' {| style="border-collapse: collapse; padding: 0.2em 0.2em 0.2em 0.2em;"|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #cdc;" | '''Start'''| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ccd;" | '''End'''| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ccc;" | '''Length'''| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dcc;" | '''Description'''|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x0bff| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x0c0e| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 0x0010| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Encrypted title key (decrypt using the master key)|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x0c1c| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x0c23| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 0x0008| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | First 8 bytes of IV for title key decryption (last 8 bytes are zero)|} To obtain the title key, simply decrypt it using the master key and the given IV (last eight bytes zero, first eight bytes supplied). Note: this is probably part of the TMD/ticket/whatever. I'm throwing the offsets here for now, since this is arguably the most important part for extraction purposes. === File Table === '''<span style="color: red;">It's recommended to read the [[Tmd file structure|TMD]] article and using the header information instead of that info and constant offsets.</span>''' WAD files contain a number of "files" in them. The number of files can be obtained from the halfword (2 bytes) at 0xede. The table itself starts at 0xee4, and it is composed of a number of file entries: {| style="border-collapse: collapse; padding: 0.2em 0.2em 0.2em 0.2em;"|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #cdc;" | '''Start'''| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ccd;" | '''End'''| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ccc;" | '''Length'''| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dcc;" | '''Description'''|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x00| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x03| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 0x04| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | File number / ID|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x04| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x05| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 0x02| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | First 2 bytes of IV to decrypt contents (last 14 bytes are zero)|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x06| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x07| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 0x02| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Flags ?|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x08| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x0B| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 0x04| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Padding (zero)|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x0C| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x0F| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 0x04| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | File size|- style="background-color: #ddd;"| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x10| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x24| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 0x14| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | SHA-1 sum of decrypted file|} The files are located after the file table, with their starts aligned to a 64 byte boundary. To read a file, skip bytes until the next 64 byte boundary (unless already at one), read the ''File size'' bytes rounded to the next 16 bytes (the AES block size), decrypt using AES (using the title key and the IV in the file table entry plus 14 zero bytes), and take filesize bytes from the result to create the output file. The SHA-1 sum of this should match the one in the file table. === APP Footer ===The "APPfooter" block in the WAD is a block of encrypted data that contains the info that is actually used. The contents in the APP are referenced by the TMD content table. The APP is aligned to 64 bytes after each file. The files are encrypted using the title key (decrypt it from the [[Ticket|ticket]]) and the file index (in the TMDan optional, the 2 first bytes of the IV are the index, the last 14 bytes are zeroes) as IV. === Trailer ===The "trailer" is a copy of the first file in the APP section. It's unencrypted. === Modification tools ===There are tools which allow wad manipulation, but they will not be provided here because of piracy concernstimestamp / buildstamp.

Navigation menu