libWiiPy.title.cert Module#
The libWiiPy.title.cert
module provides support for parsing the various signing certificates used by the Wii for content validation.
This module allows you to write your own code for validating the authenticity of a TMD or Ticket by providing the certificates from the Wii’s certificate chain. Both retail and development certificate chains are supported.
Module Contents#
- class libWiiPy.title.cert.Certificate#
Bases:
object
A Certificate object used to parse a certificate used for the Wii’s content verification.
- type#
The type of the certificate, either RSA-2048, RSA-4096, or ECC.
- Type:
- signature#
The signature data of the certificate.
- Type:
bytes
- issuer#
The certificate that issued this certificate.
- Type:
str
- pub_key_type#
The type of public key contained in the certificate, either RSA-2048, RSA-4096, or ECC.
- Type:
- child_name#
The name of this certificate.
- Type:
str
- pub_key_id#
The ID of this certificate’s public key.
- Type:
int
- pub_key_modulus#
The modulus of this certificate’s public key. Combined with the exponent to get the full key.
- Type:
int
- pub_key_exponent#
The exponent of this certificate’s public key. Combined with the modulus to get the full key.
- Type:
int
- dump() bytes #
Dump the certificate object back into bytes.
- Returns:
The certificate file as bytes.
- Return type:
bytes
- load(cert: bytes) None #
Loads certificate data into the Certificate object, allowing you to parse the certificate.
- Parameters:
cert (bytes) – The data for the certificate to load.
- class libWiiPy.title.cert.CertificateChain#
Bases:
object
A CertificateChain object used to parse the chain of certificates stored in a WAD that are used for the Wii’s content verification. The certificate chain is the format that the certificates are stored in as part of every WAD.
- ca_cert#
The CA certificate from the chain.
- Type:
- tmd_cert#
The CP (TMD) certificate from the chain.
- Type:
- ticket_cert#
The XS (Ticket) certificate from the chain.
- Type:
- dump() bytes #
Dumps the full certificate chain back into bytes. This chain will always be formatted with the CA cert first, followed by the CP (TMD) cert, then finally the XS (Ticket) cert.
- Returns:
The full certificate chain as bytes.
- Return type:
bytes
- load(cert_chain: bytes) None #
Loads certificate chain data into the CertificateChain object, allowing you to parse the individual certificates stored in the chain.
- Parameters:
cert_chain (bytes) – The data for the certificate chain to load.
- class libWiiPy.title.cert.CertificateKeyLength(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
IntEnum
- ECC = 60#
- RSA_2048 = 256#
- RSA_4096 = 512#
- class libWiiPy.title.cert.CertificateKeyType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
IntEnum
- ECC = 2#
- RSA_2048 = 1#
- RSA_4096 = 0#
- class libWiiPy.title.cert.CertificateSignatureLength(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
IntEnum
- ECC = 60#
- RSA_2048 = 256#
- RSA_4096 = 512#
- class libWiiPy.title.cert.CertificateType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
IntEnum
- ECC = 65538#
- RSA_2048 = 65537#
- RSA_4096 = 65536#
- libWiiPy.title.cert.verify_ca_cert(ca_cert: Certificate) bool #
Verify a Wii CA certificate using the root public key. The retail or development root key will be automatically selected based off of the name of the CA certificate provided.
- Parameters:
ca_cert (Certificate) – The CA certificate to verify.
- Returns:
Whether the certificate is valid or not.
- Return type:
bool
- libWiiPy.title.cert.verify_cert_sig(ca_cert: Certificate, target_cert: Certificate) bool #
Verify a TMD or Ticket certificate using a CA certificate.
- Parameters:
ca_cert (Certificate) – The CA certificate to use for verification.
target_cert (Certificate) – The target certificate to verify.
- Returns:
Whether the certificate’s signature is valid or not.
- Return type:
bool
- libWiiPy.title.cert.verify_ticket_sig(ticket_cert: Certificate, ticket: Ticket) bool #
Verify the signature of a Ticket file using a Ticket certificate.
- Parameters:
ticket_cert (Certificate) – The Ticket certificate to use for verification.
ticket (Ticket) – The Ticket to verify.
- Returns:
Whether the Ticket’s signature is valid or not.
- Return type:
bool
- libWiiPy.title.cert.verify_tmd_sig(tmd_cert: Certificate, tmd: TMD) bool #
Verify the signature of a TMD file using a TMD certificate.
- Parameters:
tmd_cert (Certificate) – The TMD certificate to use for verification.
tmd (TMD) – The TMD to verify.
- Returns:
Whether the TMD’s signature is valid or not.
- Return type:
bool