Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,19 @@ AC_ARG_ENABLE([swtpm],
[ ENABLED_SWTPM=no ]
)

if test "x$ENABLED_SWTPM" = "xyes"
if test "x$ENABLED_SWTPM" != "xno"
then
if test "x$ENABLED_DEVTPM" = "xyes"
then
AC_MSG_ERROR([Cannot enable both swtpm and devtpm])
fi

AM_CFLAGS="$AM_CFLAGS -DWOLFTPM_SWTPM"

if test "x$ENABLED_SWTPM" = "xuart"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFTPM_SWTPM_UART"
fi
fi

# Windows TBS device Support
Expand All @@ -249,7 +254,7 @@ AC_ARG_ENABLE([winapi],

if test "x$ENABLED_WINAPI" = "xyes"
then
if test "x$ENABLED_DEVTPM" = "xyes" -o "x$ENABLED_SWTPM" = "xyes"
if test "x$ENABLED_DEVTPM" = "xyes" -o "x$ENABLED_SWTPM" != "xno"
then
AC_MSG_ERROR([Cannot enable swtpm or devtpm with windows API])
fi
Expand Down Expand Up @@ -387,7 +392,7 @@ AC_ARG_ENABLE([hal],
[ ENABLED_EXAMPLE_HAL=$enableval ],
[ ENABLED_EXAMPLE_HAL=yes ]
)
if test "x$ENABLED_EXAMPLE_HAL" = "xyes"
if test "x$ENABLED_EXAMPLE_HAL" = "xyes" || test "x$ENABLED_MMIO" = "xyes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFTPM_EXAMPLE_HAL"
fi
Expand Down Expand Up @@ -420,12 +425,12 @@ AM_CONDITIONAL([BUILD_ST], [test "x$ENABLED_ST" = "xyes"])
AM_CONDITIONAL([BUILD_MICROCHIP], [test "x$ENABLED_MICROCHIP" = "xyes"])
AM_CONDITIONAL([BUILD_INFINEON], [test "x$ENABLED_INFINEON" != "xno"])
AM_CONDITIONAL([BUILD_DEVTPM], [test "x$ENABLED_DEVTPM" = "xyes"])
AM_CONDITIONAL([BUILD_SWTPM], [test "x$ENABLED_SWTPM" = "xyes"])
AM_CONDITIONAL([BUILD_SWTPM], [test "x$ENABLED_SWTPM" != "xno"])
AM_CONDITIONAL([BUILD_WINAPI], [test "x$ENABLED_WINAPI" = "xyes"])
AM_CONDITIONAL([BUILD_NUVOTON], [test "x$ENABLED_NUVOTON" = "xyes"])
AM_CONDITIONAL([BUILD_CHECKWAITSTATE], [test "x$ENABLED_CHECKWAITSTATE" = "xyes"])
AM_CONDITIONAL([BUILD_AUTODETECT], [test "x$ENABLED_AUTODETECT" = "xyes"])
AM_CONDITIONAL([BUILD_HAL], [test "x$ENABLED_EXAMPLE_HAL" = "xyes" || test "x$ENABLED_MMIO" = "xyes"])
AM_CONDITIONAL([BUILD_HAL], [test "x$ENABLED_EXAMPLE_HAL" = "xyes"])


CREATE_HEX_VERSION
Expand Down
75 changes: 51 additions & 24 deletions docs/SWTPM.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,92 @@
# Using wolfTPM with SWTPM
# wolfTPM with Software Simulator (SWTPM) support

wolfTPM is to be able to interface with 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)
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)

Using the socket connection for SWTPM is exclusive and not compatible
with TIS or devtpm.
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.

Only a subset of functionality is implemented to support testing of
wolfTPM. The platform requests are not used by wolfTPM.
This implementation only uses the TPM command interface typically on port 2321. It does not support the Platform interface typically on port 2322.

Two implementations were used in testing:

* https://sourceforge.net/projects/ibmswtpm2/files/
Software TPM implementations tested:
* https://github.com/kgoldman/ibmswtpm2 or https://sourceforge.net/projects/ibmswtpm2/files/
* https://github.com/microsoft/ms-tpm-20-ref
* https://github.com/stefanberger/swtpm

## Building with SW TPM support
## Building SW TPM support

```
By default a socket transport will be used.

```sh
./configure --enable-swtpm
make
```

### Build SW TPM with UART transport

```sh
./configure --enable-swtpm=uart
make
```

## Build Options

* `WOLFTPM_SWTPM`: Use socket transport (no TIS layer)
* `TPM2_SWTPM_HOST`: The host TPM address (default=localhost)
* `TPM2_SWTPM_PORT`: The socket port (default=2321)
* `WOLFTPM_SWTPM_UART`: Use UART transport (no TIS layer)


## SWTPM simulator setup

### ibmswtpm2

Checkout and Build
```
```sh
git clone https://github.com/kgoldman/ibmswtpm2.git
cd ibmswtpm2/src/
make
```

Running:
```
```sh
./tpm_server -rm
```

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

### ms-tpm-20-ref

```sh
git clone https://github.com/microsoft/ms-tpm-20-ref
cd ms-tpm-20-ref
./bootstrap
./configure
make
./Simulator/src/tpm2-simulator
```

### swtpm

Build libtpms

```
```sh
git clone git@github.com:stefanberger/libtpms.git
(cd libtpms && ./autogen.sh --with-tpm2 --with-openssl --prefix=/usr && make install)
cd libtpms
./autogen.sh --with-tpm2 --with-openssl --prefix=/usr
make install
```

Build swtpm

```
```sh
git clone git@github.com:stefanberger/swtpm.git
(cd swtpm && ./autogen.sh && make install)
cd swtpm
./autogen.sh
make install
```

Note: On Mac OS X had to do the following first:

```
```sh
brew install openssl socat
pip3 install cryptography

Expand All @@ -71,14 +98,14 @@ export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

Running swtpm

```
```sh
mkdir -p /tmp/myvtpm
swtpm socket --tpmstate dir=/tmp/myvtpm --tpm2 --ctrl type=tcp,port=2322 --server type=tcp,port=2321 --flags not-need-init
```

## Running examples

```
```sh
./examples/pcr/extend
./examples/wrap/wrap_test
```
Expand Down
Loading