Skip to content

Commit 6b47e43

Browse files
committed
Add RealTek AmebaPro2 (RTL8735B) HUK crypto-callback port (AES, HMAC-SHA256, ECDSA, TRNG)
1 parent 3fa342a commit 6b47e43

12 files changed

Lines changed: 2737 additions & 2 deletions

File tree

.github/workflows/rtl8735b.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: RealTek RTL8735B (AmebaPro2) HUK port Tests
2+
3+
# START OF COMMON SECTION
4+
on:
5+
push:
6+
branches: [ 'release/**' ]
7+
pull_request:
8+
types: [opened, synchronize, reopened, ready_for_review]
9+
branches: [ '*' ]
10+
# Weekday-morning cron seeds the master-scoped ccache that PR runs restore
11+
# read-only (see ccache-setup).
12+
schedule:
13+
- cron: '27 10 * * 1-5'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
# END OF COMMON SECTION
19+
20+
jobs:
21+
# Compile + helper-KAT gate for the RTL8735B HUK crypto-callback port.
22+
# --enable-rtl8735b sets WOLFSSL_RTL8735B_HOST_TEST, which swaps the vendor HAL
23+
# headers for rtl8735b_shim.h (sentinel stubs, no real crypto). Two levels:
24+
# (1) build-only matrix -- exercises crypto-callback dispatch, info-struct
25+
# field access, compile guards, and build wiring across algo/guard combos
26+
# and both WOLFSSL_SMALL_STACK branches, via parallel-make-check.py.
27+
# (2) one config runs testwolfcrypt, which calls wc_Rtl8735b_HukSelfTest() --
28+
# real KATs of the silicon-independent helpers (BE/LE word conversion, CTR
29+
# counter increment, HMAC accumulator growth/overflow/cap, bounce
30+
# alignment). No fake-crypto shim path is asserted as "correct".
31+
# Functional crypto correctness (AES/GCM/ECDSA on silicon) is validated on
32+
# RTL8735B hardware, NOT here (see the port README).
33+
build:
34+
name: build + helper KATs (--enable-rtl8735b)
35+
if: ${{ (github.repository_owner == 'wolfssl') && (github.event_name != 'pull_request' || github.event.pull_request.draft == false) }}
36+
runs-on: ubuntu-24.04
37+
timeout-minutes: 15
38+
steps:
39+
- uses: actions/checkout@v5
40+
name: Checkout wolfSSL
41+
42+
- name: Install dependencies
43+
uses: ./.github/actions/install-apt-deps
44+
with:
45+
packages: autoconf automake libtool build-essential
46+
ghcr-debs-tag: ubuntu-24.04-minimal
47+
48+
- name: Set up ccache
49+
uses: ./.github/actions/ccache-setup
50+
with:
51+
workflow-id: rtl8735b
52+
read-only: ${{ github.event_name == 'pull_request' }}
53+
max-size: 100M
54+
55+
- name: Build all configs (compile-only, out-of-tree)
56+
run: |
57+
cat > "$RUNNER_TEMP/rtl8735b-configs.json" <<'EOF'
58+
[
59+
{"name": "full-smallstack", "minutes": 2,
60+
"comment": "All port paths (AES-GCM/ECB/CBC/CTR, HMAC-SHA256, ECDSA P-256) with WOLFSSL_SMALL_STACK -> exercises the heap branch of the HW-ECDSA mp_int helpers.",
61+
"configure": ["--enable-rtl8735b", "--enable-cryptocb", "--enable-ecc",
62+
"--enable-aesgcm", "--enable-aesctr", "--enable-aescbc",
63+
"CPPFLAGS=-DWOLFSSL_SMALL_STACK"]},
64+
{"name": "full", "minutes": 2,
65+
"comment": "Same algo coverage without WOLFSSL_SMALL_STACK -> exercises the on-stack (array) branch of the HW-ECDSA mp_int helpers.",
66+
"configure": ["--enable-rtl8735b", "--enable-cryptocb", "--enable-ecc",
67+
"--enable-aesgcm", "--enable-aesctr", "--enable-aescbc"]},
68+
{"name": "min", "minutes": 2,
69+
"comment": "Minimal: no ECC (HW/SW ECDSA sign code compiled out), AES + HMAC only -> exercises the non-ECC compile guards.",
70+
"configure": ["--enable-rtl8735b", "--enable-cryptocb"]}
71+
]
72+
EOF
73+
.github/scripts/parallel-make-check.py --build-only \
74+
"$RUNNER_TEMP/rtl8735b-configs.json"
75+
76+
- name: Run helper KATs on host (testwolfcrypt self-test)
77+
run: |
78+
./autogen.sh
79+
./configure --enable-rtl8735b --enable-cryptocb --enable-ecc \
80+
--enable-aesgcm --enable-aesctr --enable-aescbc
81+
make -j"$(nproc)"
82+
./wolfcrypt/test/testwolfcrypt
83+
84+
- name: ccache stats
85+
if: always()
86+
run: ccache -s || true
87+
88+
- name: Upload logs on failure
89+
if: failure()
90+
uses: actions/upload-artifact@v6
91+
with:
92+
retention-days: 7
93+
name: rtl8735b-logs
94+
path: |
95+
build-*/config.log
96+
if-no-files-found: ignore

configure.ac

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3216,6 +3216,30 @@ case "$ENABLED_STSAFE" in
32163216
esac
32173217

32183218

3219+
# RealTek AmebaPro2 (RTL8735B) HUK crypto-callback port.
3220+
# On-target the application supplies the AmebaPro2 HAL include path. This option
3221+
# is a host compile-test of the port: it swaps the HAL headers for a shim
3222+
# (WOLFSSL_RTL8735B_HOST_TEST) so the cryptocb dispatch and wiring build without
3223+
# the vendor SDK. It forces crypto callbacks on (see the cryptocb block).
3224+
# Example: "./configure --enable-rtl8735b"
3225+
ENABLED_RTL8735B="no"
3226+
AC_ARG_ENABLE([rtl8735b],
3227+
[AS_HELP_STRING([--enable-rtl8735b],
3228+
[Enable RealTek AmebaPro2 (RTL8735B) HUK crypto-callback port (host compile-test).])],
3229+
[ ENABLED_RTL8735B=$enableval ],
3230+
[ ENABLED_RTL8735B=no ])
3231+
3232+
if test "x$ENABLED_RTL8735B" != "xno"
3233+
then
3234+
# HAVE_AES_ECB is required: the port chains AES-CBC/CTR over single-block
3235+
# secure-key ECB ops, so enabling the port implies AES-ECB for the build.
3236+
# NOTE: this enables the (public, unauthenticated) AES-ECB API build-wide,
3237+
# not just for the port -- a deliberate, documented side effect.
3238+
AC_MSG_NOTICE([--enable-rtl8735b also enables AES-ECB build-wide (HAVE_AES_ECB)])
3239+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_RTL8735B_HUK -DWOLFSSL_RTL8735B_HOST_TEST -DHAVE_AES_ECB"
3240+
fi
3241+
3242+
32193243
# NXP SE050
32203244
# Example: "./configure --with-se050=/home/pi/simw_top"
32213245
ENABLED_SE050="no"
@@ -10717,7 +10741,7 @@ AC_ARG_ENABLE([cryptocb-sw-test],
1071710741
[ ENABLED_CRYPTOCB_SW_TEST=yes ]
1071810742
)
1071910743
10720-
if test "x$ENABLED_PKCS11" = "xyes" || test "x$ENABLED_WOLFTPM" = "xyes" || test "$ENABLED_CAAM" != "no"
10744+
if test "x$ENABLED_PKCS11" = "xyes" || test "x$ENABLED_WOLFTPM" = "xyes" || test "$ENABLED_CAAM" != "no" || test "x$ENABLED_RTL8735B" != "xno"
1072110745
then
1072210746
ENABLED_CRYPTOCB=yes
1072310747
fi
@@ -12492,6 +12516,7 @@ AM_CONDITIONAL([BUILD_IOTSAFE],[test "x$ENABLED_IOTSAFE" = "xyes"])
1249212516
AM_CONDITIONAL([BUILD_IOTSAFE_HWRNG],[test "x$ENABLED_IOTSAFE_HWRNG" = "xyes"])
1249312517
AM_CONDITIONAL([BUILD_SE050],[test "x$ENABLED_SE050" = "xyes"])
1249412518
AM_CONDITIONAL([BUILD_STSAFE],[test "x$ENABLED_STSAFE" != "xno"])
12519+
AM_CONDITIONAL([BUILD_RTL8735B],[test "x$ENABLED_RTL8735B" != "xno"])
1249512520
AM_CONDITIONAL([BUILD_TROPIC01],[test "x$ENABLED_TROPIC01" = "xyes"])
1249612521
AM_CONDITIONAL([BUILD_KDF],[test "x$ENABLED_KDF" = "xyes"])
1249712522
AM_CONDITIONAL([BUILD_HMAC],[test "x$ENABLED_HMAC" = "xyes"])
@@ -13075,6 +13100,7 @@ echo " * IoT-Safe: $ENABLED_IOTSAFE"
1307513100
echo " * IoT-Safe HWRNG: $ENABLED_IOTSAFE_HWRNG"
1307613101
echo " * NXP SE050: $ENABLED_SE050"
1307713102
echo " * STMicro STSAFE: $ENABLED_STSAFE"
13103+
echo " * RealTek RTL8735B HUK: $ENABLED_RTL8735B"
1307813104
echo " * TROPIC01: $ENABLED_TROPIC01"
1307913105
echo " * Maxim Integrated MAXQ10XX: $ENABLED_MAXQ10XX"
1308013106
echo " * PSA: $ENABLED_PSA"

wolfcrypt/src/include.am

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ EXTRA_DIST += wolfcrypt/src/port/ti/ti-aes.c \
106106
wolfcrypt/src/port/st/README.md \
107107
wolfcrypt/src/port/st/STM32MP13.md \
108108
wolfcrypt/src/port/st/STM32MP25.md \
109+
wolfcrypt/src/port/realtek/rtl8735b.c \
110+
wolfcrypt/src/port/realtek/rtl8735b_shim.h \
111+
wolfcrypt/src/port/realtek/README.md \
109112
wolfcrypt/src/port/tropicsquare/tropic01.c \
110113
wolfcrypt/src/port/tropicsquare/README.md \
111114
wolfcrypt/src/port/af_alg/afalg_aes.c \
@@ -245,6 +248,10 @@ if BUILD_TROPIC01
245248
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/tropicsquare/tropic01.c
246249
endif
247250

251+
if BUILD_RTL8735B
252+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/realtek/rtl8735b.c
253+
endif
254+
248255
if BUILD_PSA
249256
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/psa/psa.c
250257
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/psa/psa_hash.c

0 commit comments

Comments
 (0)