Skip to content

Commit 884294d

Browse files
authored
Merge pull request #424 from dgarske/swtpm_docs2
Added TCG TPM to the SWTPM documentation
2 parents 22b324f + c09418d commit 884294d

File tree

1 file changed

+56
-54
lines changed

1 file changed

+56
-54
lines changed

docs/SWTPM.md

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,91 @@
11
# wolfTPM with Software Simulator (SWTPM) support
22

3-
wolfTPM is to be able to interface with software TPM (SW TPM) interfaces defined by section D.3 of [TPM-Rev-2.0-Part-4-Supporting-Routines-01.38-code](https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-4-Supporting-Routines-01.38-code.pdf)
3+
wolfTPM is to be able to use Software TPM (SW TPM) defined by section D.3 of [TPM-Rev-2.0-Part-4-Supporting-Routines-01.38-code](https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-4-Supporting-Routines-01.38-code.pdf)
44

5-
The SWTPM interface is not compatible with TIS or devtpm (/dev/tpm0). Transport is a socket connection by default, but can also be a UART.
5+
Software TPM implementations tested:
6+
* [Official TCG Reference](https://github.com/TrustedComputingGroup/TPM): Reference code from the specification maintained by TCG [build steps](#tcg-tpm)
7+
* [IBM / Ken Goldman](https://github.com/kgoldman/ibmswtpm2): Fork of reference code maintained by IBM [build steps](#ibmswtpm2)
8+
* [Microsoft](https://github.com/microsoft/ms-tpm-20-ref): Fork of reference code maintained by Microsoft (93% identical to official TCG) [build steps](#ms-tpm-20-ref)
9+
* [Stefan Berger](https://github.com/stefanberger/swtpm): Uses libtpms front end interfaces. [build steps](#swtpm)
610

7-
This implementation only uses the TPM command interface typically on port 2321. It does not support the Platform interface typically on port 2322.
11+
The software TPM transport is a socket connection by default, but we also support a UART.
812

9-
Software TPM implementations tested:
10-
* https://github.com/kgoldman/ibmswtpm2 or https://sourceforge.net/projects/ibmswtpm2/files/
11-
* https://github.com/microsoft/ms-tpm-20-ref
12-
* https://github.com/stefanberger/swtpm
13+
This implementation only uses the TPM command interface typically on port 2321. It does not support the Platform interface typically on port 2322.
1314

14-
## Building SW TPM support
15+
## wolfTPM SWTPM support
1516

16-
By default a socket transport will be used.
17+
To enable the socket transport for SWTPM use `--enable-swtpm`. By default all software TPM simulators use TCP port 2321.
1718

1819
```sh
1920
./configure --enable-swtpm
2021
make
2122
```
2223

23-
### Build SW TPM with UART transport
24+
Note: It is not possible to enable more than one transport interface at a time. If building with SWTPM socket interface the built-in TIS and devtpm (/dev/tpm0) interfaces are not available.
2425

25-
```sh
26-
./configure --enable-swtpm=uart
27-
make
28-
```
29-
30-
## Build Options
26+
Build Options:
3127

3228
* `WOLFTPM_SWTPM`: Use socket transport (no TIS layer)
33-
* `TPM2_SWTPM_HOST`: The serial device to use (default=/dev/ttyS0)
34-
* `TPM2_SWTPM_PORT`: The baud rate (default=115200)
35-
* `WOLFTPM_SWTPM_UART`: Use UART transport (no TIS layer)
29+
* `TPM2_SWTPM_HOST`: The socket host (default is localhost)
30+
* `TPM2_SWTPM_PORT`: The socket port (default is 2321)
31+
32+
## Using a SWTPM
33+
34+
### SWTPM Power Up and Startup
3635

37-
## SWTPM simulator setup
36+
The TCG TPM and Microsoft ms-tpm-20-ref implementations require sending power up and startup commands on the platform interface before the command interface is enabled. You can use these commands to issue the required power up and startup:
3837

39-
### Xilinx UART
38+
```sh
39+
echo -ne "\x00\x00\x00\x01" | nc 127.0.0.1 2322
40+
echo -ne "\x00\x00\x00\x0B" | nc 127.0.0.1 2322
41+
```
4042

41-
Alternatively for raw API calls with Xilinx
43+
### TCG TPM
4244

4345
```sh
44-
./cofnigure --enable-swtpm=uartns550
46+
clone [email protected]:TrustedComputingGroup/TPM.git
47+
cd TPM
48+
cd TPMCmd
49+
./bootstrap
50+
./configure
4551
make
4652
```
4753

48-
## Build Options
54+
Run with: `./Simulator/src/tpm2-simulator`
4955

50-
* `WOLFTPM_SWTPM`: Use socket transport (no TIS layer)
51-
* `TPM2_SWTPM_PORT`: Used as the default baud rate (default=115200)
52-
* `TPM2_SWTPM_HOST`: The device to connect with (default=XPAR_MB0_AXI_UART16550_2_DEVICE_ID)
53-
* `WOLFTPM_SWTPM_UARTNS550`: Use Xilinx UART transport (no TIS layer)
56+
Run power on and self test. See [SWTPM Power Up and Startup](#swtpm-power-up-and-startup).
5457

5558
### ibmswtpm2
5659

57-
Checkout and Build
60+
Build steps:
61+
5862
```sh
5963
git clone https://github.com/kgoldman/ibmswtpm2.git
6064
cd ibmswtpm2/src/
6165
make
6266
```
6367

64-
Running:
65-
```sh
66-
./tpm_server -rm
67-
```
68+
Run with: `./tpm_server`
69+
70+
Note: You can use the `-rm` switch to remove the cache file NVChip. Alternatively you can delete the NVChip file (`rm NVChip`)
6871

69-
The rm switch is optional and remove the cache file NVChip. Alternately you can `rm NVChip`
7072

7173
### ms-tpm-20-ref
7274

75+
Build steps:
76+
7377
```sh
7478
git clone https://github.com/microsoft/ms-tpm-20-ref
7579
cd ms-tpm-20-ref/TPMCmd
7680
./bootstrap
7781
./configure
7882
make
79-
./Simulator/src/tpm2-simulator
8083
```
8184

82-
In another terminal power on ms-tpm-20-ref and start NV
85+
Run with: `./Simulator/src/tpm2-simulator`
86+
87+
Run power on and self test. See [SWTPM Power Up and Startup](#swtpm-power-up-and-startup).
8388

84-
```sh
85-
echo -ne "\x00\x00\x00\x01" | nc 127.0.0.1 2322 | exit
86-
echo -ne "\x00\x00\x00\x0B" | nc 127.0.0.1 2322 | exit
87-
```
8889

8990
### swtpm
9091

@@ -125,16 +126,6 @@ mkdir -p /tmp/myvtpm
125126
swtpm socket --tpmstate dir=/tmp/myvtpm --tpm2 --ctrl type=tcp,port=2322 --server type=tcp,port=2321 --flags not-need-init
126127
```
127128

128-
## Running examples
129-
130-
```sh
131-
./examples/pcr/extend
132-
./examples/wrap/wrap_test
133-
```
134-
135-
See `README.md` for more examples
136-
137-
138129
### swtpm with QEMU
139130

140131
This demonstrates using wolfTPM in QEMU to communicate using the linux
@@ -145,7 +136,7 @@ method to build. You may need to consult the instructions for
145136
and
146137
[swtpm](https://github.com/stefanberger/swtpm/wiki#compile-and-install-on-linux)
147138

148-
```
139+
```sh
149140
PREFIX=$PWD/inst
150141
git clone [email protected]:stefanberger/libtpms.git
151142
cd libtpms/
@@ -163,7 +154,7 @@ You can setup a basic linux installation. Other installation bases can
163154
be used. This step will take some time to install the base linux
164155
system.
165156

166-
```
157+
```sh
167158
# download mini install image
168159
curl -O http://archive.ubuntu.com/ubuntu/dists/bionic-updates/main/installer-amd64/current/images/netboot/mini.iso
169160
# create qemu image file
@@ -183,7 +174,7 @@ qemu-system-x86_64 -m 1024 -boot d -bios bios-256k.bin -boot menu=on \
183174
Once a base system is installed it's ready to start the qemu and build
184175
wolfSSL and wolfTPM in the qemu instance.
185176

186-
```
177+
```sh
187178
# start swtpm again
188179
$PREFIX/bin/swtpm socket --tpm2 --tpmstate dir=$PREFIX/mytpm \
189180
--ctrl type=unixio,path=$PREFIX/mytpm/swtpm-sock --log level=20 &
@@ -196,7 +187,7 @@ qemu-system-x86_64 -m 1024 -boot d -bios bios-256k.bin -boot menu=on \
196187

197188
To build checkout and build wolfTPM, in the QEMU terminal
198189

199-
```
190+
```sh
200191
sudo apt install automake libtool gcc git make
201192

202193
# get and build wolfSSL
@@ -219,3 +210,14 @@ popd
219210

220211
You can now run the examples such as `sudo ./examples/wrap/wrap`
221212
within QEMU. Using `sudo` maybe required for access to `/dev/tpm0`.
213+
214+
215+
## Running examples
216+
217+
```sh
218+
./examples/wrap/caps
219+
./examples/pcr/extend
220+
./examples/wrap/wrap_test
221+
```
222+
223+
See [examples/README.md](../examples/README.md) for additional example usage.

0 commit comments

Comments
 (0)