mirror of
https://github.com/NinjaCheetah/libWiiPy.git
synced 2025-04-25 12:51:01 -04:00
Added method to title module to get if a title is signed legitimately
This commit is contained in:
parent
e45c7a3076
commit
046645eb56
@ -1,5 +1,9 @@
|
||||
# libWiiPy.nand.setting Module
|
||||
|
||||
The `libWiiPy.nand.setting` module provides support for handling the Wii's `setting.txt` file. This file is stored as part of the Wii Menu's save data (stored in `/title/00000001/00000002/data/`) and is an encrypted text file that's primarily used to store your console's serial number and region information.
|
||||
|
||||
This module allows you to encrypt or decrypt this file, and exposes the keys stored in it for editing.
|
||||
|
||||
## Module Contents
|
||||
|
||||
```{eval-rst}
|
||||
|
@ -1,5 +1,7 @@
|
||||
# libWiiPy.nand.sys Module
|
||||
|
||||
The `libWiiPy.nand.sys` module provides support for editing system files used on the Wii. Currently, it only offers support for `uid.sys`, which keeps a record of the Title IDs of every title launched on the console, assigning each one a unique ID.
|
||||
|
||||
## Module Contents
|
||||
|
||||
```{eval-rst}
|
||||
|
@ -1,5 +1,9 @@
|
||||
# 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
|
||||
|
||||
```{eval-rst}
|
||||
|
@ -1,5 +1,7 @@
|
||||
# libWiiPy.title.commonkeys Module
|
||||
|
||||
The `libWiiPy.title.commonkeys` module simply provides easy access to the Wii's common encryption keys.
|
||||
|
||||
## Module Contents
|
||||
|
||||
```{eval-rst}
|
||||
|
@ -1,5 +1,7 @@
|
||||
# libWiiPy.title.content Module
|
||||
|
||||
The `libWiiPy.title.content` module provides support for parsing, adding, removing, and editing content files from a digital Wii title.
|
||||
|
||||
## Module Contents
|
||||
|
||||
```{eval-rst}
|
||||
|
@ -1,5 +1,7 @@
|
||||
# libWiiPy.title.crypto Module
|
||||
|
||||
The `libWiiPy.title.crypto` module provides low-level cryptography functions required for handling digital Wii titles. It does not expose many functions that are likely to be required during typical use, and instead acts more as a dependency for other modules.
|
||||
|
||||
## Module Contents
|
||||
|
||||
```{eval-rst}
|
||||
|
@ -1,5 +1,7 @@
|
||||
# libWiiPy.title.iospatcher Module
|
||||
|
||||
The `libWiiPy.title.iospatcher` module provides support for applying various binary patches to IOS' ES module. These patches and what they do can be found attached to the methods used to apply them.
|
||||
|
||||
## Module Contents
|
||||
|
||||
```{eval-rst}
|
||||
|
@ -1,5 +1,7 @@
|
||||
# libWiiPy.title.nus Module
|
||||
|
||||
The `libWiiPy.title.nus` module provides support for downloading digital Wii titles from the Nintendo Update Servers. This module provides easy methods for downloading TMDs, common Tickets (when present), encrypted content, and the certificate chain.
|
||||
|
||||
## Module Contents
|
||||
|
||||
```{eval-rst}
|
||||
|
@ -1,5 +1,7 @@
|
||||
# libWiiPy.title.ticket Module
|
||||
|
||||
The `libWiiPy.title.ticket` module provides support for handling Tickets, which are the license files used to decrypt the content of digital titles during installation. This module allows for easy parsing and editing of Tickets.
|
||||
|
||||
## Module Contents
|
||||
|
||||
```{eval-rst}
|
||||
|
@ -1,5 +1,11 @@
|
||||
# libWiiPy.title.title Module
|
||||
|
||||
The `libWiiPy.title.title` module provides a high-level interface for handling all the components of a digital Wii title through one class. It allows for directly importing a WAD, and will automatically extract the various components and load them into their appropriate classes. Additionally, it provides duplicates of some methods found in those classes that require fewer arguments, as it has the context of the other components and is able to retrieve additional data automatically.
|
||||
|
||||
An example of that idea can be seen with the method `get_content_by_index()`. In its original definition, which can be seen at <project:#libWiiPy.title.content.ContentRegion.get_content_by_index>, you are required to supply the Title Key for the title that the content is sourced from. In contrast, when using <project:#libWiiPy.title.title.Title.get_content_by_index>, you do not need to supply a Title Key, as the Title object already has the context of the Ticket and can retrieve the Title Key from it automatically. In a similar vein, this module provides the easiest route for verifying that a title is legitimately signed by Nintendo. The method <project:#libWiiPy.title.title.Title.get_is_signed> is able to access the entire certificate chain, the TMD, and the Ticket, and is therefore able to verify all components of the title by itself.
|
||||
|
||||
Because using <project:#libWiiPy.title.title.Title> allows many operations to be much simpler than if you manage the components separately, it's generally recommended to use it whenever possible.
|
||||
|
||||
## Module Contents
|
||||
|
||||
```{eval-rst}
|
||||
|
@ -1,5 +1,7 @@
|
||||
# libWiiPy.title.tmd Module
|
||||
|
||||
The `libWiiPy.title.tmd` module provides support for handling TMD (Title Metadata) files, which contain the metadata of both digital and physical Wii titles. This module allows for easy parsing and editing of TMDs.
|
||||
|
||||
## Module Contents
|
||||
|
||||
```{eval-rst}
|
||||
|
@ -1,5 +1,7 @@
|
||||
# libWiiPy.title.util Module
|
||||
|
||||
The `libWiiPy.title.util` module provides common utility functions internally. It is not designed to be used directly.
|
||||
|
||||
## Module Contents
|
||||
|
||||
```{eval-rst}
|
||||
|
@ -1,5 +1,7 @@
|
||||
# libWiiPy.title.wad Module
|
||||
|
||||
The `libWiiPy.title.wad` module provides support for handling WAD (Wii Archive Data) files, which is the format used to deliver digital Wii titles. This module allows for extracting the various components for a WAD, as well as properly padding and writing out that data when it has been edited using other modules.
|
||||
|
||||
## Module Contents
|
||||
|
||||
```{eval-rst}
|
||||
|
@ -4,7 +4,9 @@
|
||||
# See https://wiibrew.org/wiki/Title for details about how titles are formatted
|
||||
|
||||
import math
|
||||
from .cert import CertificateChain as _CertificateChain
|
||||
from .cert import (CertificateChain as _CertificateChain,
|
||||
verify_ca_cert as _verify_ca_cert, verify_cert_sig as _verify_cert_sig,
|
||||
verify_tmd_sig as _verify_tmd_sig, verify_ticket_sig as _verify_ticket_sig)
|
||||
from .content import ContentRegion as _ContentRegion
|
||||
from .ticket import Ticket as _Ticket
|
||||
from .tmd import TMD as _TMD
|
||||
@ -418,3 +420,30 @@ class Title:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_is_signed(self) -> bool:
|
||||
"""
|
||||
Uses the certificate chain to verify whether the Title object contains a properly signed title or not. This
|
||||
verifies both the TMD and Ticket, and if either one fails verification then the title is not considered valid.
|
||||
|
||||
This will validate the entire certificate chain. If any part of the chain doesn't match the other pieces, then
|
||||
this method will raise an exception.
|
||||
|
||||
Returns
|
||||
-------
|
||||
bool
|
||||
Whether the title is properly signed or not.
|
||||
"""
|
||||
# The entire chain needs to be verified, so start with the CA cert and work our way down. If anything fails
|
||||
# along the way, future steps don't matter so exit the descending if's and return False.
|
||||
try:
|
||||
if _verify_ca_cert(self.cert_chain.ca_cert) is True:
|
||||
if _verify_cert_sig(self.cert_chain.ca_cert, self.cert_chain.tmd_cert) is True:
|
||||
if _verify_tmd_sig(self.cert_chain.tmd_cert, self.tmd) is True:
|
||||
if _verify_cert_sig(self.cert_chain.ca_cert, self.cert_chain.ticket_cert) is True:
|
||||
if _verify_ticket_sig(self.cert_chain.ticket_cert, self.ticket) is True:
|
||||
return True
|
||||
except ValueError:
|
||||
raise ValueError("This title's certificate chain is not valid, or does not match the signature type of "
|
||||
"the TMD/Ticket.")
|
||||
return False
|
||||
|
Loading…
x
Reference in New Issue
Block a user