Added methods to check if a TMD, Ticket, and Title are fakesigned

This commit is contained in:
Campbell 2024-08-03 14:01:09 -04:00
parent 6220821a2f
commit fb87c2c58c
Signed by: NinjaCheetah
GPG Key ID: B547958AF96ED344
3 changed files with 63 additions and 2 deletions

View File

@ -252,6 +252,27 @@ class Ticket:
except OverflowError: except OverflowError:
raise Exception("An error occurred during fakesigning. Ticket could not be fakesigned!") raise Exception("An error occurred during fakesigning. Ticket could not be fakesigned!")
def get_is_fakesigned(self) -> bool:
"""
Checks the Ticket object to see if it is currently fakesigned. For a description of fakesigning, refer to the
fakesign() method.
Returns
-------
bool:
True if the Ticket is fakesigned, False otherwise.
See Also
--------
libWiiPy.title.ticket.Ticket.fakesign()
"""
if self.signature != b'\x00' * 256:
return False
test_hash = hashlib.sha1(self.dump()[320:]).hexdigest()
if test_hash[:2] != '00':
return False
return True
def get_title_id(self) -> str: def get_title_id(self) -> str:
""" """
Gets the Title ID of the ticket's associated title. Gets the Title ID of the ticket's associated title.
@ -275,7 +296,7 @@ class Ticket:
See Also See Also
-------- --------
commonkeys.get_common_key libWiiPy.title.commonkeys.get_common_key
""" """
match self.common_key_index: match self.common_key_index:
case 0: case 0:

View File

@ -316,3 +316,22 @@ class Title:
""" """
self.tmd.fakesign() self.tmd.fakesign()
self.ticket.fakesign() self.ticket.fakesign()
def get_is_fakesigned(self):
"""
Checks the Title object to see if it is currently fakesigned. This ensures that both the TMD and Ticket are
fakesigned. For a description of fakesigning, refer to the fakesign() method.
Returns
-------
bool:
True if the Title is fakesigned, False otherwise.
See Also
--------
libWiiPy.title.title.Title.fakesign()
"""
if self.tmd.get_is_fakesigned and self.ticket.get_is_fakesigned():
return True
else:
return False

View File

@ -257,6 +257,27 @@ class TMD:
except OverflowError: except OverflowError:
raise Exception("An error occurred during fakesigning. TMD could not be fakesigned!") raise Exception("An error occurred during fakesigning. TMD could not be fakesigned!")
def get_is_fakesigned(self) -> bool:
"""
Checks the TMD object to see if it is currently fakesigned. For a description of fakesigning, refer to the
fakesign() method.
Returns
-------
bool:
True if the TMD is fakesigned, False otherwise.
See Also
--------
libWiiPy.title.tmd.TMD.fakesign()
"""
if self.signature != b'\x00' * 256:
return False
test_hash = hashlib.sha1(self.dump()[320:]).hexdigest()
if test_hash[:2] != '00':
return False
return True
def get_title_region(self) -> str: def get_title_region(self) -> str:
""" """
Gets the region of the TMD's associated title. Gets the region of the TMD's associated title.
@ -386,7 +407,7 @@ class TMD:
Returns Returns
------- -------
bool bool
Whether the flag is enabled. True if the flag is enabled, False otherwise.
""" """
return bool(self.access_rights & _bitmask(flag)) return bool(self.access_rights & _bitmask(flag))