TPM 2.0 TSS Bindings for Python
Reason this release was yanked:
Outdated and broken, use master
Project description
tpm2-pytss
TPM2 TSS Python bindings for Enhanced System API (ESYS).
Supported versions of Python are
- 3.5
- 3.6
- 3.7
- 3.8
Features
We support the FAPI, ESAPI, and marshalling library.
Dependencies
This has been tested against TPM2 TSS 2.4.0, SWIG 3 and SWIG 4.
tpm2-tss
You need to install tpm2-tss prior to installing this, INSTALL.md.
pkg-config
You need to install pkg-config
swig
You need to install swig
Ubuntu
$ sudo apt-get -y install swig pkg-config
ldconfig
When you ran ./configure
for tpm2-tss if you didn't supply a prefix it usually
defaults to /usr/local/
. When you ran make install
it then installed the
libraries under that path. Your pacakge manager usually installs libraries to
/usr
. If you properly configure the ldconfig
tool, it'll make the libraries
you just installed available from within /usr/local
(which means they won't
clash with things your package manager installs). If you don't configure it then
you might get this error:
ImportError: libtss2-esys.so.0: cannot open shared object file: No such file or directory
We make a config file that tells ldconfig
to look in /usr/local/lib
for
shared libraries, then we run ldconfig
.
$ sudo mkdir -p /etc/ld.so.conf.d/
$ echo 'include /etc/ld.so.conf.d/*.conf' | sudo tee -a /etc/ld.so.conf
$ echo '/usr/local/lib' | sudo tee -a /etc/ld.so.conf.d/libc.conf
$ sudo ldconfig
More info on ldconfig error: https://stackoverflow.com/a/17653893/3969496
Install
Install from PyPi.
$ python3 -m pip install tpm2-pytss
Or install from the Git repo
$ git clone --depth 1 --recurse-submodules -b ${TPM2_PYTSS_VERSION} \
https://github.com/tpm2-software/tpm2-pytss
$ cd tpm2-pytss
$ python3 -m pip install -e .
Examples
See tests/
folder for example usage.
Testing
You need to have tpm_server
installed in your path to run the tests.
Download the latest version from https://sourceforge.net/projects/ibmswtpm2/files/
and put it somewher in your $PATH
.
$ python3 setup.py test
Logging
To get traces of all calls into the TSS, use the TPM2_PYTSS_LOG_LEVEL
environment variable.
$ export TPM2_PYTSS_LOG_LEVEL=debug
Example logs:
test_random_length (tests.test_esys_get_random.TestGetRandom) ... DEBUG:asyncio:Using selector: EpollSelector
DEBUG:tpm2_pytss.util.swig:Tss2_TctiLdr_Initialize_Ex(
name: mssim,
conf: port=63684,
context: <Swig Object of type 'TSS2_TCTI_CONTEXT **' at 0x7f5e63d8ea50>,
)
DEBUG:tpm2_pytss.util.swig:new_ctx_ptr(
)
DEBUG:tpm2_pytss.util.swig:Esys_Initialize(
esys_context: <Swig Object of type 'ESYS_CONTEXT **' at 0x7f5e63d8e9f0>,
tcti: <Swig Object of type 'TSS2_TCTI_CONTEXT *' at 0x7f5e63d8e5d0>,
abiVersion: <tpm2_pytss.binding.TSS2_ABI_VERSION; proxy of <Swig Object of type 'TSS2_ABI_VERSION *' at 0x7f5e6337ab10> >,
)
DEBUG:tpm2_pytss.util.swig:ctx_ptr_value(
obj: <Swig Object of type 'ESYS_CONTEXT **' at 0x7f5e63d8e9f0>,
)
DEBUG:tpm2_pytss.util.swig:Esys_Startup(
esysContext: <Swig Object of type 'ESYS_CONTEXT *' at 0x7f5e63d8e7e0>,
startupType: 0,
)
DEBUG:tpm2_pytss.util.swig:Esys_SetTimeout(
esys_context: <Swig Object of type 'ESYS_CONTEXT *' at 0x7f5e63d8e7e0>,
timeout: -1,
)
DEBUG:tpm2_pytss.util.swig:Esys_GetRandom(
esysContext: <Swig Object of type 'ESYS_CONTEXT *' at 0x7f5e63d8e7e0>,
shandle1: 4095,
shandle2: 4095,
shandle3: 4095,
bytesRequested: 11,
randomBytes: <Swig Object of type 'TPM2B_NONCE **' at 0x7f5e63d8e8d0>,
)
DEBUG:tpm2_pytss.util.swig:Esys_Finalize(
context: <Swig Object of type 'ESYS_CONTEXT **' at 0x7f5e63d8e9f0>,
)
DEBUG:tpm2_pytss.util.swig:delete_ctx_ptr(
obj: <Swig Object of type 'ESYS_CONTEXT **' at 0x7f5e63d8e9f0>,
)
Contributing
- See HACKING
TODO
- Document need for ctypes for certain values, example
ESYS_TR_PTR
should beSessionContext
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file tpm2-pytss-0.1.3.tar.gz
.
File metadata
- Download URL: tpm2-pytss-0.1.3.tar.gz
- Upload date:
- Size: 615.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9c21368275a0e058424131b03acb67d914c0f2419cccc66a4a1c0d9706a05b9 |
|
MD5 | dbd5cebc0a5002cd79978b2e23e7adaa |
|
BLAKE2b-256 | 698edaac67e589e43454fb56393009c9d8d41bbff4ce75e057fc330ca6cdfaa4 |