The data within a WAD file has the following format.
Thanks to Segher for his source.
|0x000||0x003||4||Header size = 0x0020|
|0x004||0x007||4||WAD Type ('Is\0\0' or 'ib\0\0' or 'Bk\0\0')|
|0x008||0x00B||4||Certificate chain size.|
|0x00C||0x00F||4||Reserved = 0|
|0x018||0x01B||4||Data (APP) size|
The sections are stored in the WAD in the same order that in the header. Each block (header, sections) is aligned to 0x40 bytes.
The contents are stored in the WAD in the same order as in the TMD. Each file is aligned to 0x40 bytes.
The contents (Data section) are encrypted using the title key (decrypt it from the ticket) and the content index (in the TMD, the 2 first bytes of the IV are the index, the last 14 bytes are zeroes) as IV. The SHA1 of the decrypted content must match the hash that is stored in the TMD.
The "footer" is an optional, unencrypted timestamp / buildstamp.