wiithon.crypto.blocks module

wiithon.crypto.blocks.decrypt_block(block, title_key)[source]

Decrypt a single 0x8000-byte block

  • Extracts the IV at offset: 0x3D0 of the block header (16 bytes)

  • Decrypts the data section (0x400 to end) with AES-128-CBC

  • Returns the 0x7C00 bytes, decrypted

See: https://wiibrew.org/wiki/Wii_disc#Encrypted :type block: bytes :param block: Raw encrypted block :type title_key: bytes :param title_key: 16-byte title key

Return type:

bytes

Returns:

decrypted data (0x7C00)

Parameters:
wiithon.crypto.blocks.decrypt_group(group_data, title_key)[source]

Decrypt an entire group of 64 blocks. Iterates over all 64 blocks in the group, decrypt each one and concatenates

Parameters:
  • group_data (bytes) – Raw encrypted group

  • title_key (bytes) – 16-byte title key

Return type:

bytes

Returns:

Decrypted group

wiithon.crypto.blocks.encrypt_group(group_data, title_key, h3_ref=None)[source]

Hash and encrypt a full 2MB group Reference: https://wiibrew.org/wiki/Wii_disc#Encrypted

Parameters:
  • group_data (bytes | bytearray) – 2MB bytes/bytearray to be hashed and encrypted

  • title_key (bytes) – 16-byte decrypted title key

  • h3_ref (bytearray | None, default: None) – Optional bytearray of length 20 where the H3 hash will be stored

Return type:

bytes

Returns:

The encrypted 2MB data as bytes