Skip to content

Commit

Permalink
docs: start types documentation
Browse files Browse the repository at this point in the history
Signed-off-by: William Roberts <william.c.roberts@intel.com>
  • Loading branch information
William Roberts committed Dec 1, 2021
1 parent 9dfdf52 commit 8a732fb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ to change.
:maxdepth: 2
:caption: Contents:

types
esys
fapi
utils
Expand Down
6 changes: 6 additions & 0 deletions docs/types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Types
=====

.. automodule:: tpm2_pytss.types
:members:
:undoc-members:
28 changes: 28 additions & 0 deletions tpm2_pytss/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# SPDX-License-Identifier: BSD-2
"""
The types module contains types for each of the corresponding TPM types from the TCG TSS specification
- https://trustedcomputinggroup.org/resource/tss-overview-common-structures-specification
The classes contained within can be initialized based on named argument value pairs or dictionaries
of key-value objects where the keys are the names of the associated type.
"""
from ._libtpm2_pytss import ffi, lib

from tpm2_pytss.internal.utils import (
Expand Down Expand Up @@ -40,14 +47,20 @@


class ParserAttributeError(Exception):
""" Exception ocurred when when parsing."""

pass


class TPM2_HANDLE(int):
""""A handle to a TPM address"""

pass


class TPM_OBJECT(object):
""" Abstract Base class for all TPM Objects. Not suitable for direct instantiation."""

def __init__(self, _cdata=None, **kwargs):

# Rather than trying to mock the FFI interface, just avoid it and return
Expand Down Expand Up @@ -197,6 +210,9 @@ def unmarshal(cls, buf):


class TPM2B_SIMPLE_OBJECT(TPM_OBJECT):
""" Abstract Base class for all TPM2B Simple Objects. A Simple object contains only
a size and byte buffer fields. This is not suitable for direct instantiation."""

def __init__(self, _cdata=None, **kwargs):

_cdata, kwargs = _fixup_cdata_kwargs(self, _cdata, kwargs)
Expand Down Expand Up @@ -274,6 +290,15 @@ def __eq__(self, value):


class TPML_Iterator(object):
""" Iterator class for iterating over TPML data types.
This class is used in enumerated for loops, such as:
.. code-block:: python
for alg in TPML_ALG:
do_something(alg)
"""

def __init__(self, tpml):
self._tpml = tpml
self._index = 0
Expand All @@ -292,6 +317,9 @@ def __next__(self):


class TPML_OBJECT(TPM_OBJECT):
""" Abstract Base class for all TPML Objects. A TPML object is an object that
contains a list of objects. This is not suitable for direct instantiation."""

def __init__(self, _cdata=None, **kwargs):

_cdata, kwargs = _fixup_cdata_kwargs(self, _cdata, kwargs)
Expand Down

0 comments on commit 8a732fb

Please sign in to comment.