Skip to content

Commit 0c52f3b

Browse files
committed
Add firmware TPM 2.0 (fwTPM) implementation
Add portable firmware TPM 2.0 implementation (fwTPM) built on wolfCrypt. Implements 105/113 TPM 2.0 v1.38 commands (93%) as a standalone server with socket and TIS transports, NV storage, and full CI/fuzz coverage.
1 parent 4556395 commit 0c52f3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+32049
-2053
lines changed

.github/workflows/cmake-build.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ jobs:
8484
# Test combination of options
8585
- name: "Combined Options"
8686
options: "-DWOLFTPM_INTERFACE=I2C -DWOLFTPM_MODULE=st33 -DWOLFTPM_ADVIO=yes -DWOLFTPM_CHECK_WAIT_STATE=yes"
87+
# fwTPM server with socket transport
88+
- name: "fwTPM Socket"
89+
options: "-DWOLFTPM_FWTPM=yes -DWOLFTPM_INTERFACE=SWTPM"
90+
# fwTPM server with TIS/shared-memory transport
91+
- name: "fwTPM TIS"
92+
options: "-DWOLFTPM_FWTPM=yes -DWOLFTPM_INTERFACE=SPI"
93+
# fwTPM server-only mode (no client library or examples)
94+
- name: "fwTPM Only"
95+
options: "-DWOLFTPM_FWTPM_ONLY=yes -DWOLFTPM_INTERFACE=SWTPM"
8796

8897
steps:
8998
#pull wolfTPM
@@ -107,7 +116,7 @@ jobs:
107116
mkdir build
108117
cd build
109118
# wolfSSL PR 7188 broke "make install" unless WOLFSSL_INSTALL is set
110-
cmake -DWOLFSSL_TPM=yes -DWOLFSSL_INSTALL=yes -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install" ..
119+
cmake -DWOLFSSL_TPM=yes -DWOLFSSL_INSTALL=yes -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install" -DCMAKE_C_FLAGS="-DWC_RSA_NO_PADDING" ..
111120
cmake --build .
112121
cmake --install .
113122
@@ -119,3 +128,9 @@ jobs:
119128
cmake ${{ matrix.config.options }} -DCMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/install" -DWITH_WOLFSSL="$GITHUB_WORKSPACE/install" ..
120129
cmake --build .
121130
cmake --install .
131+
132+
- name: Test fwTPM
133+
if: contains(matrix.config.options, 'WOLFTPM_FWTPM')
134+
run: |
135+
cd build
136+
LD_LIBRARY_PATH="$GITHUB_WORKSPACE/install/lib" ctest --output-on-failure

.github/workflows/codespell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
uses: codespell-project/actions-codespell@v2
2424
with:
2525
skip: .git,./IDE,./certs,./m4,*.der,*.pem
26-
ignore_words_list: inh,inout,keypair,nd,parm,rcv,ser,loadIn,importIn,certifyIn,bu,fo
26+
ignore_words_list: inh,inout,keypair,nd,parm,rcv,ser,loadIn,importIn,certifyIn,bu,fo,daa,pris,hsi

.github/workflows/coverity-scan-fixes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
run: ./autogen.sh
2525
- name: wolfssl configure
2626
working-directory: ./wolfssl
27-
run: ./configure --enable-wolftpm
27+
run: ./configure --enable-wolftpm --enable-pkcallbacks --enable-keygen CFLAGS="-DWC_RSA_NO_PADDING"
2828
- name: wolfssl make
2929
working-directory: ./wolfssl
3030
run: make

.github/workflows/fuzz.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Fuzz Testing
2+
3+
on:
4+
schedule:
5+
- cron: '0 4 * * 1' # Weekly Monday 4am UTC
6+
workflow_dispatch: # Manual trigger
7+
pull_request:
8+
branches: [ '*' ]
9+
10+
jobs:
11+
fuzz:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 30
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
include:
18+
# Full fuzz run (weekly/manual) - 10 minutes
19+
- name: fuzz-full
20+
fuzz_time: 600
21+
smoke_only: false
22+
# Quick smoke test (PR) - 60 seconds
23+
- name: fuzz-smoke
24+
fuzz_time: 60
25+
smoke_only: true
26+
27+
steps:
28+
- name: Checkout wolfTPM
29+
uses: actions/checkout@v4
30+
31+
- name: Checkout wolfSSL
32+
uses: actions/checkout@v4
33+
with:
34+
repository: wolfssl/wolfssl
35+
path: wolfssl
36+
37+
- name: ASLR workaround
38+
run: sudo sysctl vm.mmap_rnd_bits=28
39+
40+
- name: Build wolfSSL with fuzzer support
41+
working-directory: ./wolfssl
42+
run: |
43+
./autogen.sh
44+
CC=clang ./configure --enable-wolftpm --enable-pkcallbacks --enable-keygen \
45+
CFLAGS="-fsanitize=fuzzer-no-link,address -fno-omit-frame-pointer -g -O1 -DWC_RSA_NO_PADDING" \
46+
LDFLAGS="-fsanitize=address"
47+
make -j$(nproc)
48+
sudo make install
49+
sudo ldconfig
50+
51+
- name: Build fuzz target
52+
run: |
53+
./autogen.sh
54+
CC=clang ./configure --enable-fwtpm --enable-fuzz \
55+
CFLAGS="-fsanitize=fuzzer-no-link,address -fno-omit-frame-pointer -g -O1" \
56+
LDFLAGS="-fsanitize=address"
57+
make -j$(nproc)
58+
59+
- name: Generate seed corpus
60+
run: python3 tests/fuzz/gen_corpus.py
61+
62+
- name: Run fuzzer
63+
env:
64+
ASAN_OPTIONS: "detect_leaks=1:abort_on_error=1:symbolize=1"
65+
run: |
66+
echo "Fuzzing for ${{ matrix.fuzz_time }} seconds..."
67+
timeout ${{ matrix.fuzz_time }} \
68+
./tests/fuzz/fwtpm_fuzz \
69+
tests/fuzz/corpus/ \
70+
-dict=tests/fuzz/tpm2.dict \
71+
-max_len=4096 \
72+
-timeout=30 \
73+
-rss_limit_mb=2048 \
74+
-print_final_stats=1 \
75+
|| FUZZ_RC=$?
76+
# timeout returns 124 on normal expiry, fuzzer returns 0 on no crash
77+
if [ "${FUZZ_RC:-0}" -eq 124 ] || [ "${FUZZ_RC:-0}" -eq 0 ]; then
78+
echo "Fuzzer completed without crashes"
79+
else
80+
echo "Fuzzer found crashes (exit code $FUZZ_RC)"
81+
ls -la crash-* 2>/dev/null || true
82+
exit 1
83+
fi
84+
85+
- name: Upload crash artifacts
86+
if: failure()
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: fuzz-crashes-${{ matrix.name }}
90+
path: |
91+
crash-*
92+
oom-*
93+
timeout-*
94+
retention-days: 30
95+
if-no-files-found: ignore

0 commit comments

Comments
 (0)