Trusted Platform Module (TPM)
In this laboratory, we will explore the security implications related to how to use a TPM by using a SW TPM. You will explore how to use parts of such engine. Obiouvsly, this will be limited in its depth as the SW solution is quite limited. However, the commands used would be the same even if a TPM would have been used.
Preparation tasks
We are going to use a SW TPM, as seen in the course. To be precise, we are using the Software TPM Emulator created by Stefan Berger and David Safford at IBM and hosted under https://github.com/stefanberger/swtpm.git. The detailed information about the solution can be found under https://deepwiki.com/stefanberger/swtpm/1-swtpm-overview.
An alternative TPM solution is https://sourceforge.net/projects/ibmswtpm2/.
The overall usage follows the following diagram:

Main roles:
- VSC-Docker Container : what you have been using to compile
buildroot - tpm-ubuntu Container : a new container that you will install following the steps below.
Info
Once the container with the SW TPM (tpm-ubuntu) is installed, you will interact with it from the VSC-Docker container. You may be obviously interact with it from elsewhere, but the exercice assumes you have the tools installed as in VSC-Docker.
1. New “SW TPM” .devcontainer
We have provided you with a new .devcontainer that launches a SW-based TPM.
In order to do so, you should
- copy the following to your computer by cloning the repository
git clone --filter=blob:none --no-checkout https://github.com/MA-SeS/resources.git tpm_docker
cd tpm_docker
git sparse-checkout init --cone
git sparse-checkout set tpm_docker
git checkout
-
open the
.devcontainerin Visual Studio Code so that the image gets built and the container startedNote
Note: it is going to take some time to do so…
-
once up and running, in a shell, enter the command
swtpm socket --tpmstate dir=/tpm2/tpm --tpm2 --server type=tcp,port=2321,bindaddr=0.0.0.0 --ctrl type=tcp,port=2322,bindaddr=0.0.0.0 --flags not-need-init,startup-clear
2. On the available buildroot .devcontainer
From within the container you have been using for building buildroot, issue
apt install tpm2-toolsto install the necessary libraryexport TPM2TOOLS_TCTI="swtpm:host=HOST_IP_ADDRESS", whereHOST_IP_ADDRESSis the IP address of your the host (not the container)- test that it all works smoothly with
tpm2_getcap -l. You should get
- algorithms
- commands
- pcrs
- properties-fixed
- properties-variable
- ecc-curves
- handles-transient
- handles-persistent
- handles-permanent
- handles-pcr
- handles-nv-index
- handles-loaded-session
- handles-saved-session
If not, one would get something like
tpm2_getcap -l
ERROR:tcti:src/tss2-tcti/tcti-swtpm.c:192:tcti_control_command() Failed to get response to control command, errno 2: No such file or directory
ERROR:tcti:src/tss2-tcti/tcti-swtpm.c:342:tcti_swtpm_set_locality() Failed to set locality: 0xa000a
WARNING:tcti:src/tss2-tcti/tcti-swtpm.c:622:Tss2_Tcti_Swtpm_Init() Could not set locality via control channel: 0xa000a
ERROR:tcti:src/tss2-tcti/tctildr-dl.c:154:tcti_from_file() Could not initialize TCTI file: swtpm
ERROR:tcti:src/tss2-tcti/tctildr.c:428:Tss2_TctiLdr_Initialize_Ex() Failed to instantiate TCTI
ERROR: Could not load tcti, got: "swtpm:host=1.2.3.4"
Warning
If you change the IP address (say, you went home after the course), do remember to update HOST_IP_ADDRESS.
Questions
For all questions you are asked to execute the expected steps and record the commands you used for doing so as well as the resulting outcome.
Important
You will face issues with the small number of objects (only 3) you can hold in the RAM (transient area), make sure that :
- you consider using the NVRAM (persistent) storage
- write down the commands used for this and getting around the limitation
Question 1
-
Create primary key in owner hierarchy using key parameter: RSA 2048 bits
-
Check and report the handles-transient, handles-persistent areas
-
Flush the handle-transient area
-
Save the primary key to the NVRAM
-
Check the handles-transient, handles-persistent areas
Question 2
-
Create a child key in the owner hierarchy with the key parameter: RSA 2048 bits
-
Check and report the handles-transient, handles-persistent areas
-
Flush the handle-transient area
-
Save the child key to the NVRAM
-
Check and report the handles-transient, handles-persistent areas
Question 3
Although u-boot has not integrated TPM in the version used, the goal of this
question is to simulate on your PC how u-boot can integrate the TPM in order
to check the Linux kernel integrity.
Namely :
-
With the
tpm2commands and created, dedicated graphics, simulate howu-bootshoud check the Linux kernel integrity with PCR registers andprcpolicy. -
With the
tpm2commands and created, dedicated graphics, simulate how it is possible to install a new Linux kernel and update PCR registers andprcpolicy.
Info
Assume the name of the Linux kernel to be
vmlinuz and vmlinuz.new for the
new kernel to install.
Question 4
- Make sure to add to the report also the question related to IEC 62443 question.