namespace BinaryObjectScanner.Models.N3DS { /// /// A format used to store an encrypted titlekey (using 128-Bit AES-CBC). /// With 3DS, the Ticket format was updated (now v1) from Wii/DSi format (v0). /// /// public sealed class Ticket { /// /// Signature Type /// public SignatureType SignatureType; /// /// Signature size /// public ushort SignatureSize; /// /// Padding size /// public byte PaddingSize; /// /// Signature /// public byte[] Signature; /// /// Padding /// public byte[] Padding; /// /// Issuer /// public string Issuer; /// /// ECC PublicKey /// public byte[] ECCPublicKey; /// /// Version (For 3DS this is always 1) /// public byte Version; /// /// CaCrlVersion /// public byte CaCrlVersion; /// /// SignerCrlVersion /// public byte SignerCrlVersion; /// /// TitleKey (normal-key encrypted using one of the common keyYs; see below) /// /// /// The titlekey is decrypted by using the AES engine with the ticket common-key keyslot. /// The keyY is selected through an index (ticket offset 0xB1) into a plaintext array /// of 6 keys ("common keyYs") stored in the data section of Process9. AES-CBC mode is used /// where the IV is the big-endian titleID. Note that on a retail unit index0 is a retail keyY, /// while on a dev-unit index0 is the dev common-key which is a normal-key. /// (On retail for these keyYs, the hardware key-scrambler is used) /// /// The titlekey is used to decrypt content downloaded from the CDN using 128-bit AES-CBC with /// the content index (as big endian u16, padded with trailing zeroes) as the IV. /// public byte[] TitleKey; /// /// Reserved /// public byte Reserved1; /// /// TicketID /// public ulong TicketID; /// /// ConsoleID /// public uint ConsoleID; /// /// TitleID /// public ulong TitleID; /// /// Reserved /// public byte[] Reserved2; /// /// Ticket title version /// /// /// The Ticket Title Version is generally the same as the title version stored in the /// Title Metadata. Although it doesn't have to match the TMD version to be valid. /// public ushort TicketTitleVersion; /// /// Reserved /// public byte[] Reserved3; /// /// License Type /// public byte LicenseType; /// /// Index to the common keyY used for this ticket, usually 0x1 for retail system titles /// public byte CommonKeyYIndex; /// /// Reserved /// public byte[] Reserved4; /// /// eShop Account ID? /// public uint eShopAccountID; /// /// Reserved /// public byte Reserved5; /// /// Audit /// public byte Audit; /// /// Reserved /// public byte[] Reserved6; /// /// Limits /// /// /// In demos, the first u32 in the "Limits" section is 0x4, then the second u32 is the max-playcount. /// public uint[] Limits; /// /// The Content Index of a ticket has its own size defined within itself, /// with seemingly a minimal of 20 bytes, the second u32 in big endian defines /// the full value of X. /// public uint ContentIndexSize; /// /// Content Index /// public byte[] ContentIndex; /// /// Certificate chain /// /// /// https://www.3dbrew.org/wiki/Ticket#Certificate_Chain /// public Certificate[] CertificateChain; } }