wiithon.crypto.keys module

wiithon.crypto.keys.decrypt_title_key(encrypted_key, common_key_index, title_id)[source]

Decrypt the title key using the common key and title ID as IV

  • Build the IV: title_id (8 bytes) + 8 zero bytes

  • Select the right common key by index

  • Decrypt with AES-128-CBC

The resulting title key will be used to decrypt all data block in the partition :type encrypted_key: bytes :param encrypted_key: Encrypted title key :type common_key_index: int :param common_key_index: Common key index :type title_id: bytes :param title_id: Title ID

Return type:

bytes

Returns:

Decrypted title key

Parameters:
wiithon.crypto.keys.encrypt_title_key(decrypted_key, common_key_index, title_id)[source]

Encrypt the title key using the common key and title ID as IV

Parameters:
  • decrypted_key (bytes) – Decrypted title key

  • common_key_index (int) – Common key index

  • title_id (bytes) – Title ID

Return type:

bytes

Returns:

Decrypted title key

wiithon.crypto.keys.get_length_from_key_type(key_type)[source]

Return (key_size, exponent_size, padding_size) for a certificate key type

Used when reading/writing to know how many bytes to read/write and its padding

Parameters:

key_type (KeyType) – Key type from the certificate

Return type:

tuple[int, int, int]

Returns:

Tuple (key_size, exponent_size, padding_size)