Skip to contentSkip to conversation

TPM2 TSS Python Bindings: Update, Request for Naming Ideas, Further Abstraction?

tpm2 Andersen 2 participants 4 messages Jul 9, 2019 – Jul 15, 2019

lore
Share & tools
lore

Andersen

#0 lore raw

TPM2 TSS Python Bindings: Update, Request for Naming Ideas, Further Abstraction?
================================================================================

Update
------

We've switched over to using swig (a move that it sounds like @AndreasFuchsSIT and @tstruk had discussed, and @tstruk implemented). We've successfully packaged it into a setuptools package which we can upload to PyPi (Pythons package management system).

TODO's are still the same as they were, packaging was hard. It sounds like we'll be releasing this as a separate repo (tpm2-software/tpm2-pyesys or something, I'd like to get ideas and votes on names (below).

We've re-used the CI setup from the tools repo, aka the docker setup. My plan now is to start re-writing some of the integration tests that are present in the TSS repo using the Python bindings.

Since we're releasing this as a separate repo the name has to get cleared by our legal dept. and we have to go through some other internal processes. So code might not be in the open for a bit. But I'll keep you all up to date as things progress.

TODOs
~~~~~
- Add Support for TCTIs (via a libtss2-tcti or libpytpm2tss, depending on what comes first)
- Add documentation
- Add more integration and/or unit testing
- Code review

Naming
------

Options so far (please add suggestions if you have any):
- tpm2-pyesys
- pytss_esys
- pytpm2tss

Further Abstraction?
--------------------

We need to decide if we want to provide a straight wrapper or abstract into a
more pythonic interface (similar to what @AndreasFuchsSIT did with his classes
in PR 1248: https://github.com/tpm2-software/tpm2-tss/blob/1af543f2cc1ba44af66a6279eca5473864e7bfc9/bindings/python/pytpm2tss/__init__.py#L65-L81).

So, should the API be a 1:1 mapping to the ESYS API in TSS or should we provide a layer of abstraction above that. We could of course do this after the initial release of the Python bindings, but we need to decide if we want to, and then when we want to time wise. As that will obviously take more time to implement, validate, and agree upon.

Thanks,
John

#1 lore raw

The ESYS spec was written intentionally with bindings OO-languages in mind. That's why we follow the naming convention of GObject for function names to begin with. Unfortunately, we had to carry around the context everywhere as well, but that can be removed.
Thus, I'd vode for "more abstract" with classes.

Regarding tcti: I think it should be sufficient to provide bindings for the tctildr library. I even wanted to go as far as to included it with names optional parameters directly into the Esys_Initialize call.

Great to see the work be picked up !

________________________________________
From: tpm2 [tpm2-bounces(a)lists.01.org] on behalf of Andersen, John [john.s.andersen(a)intel.com]
Sent: Wednesday, July 10, 2019 00:59
To: tpm2(a)lists.01.org
Subject: [tpm2] TPM2 TSS Python Bindings: Update, Request for Naming Ideas, Further Abstraction?

TPM2 TSS Python Bindings: Update, Request for Naming Ideas, Further Abstraction?
================================================================================

Update
------

We've switched over to using swig (a move that it sounds like @AndreasFuchsSIT and @tstruk had discussed, and @tstruk implemented). We've successfully packaged it into a setuptools package which we can upload to PyPi (Pythons package management system).

TODO's are still the same as they were, packaging was hard. It sounds like we'll be releasing this as a separate repo (tpm2-software/tpm2-pyesys or something, I'd like to get ideas and votes on names (below).

We've re-used the CI setup from the tools repo, aka the docker setup. My plan now is to start re-writing some of the integration tests that are present in the TSS repo using the Python bindings.

Since we're releasing this as a separate repo the name has to get cleared by our legal dept. and we have to go through some other internal processes. So code might not be in the open for a bit. But I'll keep you all up to date as things progress.

TODOs
~~~~~
- Add Support for TCTIs (via a libtss2-tcti or libpytpm2tss, depending on what comes first)
- Add documentation
- Add more integration and/or unit testing
- Code review

Naming
------

Options so far (please add suggestions if you have any):
- tpm2-pyesys
- pytss_esys
- pytpm2tss

Further Abstraction?
--------------------

We need to decide if we want to provide a straight wrapper or abstract into a
more pythonic interface (similar to what @AndreasFuchsSIT did with his classes
in PR 1248: https://github.com/tpm2-software/tpm2-tss/blob/1af543f2cc1ba44af66a6279eca5473864e7bfc9/bindings/python/pytpm2tss/__init__.py#L65-L81).

So, should the API be a 1:1 mapping to the ESYS API in TSS or should we provide a layer of abstraction above that. We could of course do this after the initial release of the Python bindings, but we need to decide if we want to, and then when we want to time wise. As that will obviously take more time to implement, validate, and agree upon.

Thanks,
John
_______________________________________________
tpm2 mailing list
tpm2(a)lists.01.org
https://lists.01.org/mailman/listinfo/tpm2

#2 lore raw
Quoted 5 lines · Andreas

The ESYS spec was written intentionally with bindings OO-languages in mind. That's why we follow the naming convention of GObject for function names to begin with. Unfortunately, we had to carry around the context everywhere as well, but that can be removed.
Thus, I'd vode for "more abstract" with classes.

Yes, please. As a Python developer, you usually do not want to deal with all the complexity of a C API, when you are used to much nicer interfaces :)

Alexander

#3 lore raw
In reply to Andersen
Quoted 5 lines · John

Update
------

We've switched over to using swig (a move that it sounds like @AndreasFuchsSIT and @tstruk had discussed, and @tstruk implemented).

Was there a specific reason to choose SWIG over any of the other ways to plug C libraries into Python? Nowdays, I'd say the gold standard for that is CFFI (https://cffi.readthedocs.io/), not only because it is easy to use for Python/C developers, but also because it avoids the CPython C API (https://docs.python.org/3/extending/extending.html), thus giving better compatibility and excellent performance on alternative interpreters, such as PyPy.

Quoted 7 lines

Naming
------

Options so far (please add suggestions if you have any):
- tpm2-pyesys
- pytss_esys
- pytpm2tss

Out of these options, I'd choose pytpm2tss. Or perhaps the even more generic pytpm2. As a developer, I don't care whether my library internally uses the SAPI, ESAPI or FAPI. I simply want it to "do stuff with the TPM", which is just what the name reflects. Also, this allows to write nice code like "import pytpm2; pytpm2.do_stuff()". (You cannot do that with tpm2-pyesys because of the "-". pytss_esys would work, but is longer and consists almost entirely of acronyms that nobody not intimately familiar with the TPM ecosystem knows.)

Alexander