pyctr.type.save.common module

exception pyctr.type.save.common.PartitionContainerError[source]

Bases: PyCTRError

Generic error for partition container operations.

exception pyctr.type.save.common.InvalidPartitionContainerError[source]

Bases: PartitionContainerError

There is an error with the header, such as a missing magic.

exception pyctr.type.save.common.CorruptPartitionError[source]

Bases: PartitionContainerError

A hash somewhere in the header is incorrect.

class pyctr.type.save.common.PartitionContainerBase(file, mode='rb', *, fs=None, closefd=None, crypto=None, dev=False, cmac_base=None, sd_key_file=None, sd_key=None)[source]

Bases: TypeReaderCryptoBase

Base class for the DISA and DIFF classes.

This object is not to be manually created. Please use the DISA or DIFF classes.

Parameters:
  • file (FilePathOrObject) – A file path or a file-like object with the DISA or DIFF data.

  • mode (ReadWriteBinaryFileModes) – Mode to open the file with, passed to open. Only used if a file path was given.

  • closefd (bool | None) – Close the underlying file object when closed. Defaults to True for file paths, and False for file-like objects.

  • crypto (CryptoEngine) – A custom CryptoEngine object to be used. Defaults to None, which causes a new one to be created.

  • dev (bool) – Use devunit keys.

  • cmac_base (CMACTypeBase) – A CMACTypeBase object that describes how to update the CMAC.

  • sd_key_file (FilePath) – Path to a movable.sed file to load the SD KeyY from.

  • sd_key (bytes) – SD KeyY to use. Has priority over sd_key_file if both are specified.

  • fs (FS | None)

partitions: dict[int, Partition]

Partitions of the file. Only 0 exists for DIFF, while 0 and 1 can exist with DISA.