Skip to content

Commit 90096b9

Browse files
committed
Add fwTPM firmware TPM 2.0 server with STM32 port and UART transport
- fwTPM server implementing TPM 2.0 spec v1.38 (98/113 commands, 87%) - NV storage with TLV journal format (flash-friendly, append-only) - Socket (mssim/swtpm auto-detect) and TIS/SHM transports for desktop - STM32 Cortex-M33 bare-metal port with TrustZone (CMSE) support - UART transport for embedded fwTPM communication - Shared crypto refactoring: KDFa/KDFe, AES-CFB, HMAC/Hash to tpm2_crypto.c - Bounds-checked TPM2_Packet_ParseU16Buf for safer response parsing - libFuzzer harness with gen_corpus.py and tpm2.dict - 290+ tpm2-tools compatibility tests - CI: fwtpm-test.yml (examples, tpm2-tools, emulator), fuzz.yml
1 parent efaab4a commit 90096b9

Some content is hidden

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

76 files changed

+29774
-1133
lines changed

.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/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" \
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=10 \
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)