TCTI

class tpm2_pytss.TCTI.PyTCTI(max_size=4096, magic=b'PYTCTI\x00\x00')[source]

Subclass for implementing a TCTI in Python.

Extend this object and implement the following methods:
  • def do_transmit(self, command: bytes) -> None

    This method transmits a command buffer to the TPM. This method IS REQUIRED.

  • def do_receive(self, timeout: int) -> bytes:

    This method receives a response from the TPM and returns it. This method IS REQUIRED

  • def do_cancel(self) -> None:

    Cancels an I/O operation with the TPM. This method is OPTIONAL.

  • def do_get_poll_handles(self) -> Optional[Tuple[PollData]]:

    Retrieves PollData objects from the TCTI used for async I/O. This method is OPTIONAL.

  • def do_set_locality(self, locality: int) -> None:

    Sets the locality in which to communicate with the TPM. This method is OPTIONAL.

  • def do_make_sticky(self, handle: int, is_sticky: bool) -> None:

    Makes a handle sticky to persist across client exits with an RM. This method is OPTIONAL.

  • def do_finalize(self) -> None:

    Finalizes a TCTI, this is analogous to close on a file. This method is OPTIONAL.

Note

All methods may throw exceptions as needed.

Parameters:
  • max_size (int) – The size of the response buffer for callers to allocate. Defaults to 4096.

  • magic (bytes) – The magic value for the TCTI, may aid in debugging. Max length is 8, defaults to b”PYTCTI"

Returns:

An instance of the PyTCTI class. It’s unusable as is, users should extend it.

do_cancel()[source]

Cancels an I/O operation with the TPM. This method is OPTIONAL.

Raises:
  • Exception – Implementations are free to raise any Exception. Exceptions are retained

  • across the native boundary.

do_finalize()[source]

Finalizes a TCTI, this is analogous to close on a file. This method is OPTIONAL.

Note: Native TCTIs do not return anything and thus cannot raise any errors. Python TCTIs MAY raise exceptions across this interface.

Raises:
  • Exception – Implementations are free to raise any Exception. Exceptions are retained

  • across the native boundary.

do_get_poll_handles()[source]

Retrieves PollData objects from the TCTI used for async I/O. This method is OPTIONAL.

Returns:

The tuple of PollData handles or None.

Raises:
  • Exception – Implementations are free to raise any Exception. Exceptions are retained

  • across the native boundary.

do_make_sticky(handle, is_sticky)[source]

Makes a handle sticky to persist across client exits with a Resource Manager. This method is OPTIONAL.

Note: A sticky object is one a RM doesn’t flush when the client closes their connection.

Parameters:
  • handle (int) – The TPM handle to make sticky.

  • is_sticky (bool) – True to make sticky, False to make it not sticky.

Raises:
  • Exception – Implementations are free to raise any Exception. Exceptions are retained

  • across the native boundary.

do_receive(timeout)[source]

This method receives a response from the TPM and returns it. This method IS REQUIRED.

Parameters:

timeout (int) – The timeout in milliseconds to wait for the TPM. Negative values mean wait indefinitely.

Raises:
  • NotImplementedError – If a subclass has not implemented this.

  • Exception – Implementations are free to raise any Exception. Exceptions are retained

  • across the native boundary.

do_set_locality(locality)[source]

Sets the locality in which to communicate with the TPM. This method is OPTIONAL.

Parameters:

locality (int) – The locality of communication with the TPM.

Raises:
  • Exception – Implementations are free to raise any Exception. Exceptions are retained

  • across the native boundary.

do_transmit(command)[source]

This method transmits a command buffer to the TPM. This method IS REQUIRED.

Parameters:

command (bytes) – The bytes to send to the TPM.

Raises:
  • NotImplementedError – If a subclass has not implemented this.

  • Exception – Implementations are free to raise any Exception. Exceptions are retained

  • across the native boundary.

class tpm2_pytss.TCTI.TCTI(ctx)[source]

Initialize a TCTI object.

Initialize a TCTI from a NATIVE instantiated TCTI.

Parameters:

ctx (ffi.CData) – A TSS2_TCTI_CONTEXT * variable. This would be returned from a TCTIs initialize or TCTILdr routine.

Returns:

An instance of a TCTI.

cancel(*args, **kwargs)[source]
finalize(*args, **kwargs)[source]
get_poll_handles(*args, **kwargs)[source]
property magic

Returns the MAGIC string of the TCTI.

Returns:

The magic byte string.

make_sticky(*args, **kwargs)[source]
receive(*args, **kwargs)[source]
set_locality(*args, **kwargs)[source]
transmit(*args, **kwargs)[source]
property version

Returns the VERSION number of the TCTI.

This is the TCTI interface version NOT the release version of the TCTI. Ie if it implements version 1 or version 2 of the spec.

Returns:

The TCTI version number.

class tpm2_pytss.TCTILdr.TCTILdr(name=None, conf=None)[source]
close()[source]
property conf
property name
property name_conf
classmethod parse(tcti_name_conf)[source]