Skip to content

Commit 6c6a2a8

Browse files
committed
fwTPM v185: CI fixes for non-PQC builds + Tier 5 server lifetime
1 parent d4c537f commit 6c6a2a8

3 files changed

Lines changed: 32 additions & 10 deletions

File tree

.github/workflows/pqc-examples.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,30 @@ jobs:
9696
run: ./examples/pqc/mlkem_encap
9797

9898
- name: Stop Tier 2 fwtpm_server (free port 2321 for E2E)
99-
if: always()
10099
run: |
101100
if [ -f /tmp/fwtpm_server.pid ]; then
102101
kill "$(cat /tmp/fwtpm_server.pid)" 2>/dev/null || true
103102
rm -f /tmp/fwtpm_server.pid
104103
fi
105-
# Defensive: kill any other default-port server lingering. Don't
106-
# match the test helper's --port-qualified server (it isn't up
107-
# yet anyway).
104+
# Defensive: kill any other default-port server lingering.
108105
pkill -f "fwtpm_server$" 2>/dev/null || true
109106
sleep 1
110107
111108
- name: PQC mssim E2E (MLKEM-768 + HashMLDSA-65 round-trips)
112109
run: ./tests/pqc_mssim_e2e.sh
113110

111+
- name: Restart fwtpm_server for Tier 5 (run_examples.sh)
112+
run: |
113+
# pqc_mssim_e2e.sh started + stopped its own server; Tier 5 needs
114+
# one again. Reuse the same default-port launch as Tier 2.
115+
pkill -f "fwtpm_server" 2>/dev/null || true
116+
sleep 1
117+
rm -f fwtpm_nv.bin
118+
./src/fwtpm/fwtpm_server > /tmp/fwtpm_server.log 2>&1 &
119+
echo $! > /tmp/fwtpm_server.pid
120+
sleep 1
121+
kill -0 "$(cat /tmp/fwtpm_server.pid)"
122+
114123
- name: Doc constants parity check
115124
run: |
116125
./tests/check_doc_constants.sh

examples/run_examples.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,27 @@ fi
2525
if [ -z "$WOLFCRYPT_RSA" ]; then
2626
WOLFCRYPT_RSA=1
2727
fi
28-
# Detect WOLFTPM_V185 (post-quantum keys) from the actual generated config
29-
# header. Search both the source-tree fallback and the autoconf-generated
30-
# location used by `make check`. ENABLE_V185 may be set by the caller to
31-
# override autodetection.
28+
# Detect WOLFTPM_V185 (post-quantum keys). Probe several known generated /
29+
# installed header locations: autoconf may write src/config.h or config.h
30+
# depending on AC_CONFIG_HEADERS, and tracked headers under wolftpm/ may
31+
# also gate the macro. ENABLE_V185 may be set by the caller to override.
3232
if [ -z "$ENABLE_V185" ]; then
3333
ENABLE_V185=0
34-
for cfg in src/config.h config.h ../src/config.h ../config.h; do
35-
if [ -f "$cfg" ] && grep -q "WOLFTPM_V185 1" "$cfg"; then
34+
for cfg in src/config.h config.h ../src/config.h ../config.h \
35+
wolftpm/options.h wolftpm/version.h; do
36+
if [ -f "$cfg" ] && grep -q "WOLFTPM_V185[[:space:]]*1" "$cfg"; then
3637
ENABLE_V185=1
3738
break
3839
fi
3940
done
41+
# Last-resort fallback: if any built example links a v1.85-only symbol
42+
# we can ask `nm` directly. nm's quiet on missing files; safe to try.
43+
if [ "$ENABLE_V185" = "0" ] && [ -x ./examples/keygen/keygen ]; then
44+
if nm ./examples/keygen/keygen 2>/dev/null | \
45+
grep -q "FwGenerateMlkemKey\|wolfTPM2_GetKeyTemplate_MLKEM"; then
46+
ENABLE_V185=1
47+
fi
48+
fi
4049
fi
4150
rm -f run.out
4251
touch run.out

src/fwtpm/fwtpm_crypto.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,6 +2468,7 @@ TPM_RC FwDecryptSeed(FWTPM_CTX* ctx,
24682468
}
24692469
else
24702470
#endif /* HAVE_ECC */
2471+
#ifdef WOLFTPM_V185
24712472
if (keyObj->pub.type == TPM_ALG_MLKEM) {
24722473
/* ML-KEM Labeled KEM per Part 1 Sec.47.4 Eq.66:
24732474
* K = ML-KEM.Decap(privateKey, ciphertext)
@@ -2497,6 +2498,7 @@ TPM_RC FwDecryptSeed(FWTPM_CTX* ctx,
24972498
(void)oaepLabel; (void)oaepLabelSz;
24982499
}
24992500
else
2501+
#endif /* WOLFTPM_V185 */
25002502
{
25012503
(void)ctx; (void)encSeedBuf; (void)encSeedSz;
25022504
(void)oaepLabel; (void)oaepLabelSz; (void)kdfLabel;
@@ -2704,6 +2706,7 @@ TPM_RC FwEncryptSeed(FWTPM_CTX* ctx,
27042706
}
27052707
else
27062708
#endif /* HAVE_ECC */
2709+
#ifdef WOLFTPM_V185
27072710
if (keyObj->pub.type == TPM_ALG_MLKEM) {
27082711
/* ML-KEM Labeled KEM per Part 1 Sec.47.4 Eq.66:
27092712
* (K, ciphertext) = ML-KEM.Encap(publicKey)
@@ -2751,6 +2754,7 @@ TPM_RC FwEncryptSeed(FWTPM_CTX* ctx,
27512754
(void)oaepLabel; (void)oaepLabelSz;
27522755
}
27532756
else
2757+
#endif /* WOLFTPM_V185 */
27542758
{
27552759
(void)ctx; (void)oaepLabel; (void)oaepLabelSz; (void)kdfLabel;
27562760
(void)seedBuf; (void)seedBufSz; (void)seedSzOut;

0 commit comments

Comments
 (0)