seeddb - SeedDB management

The seeddb module handles seeds used for title encryption. This applies to digital games released after early 2015. Seeds were used to enable pre-purchasing and downloading titles before release without providing access to the actual contents before the release date.

When a CryptoEngine object is initialized, by default it will attempt to load a seeddb.bin using the paths defined in seeddb_paths.

File format

The SeedDB file consists of a seed count, then each entry has a Title ID and its associated seed.

seeddb.bin file format

Offset

Size

Data

0x0

0x4

Entry count in little endian (C)

0x4

0xC

Padding

0x10

(0x20 * C)

Entries

Entry

Offset

Size

Data

0x0

0x8

Title ID in little endian

0x8

0x10

Seed

0x18

0x8

Padding

Functions

pyctr.crypto.seeddb.load_seeddb(fp=None)[source]

Load a seeddb file.

Parameters:

fp (FilePathOrObject) – A file path or file-like object with the seeddb data.

pyctr.crypto.seeddb.get_seed(program_id, *, load_if_required=True)[source]

Get a seed for a Program ID.

Parameters:
  • program_id (Union[int, str, bytes]) – The Program ID to search for. If bytes is provided, the value must be little-endian.

  • load_if_required (bool) – Automatically load using load_seeddb() if the requested Program ID is not already available.

pyctr.crypto.seeddb.add_seed(program_id, seed)[source]

Adds a seed to the database.

Parameters:
  • program_id (Union[int, str, bytes]) – The Program ID associated with the seed. If bytes is provided, the value must be little-endian.

  • seed (Union[bytes, str]) – The seed to add.

pyctr.crypto.seeddb.get_all_seeds()[source]

Gets all the loaded seeds.

Returns:

A read-only view of the seed database.

pyctr.crypto.seeddb.save_seeddb(fp)[source]

Save the seed database to a seeddb file.

Parameters:

fp (FilePathOrObject) – A file path or file-like object to write the seeddb data to.

Data

pyctr.crypto.seeddb.seeddb_paths: Dict[int, bytes]

The list of paths that load_seeddb() will try to load from automatically. By default this is every path in pyctr.util.config_dirs with seeddb.bin. If the environment variable SEEDDB_PATH is set, its value is put at the beginning of the list.