Skip to content
TPM 2.0 Simulator Extraction Script
C Python C++ CMake
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
documents Updated script to support published TPM 2.0 Lib Spec version 1.38 Oct 15, 2017
scripts Updated script to support published TPM 2.0 Lib Spec version 1.38 Oct 15, 2017

TPM 2.0 Simulator Extraction Script

The purpose of this script is to extract the source code from the publicly available PDF versions 01.16 and 01.38 of the Trusted Platform Module Library Specification published by the Trusted Computing Group (TCG).

The result of the extraction scripts is a complete set of the source files for a Trusted Platform Module (TPM) 2.0 Simulator, which runs under Windows, Linux, as well as Genode (by applying the appropriate patches).

Note: The extraction script also works with a Microsoft Word-based FODT-version of the more recent specifications (e.g., version 01.19), which are however only available to TCG members.

License: The files of this project are licensed under BSD 2-Clause License (except where indicated otherwise).

User Instructions



Make sure the following packages are installed on your system:


Also install the python module "pyastyle" for formatted output:

pip install pyastyle

Extracting the source code

  1. Open a terminal and navigate to the project folder tpm2simulator

  2. Edit configuration settings in the file tpm2simulator/scripts/ (e.g., MANUFACTURER, VENDOR_STRING_1, and FIRMWARE_V1) and change SET = False to SET = True when finished

  3. Create a folder named build and run the following command inside:

    cmake -G "Unix Makefiles" ../cmake -DCMAKE_BUILD_TYPE=Debug -DSPEC_VERSION=116


    cmake -G "Unix Makefiles" ../cmake -DCMAKE_BUILD_TYPE=Debug -DSPEC_VERSION=138

    This command

    • runs the Python script to extract the simulator source code
    • patches files containing the source code
    • generates a Makefile used for building the simulator

Building and running the simulator

  1. Build the simulator
  1. Run the simulator:

(If there are any error messages at startup, restart the simulator)


In order to test if the simulator is working correctly, we use IBM's TPM 2.0 TSS

  1. Open a terminal and start the TPM simulator

  2. Open another terminal and navigate to the project folder ibmtpm20tss/utils

  3. Build the TSS:

  1. Run the tests:
./ -a


The following table shows which version of the TPM Simulator works with which version of the IBM's TPM 2.0 TSS.

Specification version Used document type TSS version Results
116 PDF 755 Working 1,2
116 PDF 996 Working 1,2,3
116 FODT 755 Working 1,2
116 FODT 996 Working 1,2,3
119 FODT 755 Working 1
119 FODT 996 Working 1,3
124 FODT 755 Working
124 FODT 996 Working 1,3
138 PDF 755 Working 4
138 PDF 996 Working 4
138 FODT 755 Working 4
138 FODT 996 Working 4

1: The option -116 has to be added to line 88 in /utils/regtests/

2: The policy tests (-18 for version 755 of the TSS, -21 for version 996 of the TSS) cannot be executed separately. They only work if they are executed with the other tests using the option -a (all) in the TSS.

3: The lines 66-68 in /utils/regtests/ have to be removed. Only the tests which are not for version 138 of the TPM specification can be executed (which tests are affected can be retrieved by calling the TSS with the help argument -h). The tests have to be executed separately by using the option -n$TESTNUMBER with the TSS.

4: The TSS fails when running it the first time, but not in any subsequent run. The clock test fails.


This project was created by Steffen Wagner (Fraunhofer AISEC).

Special thanks to Sergej Proskurin, Tamás Bakos, and Christoph Kowatsch for their support in implementing the script.

IBM's TPM 2.0 TSS was created by Ken Goldman and is licensed under the Berkeley Software Distribution (BSD) License. We'd like to thank Ken for implementing and providing a TSS that also includes test cases, which we could use to verify the extracted source code of the TPM 2.0 simulator.

pyastyle (created by Timon Wong, NHNCN) and Artistic Style (licensed under GNU Lesser General Public License version 3.0)

You can’t perform that action at this time.