Add Nuvoton NuMaker-M2354 wolfCrypt test and benchmark example - #628
Open
dgarske wants to merge 1 commit into
Open
Add Nuvoton NuMaker-M2354 wolfCrypt test and benchmark example#628dgarske wants to merge 1 commit into
dgarske wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
TrustZone security validation and test-runner correctness issues must be addressed.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds a NuMaker-M2354 wolfCrypt test and benchmark example with Key Store coverage, TrustZone support, and board tooling.
Changes:
- Adds board initialization, tests, benchmarks, and wolfCrypt configuration.
- Adds Key Store AES round-trip testing and TrustZone veneers.
- Adds build, flash, capture, and validation documentation.
File summaries
| File | Summary |
|---|---|
embedded/nuvoton_m2354/user_settings.h |
wolfCrypt configuration |
embedded/nuvoton_m2354/secure/nuvoton_nsc.c |
TrustZone veneers; ECC validation, CCM sizing, and key ownership require changes |
embedded/nuvoton_m2354/run_test.sh |
Flashing and capture; output normalization and stage-result checks require changes |
embedded/nuvoton_m2354/README.md |
Usage and validation documentation; reported results need reconciliation |
embedded/nuvoton_m2354/keystore_test.c |
Key Store AES round-trip test |
embedded/nuvoton_m2354/build.sh |
Secure and TrustZone build logic |
embedded/nuvoton_m2354/app.c |
Board setup and test application |
embedded/nuvoton_m2354/.gitignore |
Ignores generated artifacts and logs |
Review details
Suppressed comments (2)
embedded/nuvoton_m2354/run_test.sh:215
app.cemits CRLF by writing\rbefore every newline, so the capturedTrustZone:value retains a trailing carriage return. As a result, the documentedEXPECT_WORLDvalue never equalsWORLDeven for the correct image. Strip\rbefore comparing.
WORLD=$(sed -n 's/^TrustZone: //p' "$OUT" | head -1)
echo "image reported: TrustZone: ${WORLD:-unknown}"
if [ -n "$EXPECT_WORLD" ] && [ "$WORLD" != "$EXPECT_WORLD" ]; then
embedded/nuvoton_m2354/secure/nuvoton_nsc.c:239
- The port's ECC request fields are 144 bytes wide, enough for P-521's 132 hex digits plus the NUL, but this veneer validates every output with 160 bytes. For the final field that range runs past the request allocation, so non-secure ECC calls are rejected by
cmse_check_address_rangebefore reaching the hardware. Keep the bound at the port's field width or derive a curve-specific output span.
/* Longest string the ECC requests carry: P-521 is 132 hex characters. */
#define NSC_ECC_STR_MAX 160
- Files reviewed: 8/8 changed files
- Comments generated: 6
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| /* Longest string the ECC requests carry: P-521 is 132 hex characters. */ | ||
| #define NSC_ECC_STR_MAX 160 | ||
|
|
||
| static int nsc_ecc_strings_ok(wc_NuvotonEccReq* r) |
Comment on lines
+399
to
+402
| NSC_ENTRY int wc_nuvoton_hw_ks_erase(int keyMem, int keySlot) | ||
| { | ||
| return wc_nuvoton_hw_ks_erase_s(keyMem, keySlot); | ||
| } |
Comment on lines
+220
to
+224
| if ! grep -q "wolfcrypt_test returned" "$OUT"; then | ||
| echo "NOTE: capture ended before wolfcrypt_test finished - raise --seconds" | ||
| elif ! grep -q "benchmark_test returned" "$OUT"; then | ||
| echo "NOTE: test finished; benchmark truncated by the window" | ||
| fi |
Comment on lines
+218
to
+219
| word32 ivSz = (local.mode == WC_NUVOTON_AES_GCM) ? | ||
| local.ivSz : (word32)WC_AES_BLOCK_SIZE; |
Comment on lines
+107
to
+109
| `wolfcrypt_test` completes on a NuMaker-M2354 with 29 of 29 tests passing and | ||
| none failing, and the benchmark runs to completion. The port README in wolfSSL | ||
| carries the throughput table. |
Comment on lines
+111
to
+115
| :warning: **The TrustZone leg is compile-checked only.** `--tz` builds both | ||
| halves but does not link or run, and nothing in `secure/nuvoton_nsc.c` has | ||
| executed on hardware. The veneers are pure request validation over wolfSSL | ||
| types, and a review of them found two defects that a functional test would have | ||
| caught at once, so treat that path as unvalidated until someone brings up a |
dgarske
force-pushed
the
nuvoton_m2354
branch
from
September 12, 2026 21:14
0867fc1 to
a1fb869
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Runnable
wolfcrypt_testand benchmark for the NuMaker-M2354 (NuMicro M2354KJFAE, Arm Cortex-M23 with TrustZone), exercising the wolfCrypt Nuvoton port that drives the part's CRPT accelerator, TRNG and Key Store.What it adds
app.c- clocks, UART0 console, the CRPT interrupt handler, a bounded_sbrk, andmain()keystore_test.c- a Key Store round trip, covering a pathwolfcrypt_testdoes not reach: a key written to a slot, used by handle for AES, read back where that is allowed, and eraseduser_settings.h- wolfCrypt configuration to start fromsecure/nuvoton_nsc.c- non-secure callable veneers for a TrustZone buildbuild.sh- cross build for either TrustZone worldrun_test.sh- flash and capture on a real board, with a bench lock and a check that the running image is the one just builtRequires a wolfSSL checkout carrying the Nuvoton port.
build.shlooks in../../../wolfsslby default;--wolfssl PATHorWOLFSSL_ROOToverride it.Hardware / test status
Validated on a NuMaker-M2354 (96 MHz, Nu-Link2-Me CMSIS-DAP, UART0 on PA6/PA7 at 115200), flashed with
pyocdagainst its builtinm2354kjfaetarget.wolfcrypt_testcompletes with 42 tests passing and none failing, and the Key Store round trip passes. The benchmark completes; the port README in wolfSSL carries the throughput table.build.sh --tzis a compile check of both halves rather than a linked image, because a working TrustZone application also needs a partition layout and a secure bootstrap belonging to the user's project. A two-image build has been run on the board separately; the wolfSSL PR and the port README carry what it showed.Scope
The Key Store round trip uses volatile SRAM slots. A Flash slot has no per-key erase, only an irreversible revoke, so a run would spend one for good;
-DM2354_KS_TEST_FLASHincludes that leg for anyone who wants it deliberately.Related
wolfBoot's M2354 target, which uses the same port: wolfSSL/wolfBoot#884