Documentation
¶
Index ¶
- Constants
- Variables
- type BinaryTMD
- type ContentRecord
- type ContentType
- type ESLicenseType
- type KeyType
- type SignatureType
- type TMD
- type Ticket
- type TimeLimitEntry
- type WAD
- func (w *WAD) ChangeTitleKey(updatedKey [16]byte) error
- func (w *WAD) GetContent(index int) ([]byte, error)
- func (w *WAD) GetDataSection() []byte
- func (w *WAD) GetHeader() ([]byte, error)
- func (w *WAD) GetTMD() ([]byte, error)
- func (w *WAD) GetTicket() ([]byte, error)
- func (w *WAD) GetWAD(wadType WADType) ([]byte, error)
- func (w *WAD) LoadDataSection(data []byte) error
- func (w *WAD) LoadHeader(source []byte) error
- func (w *WAD) LoadTMD(contents []byte) error
- func (w *WAD) LoadTicket(source []byte) error
- func (w *WAD) UpdateContent(index int, contents []byte) error
- type WADFile
- type WADHeader
- type WADType
Constants ¶
const ( // WADTypeCommon is used for IOS, channels, and roughly all other items. WADTypeCommon WADType = 0x49730000 // WADTypeBoot is used for WADs containing boot-related items. WADTypeBoot = 0x69620000 // WADTypeUnknown is documented under https://wiibrew.org/wiki/WAD_files#Header by bushing. // I have not encountered this format in the wild, nor any SDK. WADTypeUnknown = 0x426b000 )
WADType contains a list of WAD types to compare against.
const ( KeyTypeCommon KeyType = 0x0 KeyTypeKoren = 0x1 KeyTypevWii = 0x2 )
Variables ¶
var ( // CommonKey is the common key for titles in all regions but Korea. // Put into hex, "ebe42a225e8593e448d9c5457381aaf7" CommonKey = [16]byte{0xeb, 0xe4, 0x2a, 0x22, 0x5e, 0x85, 0x93, 0xe4, 0x48, 0xd9, 0xc5, 0x45, 0x73, 0x81, 0xaa, 0xf7} // KoreanKey is the common key for titles in the Korean-covered regions. // As hex, "63b82bb4f4614e2e13f2fefbba4c9b7e" KoreanKey = [16]byte{0x63, 0xb8, 0x2b, 0xb4, 0xf4, 0x61, 0x4e, 0x2e, 0x13, 0xf2, 0xfe, 0xfb, 0xba, 0x4c, 0x9b, 0x7e} // WiiUvWiiKey is untested. // Used for system titles as updated from Wii U mode, and never actually known to anything inside of vWii. WiiUvWiiKey = [16]byte{0x30, 0xbf, 0xc7, 0x6e, 0x7c, 0x19, 0xaf, 0xbb, 0x23, 0x16, 0x33, 0x30, 0xce, 0xd7, 0xc2, 0x8d} )
var ( // CertChainTemplate is an example certificate chain // that may go alongside a TMD. //go:embed templates/certs CertChainTemplate []byte // TMDTemplate is an example TMD that may be loaded // in order to create a custom WAD. //go:embed templates/tmd TMDTemplate []byte // TicketTemplate is an example Ticket that may be loaded // in order to create a custom WAD. //go:embed templates/tik TicketTemplate []byte )
var (
ErrInvalidIndex = errors.New("index does not exist within WAD")
)
Functions ¶
This section is empty.
Types ¶
type BinaryTMD ¶
type BinaryTMD struct { SignatureType SignatureType Signature [256]byte Issuer [64]byte FileVersion uint8 CACRLVersion uint8 SignerCRLVersion uint8 IsvWii bool SystemVersionHigh uint32 SystemVersionLow uint32 TitleID uint64 TitleType uint32 GroupID uint16 Unknown uint16 Region uint16 Ratings [16]byte Reserved [12]byte IPCMask [12]byte Reserved2 [18]byte AccessRightsFlags uint32 TitleVersion uint16 NumberOfContents uint16 BootIndex uint16 // contains filtered or unexported fields }
BinaryTMD describes a byte-level format for a TMD.
type ContentRecord ¶
type ContentRecord struct { ID uint32 Index uint16 Type ContentType Size uint64 Hash [20]byte }
ContentRecord describes information about a given content.
type ContentType ¶
type ContentType uint16
ContentType specifies the type of content expected. It can be a shared content held in /shared2, or a normal content for the title itself.
const ( TitleTypeNormal ContentType = 0x0001 )
type ESLicenseType ¶
type ESLicenseType uint8
ESLicenseType describes the current title's license type.
const ( LicensePermanent ESLicenseType = iota LicenseDemo LicenseTrial LicenseRental LicenseSubscription LicenseService )
type KeyType ¶
type KeyType uint8
KeyType represents the key type for the given "index". There are 3 known types.
type SignatureType ¶
type SignatureType uint32
SignatureType allows specification of the type of signature to be parsed in a ticket.
const ( // SignatureRSA2048 is only one of several internal signature types. // See https://git.io/JfJzH or, from acer_cloud_wifi_copy, // /sw_x/es_core/esc/core/base/include/esitypes.h#L74 // However, only RSA 2048 is used in the Wii's title system. SignatureRSA2048 SignatureType = 0x00010001 )
type TMD ¶
type TMD struct { BinaryTMD Contents []ContentRecord }
TMD describes a human-usable TMD format.
type Ticket ¶
type Ticket struct { SignatureType SignatureType Signature [256]byte Issuer [64]byte ECDHData [60]byte FileVersion uint8 CACRLVersion uint8 SignerCRLVersion uint8 TitleKey [16]byte Padding byte TicketID uint64 ConsoleID uint32 TitleID uint64 SystemAccessMask [2]uint8 TitleVersion uint16 // WiiBrew describes this as the "Permitted Titles Mask". // estypes.h does not agree. We'll use the official description. AccessTitleID uint32 AccessTitleMask uint32 LicenseType uint8 KeyType KeyType Unknown [114]byte TimeLimits [8]TimeLimitEntry // contains filtered or unexported fields }
Ticket defines the binary structure of a given ticket file.
func (*Ticket) GetTitleKey ¶ added in v0.3.0
func (*Ticket) UpdateTitleKey ¶ added in v0.3.0
UpdateTitleKey updates the key for the given ticket. Note that this will not re-encrypt existing data for the WAD. Consider using WAD.ChangeTitleKey to re-encrypt instead, where possible.
type TimeLimitEntry ¶
type TimeLimitEntry struct { // It's unknown what code represents. Code uint32 // Each limit is in seconds. Limit uint32 }
TimeLimitEntry holds a time limit entry for a title.
type WAD ¶
type WAD struct { Header WADHeader CertificateChain []byte CertificateRevocationList []byte Ticket Ticket TMD TMD Data []WADFile Meta []byte }
WAD describes the structure enclosing information in a typical WAD's format.
func LoadWADFromFile ¶
LoadWADFromFile takes a path, loads it, and parses the given binary WAD.
func (*WAD) ChangeTitleKey ¶ added in v0.3.0
ChangeTitleKey updates the ticket to contain the given title key, and re-encrypts all data to match.
func (*WAD) GetContent ¶ added in v0.3.0
GetContent returns the data for the given index.
func (*WAD) GetDataSection ¶ added in v0.3.0
GetDataSection returns data as specified within the TMD.
func (*WAD) GetHeader ¶ added in v0.2.0
GetHeader returns bytes based off the WADHeader for the given WAD.
func (*WAD) GetTMD ¶ added in v0.2.0
GetTMD returns the bytes for the given TMD within the current WAD.
func (*WAD) GetTicket ¶ added in v0.2.0
GetTicket returns the bytes of a given Ticket within the current WAD.
func (*WAD) LoadDataSection ¶ added in v0.3.0
LoadDataSection loads the binary data from a WAD and parses it as specified within the TMD.
func (*WAD) LoadHeader ¶ added in v0.2.0
LoadHeader creates a WADHeader based off of the given contents.
func (*WAD) LoadTMD ¶ added in v0.2.0
LoadTMD loads a given TMD from the passed contents into the WAD.
func (*WAD) LoadTicket ¶ added in v0.2.0
LoadTicket loads the given bytes from source into the Ticket for the current WAD.
type WADFile ¶
type WADFile struct { Record *ContentRecord RawData []byte }
WADFile represents a file within a WAD. RawData should always be the encrypted data ready to be stored within a WAD.
func (*WADFile) DecryptData ¶ added in v0.2.0
DecryptData returns the decrypted contents of this WADFile with the given title key.
func (*WADFile) UpdateData ¶ added in v0.3.0
UpdateData updates the contents of this WADFile with the given data and title key.