Skip to content

Commit 001c334

Browse files
committed
Add SE050 sim job running wolfcrypt_test against SE050Sim
1 parent c3ab2f6 commit 001c334

2 files changed

Lines changed: 141 additions & 0 deletions

File tree

.github/scripts/se050-run.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/sh
2+
# Build the SE050 stack -- SE050Sim (Rust TCP applet sim on :8050), the NXP
3+
# plug-and-trust SDK v04.07.01 with wolfSSL's HostCrypto patch, and wolfSSL
4+
# --with-se050 -- then build this repo's SE050 wolfcrypt_test demo and run it
5+
# against the sim. Recipe mirrors SE050Sim/Dockerfile.wolfcrypt (the sim's own
6+
# CI), grafting this repo's ex_sss demo in place of the sim's standalone main.
7+
set -eu
8+
9+
ROOT="$PWD"
10+
WORK=/tmp/se050
11+
mkdir -p "$WORK"
12+
cd "$WORK"
13+
14+
echo "::group::SE050Sim (Rust TCP server)"
15+
git clone -q --depth 1 https://github.com/wolfSSL/simulators sims
16+
# se050-sim depends on the se050 crate at ../nxp-se050/se050 (its own repo)
17+
git clone -q --branch sim-compat --depth 1 \
18+
https://github.com/LinuxJedi/nxp-se050.git sims/SE050Sim/nxp-se050
19+
( cd sims/SE050Sim/se050-sim && cargo build --release --bin tcp_server )
20+
SIM="$WORK/sims/SE050Sim/wolfcrypt-test"
21+
echo "::endgroup::"
22+
23+
echo "::group::plug-and-trust SDK + wolfSSL HostCrypto patch + sim overlays"
24+
git clone -q --depth 1 --branch v04.07.01 https://github.com/NXP/plug-and-trust simw-top
25+
curl -fsSL https://raw.githubusercontent.com/wolfSSL/osp/master/nxp-se05x-middleware/simw-top-v040701.patch \
26+
| ( cd simw-top && patch -p1 -l --forward --fuzz=3 )
27+
test -f simw-top/sss/src/wolfssl/fsl_sss_wolfssl_apis.c
28+
cp "$SIM/i2c_a7.c" simw-top/hostlib/hostLib/platform/linux/i2c_a7.c
29+
cp "$SIM/se05x_reset.c" simw-top/hostlib/hostLib/platform/rsp/se05x_reset.c
30+
python3 "$SIM/patch_ftr.py" simw-top/fsl_sss_ftr.h
31+
cp "$SIM/CMakeLists.txt" simw-top/CMakeLists.txt
32+
echo "::endgroup::"
33+
34+
echo "::group::wolfSSL pass A (no se050, so the SDK can link -lwolfssl)"
35+
git clone -q --depth 1 https://github.com/wolfSSL/wolfssl
36+
( cd wolfssl && ./autogen.sh >/dev/null 2>&1 && \
37+
./configure --enable-keygen --enable-cmac \
38+
CFLAGS="-DWOLFSSL_SE050_NO_TRNG -DSIZEOF_LONG_LONG=8" >/dev/null && \
39+
make -j"$(nproc)" >/dev/null && sudo make install >/dev/null && sudo ldconfig )
40+
echo "::endgroup::"
41+
42+
echo "::group::six SDK static libs (WOLFSSL HostCrypto)"
43+
mkdir -p simw-top/build
44+
( cd simw-top/build && \
45+
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-fPIC" \
46+
-DPTMW_Applet=SE05X_C -DPTMW_SE05X_Auth=None \
47+
-DPTMW_SMCOM=T1oI2C -DPTMW_HostCrypto=WOLFSSL -DPTMW_Host=LinuxLike >/dev/null && \
48+
cmake --build . -j"$(nproc)" >/dev/null && \
49+
cp ../fsl_sss_ftr.h ./ && \
50+
ln -sf "$WORK/simw-top/build/sss/ex/src/libex_common.a" \
51+
"$WORK/simw-top/build/sss/libex_common.a" )
52+
echo "::endgroup::"
53+
54+
echo "::group::wolfSSL pass B (--with-se050)"
55+
( cd wolfssl && make clean >/dev/null && \
56+
./configure --with-se050="$WORK/simw-top" \
57+
--enable-keygen --enable-cmac --enable-cryptocb --enable-ecc \
58+
--enable-ed25519 --enable-curve25519 --enable-sha224 --enable-sha384 --enable-sha512 \
59+
--disable-examples --enable-crypttests \
60+
CFLAGS="-DWOLFSSL_SE050_INIT -DWOLFSSL_SE050_NO_TRNG -DSIZEOF_LONG_LONG=8 \
61+
-DECC_USER_CURVES -DHAVE_ECC224 -DHAVE_ECC256 -DHAVE_ECC384" \
62+
LDFLAGS="-L$WORK/simw-top/build" >/dev/null && \
63+
make -j"$(nproc)" >/dev/null && sudo make install >/dev/null && sudo ldconfig )
64+
echo "::endgroup::"
65+
66+
echo "::group::build this repo's wolfcrypt_test demo"
67+
D="$ROOT/SE050/wolfssl/wolfcrypt_test"
68+
cp wolfssl/wolfcrypt/test/test.c "$D/test.c"
69+
cp wolfssl/wolfcrypt/test/test.h "$D/test.h"
70+
B="$WORK/simw-top/build"
71+
gcc -o "$WORK/wolfcrypt_test" "$D/wolfcrypt_test.c" "$D/test.c" \
72+
-DSIMW_DEMO_ENABLE__DEMO_WOLFCRYPTTEST -DNO_MAIN_DRIVER -DBENCH_EMBEDDED \
73+
-DUSE_CERT_BUFFERS_2048 -DUSE_CERT_BUFFERS_256 -DHAVE_CONFIG_H \
74+
-I"$D" -I"$WORK/wolfssl" -I"$WORK/wolfssl/wolfcrypt/test" -I/usr/local/include \
75+
-I"$WORK/simw-top" -I"$WORK/simw-top/sss/inc" -I"$WORK/simw-top/sss/ex/inc" \
76+
-I"$WORK/simw-top/sss/port/default" -I"$WORK/simw-top/hostlib/hostLib/inc" \
77+
-I"$WORK/simw-top/hostlib/hostLib/libCommon/log" \
78+
-I"$WORK/simw-top/hostlib/hostLib/libCommon/infra" \
79+
-I"$WORK/simw-top/hostlib/hostLib/se05x_03_xx_xx" \
80+
-I"$WORK/simw-top/hostlib/hostLib/platform/inc" -I"$B" \
81+
-L/usr/local/lib -L"$B/sss" -L"$B/hostlib/hostLib/se05x" -L"$B/hostlib/hostLib" \
82+
-L"$B/hostlib/hostLib/libCommon/log" -L"$B/hostlib/hostLib/libCommon" \
83+
-lwolfssl -lSSS_APIs -lex_common -lse05x -la7x_utils -lmwlog -lsmCom -lpthread -lm
84+
echo "::endgroup::"
85+
86+
echo "::group::run wolfcrypt_test against SE050Sim"
87+
"$WORK/sims/SE050Sim/se050-sim/target/release/tcp_server" >/tmp/se050sim.log 2>&1 &
88+
simpid=$!
89+
sleep 2
90+
export SE050_SIM_HOST=127.0.0.1 SE050_SIM_PORT=8050 LD_LIBRARY_PATH=/usr/local/lib
91+
out=$("$WORK/wolfcrypt_test" 2>&1) || true
92+
kill "$simpid" 2>/dev/null || true
93+
printf '%s\n' "$out" | tail -40
94+
printf '%s' "$out" | grep -qiE "Ran wolfCrypt test|Test complete|error test passed" \
95+
|| { echo "FAIL: se050 wolfcrypt_test did not report success"; exit 1; }
96+
echo "PASS: se050 wolfcrypt_test ran against SE050Sim"
97+
echo "::endgroup::"

.github/workflows/se050.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: SE050 sim
2+
3+
on:
4+
push:
5+
paths:
6+
- 'SE050/**'
7+
- '.github/workflows/se050.yml'
8+
- '.github/scripts/se050-run.sh'
9+
pull_request:
10+
types: [opened, synchronize, reopened, ready_for_review]
11+
paths:
12+
- 'SE050/**'
13+
- '.github/workflows/se050.yml'
14+
- '.github/scripts/se050-run.sh'
15+
workflow_call:
16+
inputs:
17+
caller_run_id:
18+
description: 'run id of the calling workflow; keeps a called run in its own concurrency group'
19+
type: string
20+
default: ''
21+
workflow_dispatch:
22+
23+
concurrency:
24+
group: ${{ inputs.caller_run_id && format('se050-call-{0}', inputs.caller_run_id) || format('se050-{0}', github.ref) }}
25+
cancel-in-progress: ${{ !inputs.caller_run_id }}
26+
27+
permissions:
28+
contents: read
29+
30+
jobs:
31+
se050:
32+
name: wolfcrypt_test vs SE050Sim
33+
runs-on: ubuntu-24.04
34+
timeout-minutes: 40
35+
steps:
36+
- uses: actions/checkout@v5
37+
- uses: ./.github/actions/apt-update
38+
- name: Install toolchain
39+
run: |
40+
set -euo pipefail
41+
sudo apt-get install -y --no-install-recommends \
42+
autoconf automake libtool cmake pkg-config curl cargo
43+
- name: Build SE050 stack and run wolfcrypt_test against the sim
44+
run: ./.github/scripts/se050-run.sh

0 commit comments

Comments
 (0)