Add a zephyr module port - #29
yosuke-wolfssl wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical public-header compatibility and moderate test cleanup issues must be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds a Zephyr module port for wolfCert with Kconfig/CMake integration, QEMU coverage, an EST sample, CI, and portability fixes.
Changes:
- Adds Zephyr module configuration, tests, documentation, certificates, and CI.
- Shares EST client cases between host and Zephyr tests.
- Fixes zero-length HTTP response handling and Zephyr socket macro collisions.
- Outstanding findings: one critical public-header issue, three moderate cleanup issues, and one documentation nit.
File summaries
| File | Summary |
|---|---|
zephyr/wolfssl_user_settings.h |
Zephyr wolfSSL feature configuration. |
zephyr/tests/wolfcert_unit_store/testcase.yaml |
Registers store unit tests. |
zephyr/tests/wolfcert_unit_store/prj.conf |
Configures store unit tests. |
zephyr/tests/wolfcert_unit_store/CMakeLists.txt |
Builds store unit tests. |
zephyr/tests/wolfcert_unit_smoke/testcase.yaml |
Registers smoke tests. |
zephyr/tests/wolfcert_unit_smoke/prj.conf |
Configures smoke tests. |
zephyr/tests/wolfcert_unit_smoke/CMakeLists.txt |
Builds smoke tests. |
zephyr/tests/wolfcert_unit_scep_msg/testcase.yaml |
Registers SCEP message tests. |
zephyr/tests/wolfcert_unit_scep_msg/prj.conf |
Configures SCEP message tests. |
zephyr/tests/wolfcert_unit_scep_msg/CMakeLists.txt |
Builds SCEP message tests. |
zephyr/tests/wolfcert_unit_parse_negative/testcase.yaml |
Registers negative parsing tests. |
zephyr/tests/wolfcert_unit_parse_negative/prj.conf |
Configures negative parsing tests. |
zephyr/tests/wolfcert_unit_parse_negative/CMakeLists.txt |
Builds negative parsing tests. |
zephyr/tests/wolfcert_unit_keygen/testcase.yaml |
Registers key-generation tests. |
zephyr/tests/wolfcert_unit_keygen/prj.conf |
Configures key-generation tests. |
zephyr/tests/wolfcert_unit_keygen/CMakeLists.txt |
Builds key-generation tests. |
zephyr/tests/wolfcert_unit_csr/testcase.yaml |
Registers CSR tests. |
zephyr/tests/wolfcert_unit_csr/prj.conf |
Configures CSR tests. |
zephyr/tests/wolfcert_unit_csr/CMakeLists.txt |
Builds CSR tests. |
zephyr/tests/wolfcert_unit_csr_attrs/testcase.yaml |
Registers CSR attribute tests. |
zephyr/tests/wolfcert_unit_csr_attrs/prj.conf |
Configures CSR attribute tests. |
zephyr/tests/wolfcert_unit_csr_attrs/CMakeLists.txt |
Builds CSR attribute tests. |
zephyr/tests/wolfcert_est/testcase.yaml |
Registers the EST test. |
zephyr/tests/wolfcert_est/src/main.c |
Runs EST cases against the host. |
zephyr/tests/wolfcert_est/prj.conf |
Configures EST networking. |
zephyr/tests/wolfcert_est/CMakeLists.txt |
Builds the EST test. |
zephyr/tests/common/wolfcert.conf |
Shared Zephyr test configuration. |
zephyr/tests/common/unit_test.cmake |
Shared unit-test build logic. |
zephyr/tests/common/test_shim.c |
Wraps existing unit tests for Zephyr. |
zephyr/samples/wolfcert_est_client/src/main.c |
Implements the EST client sample. |
zephyr/samples/wolfcert_est_client/sample.yaml |
Registers the EST sample. |
zephyr/samples/wolfcert_est_client/README.md |
Documents the EST sample. |
zephyr/samples/wolfcert_est_client/prj.conf |
Configures the EST sample. |
zephyr/samples/wolfcert_est_client/CMakeLists.txt |
Builds the EST sample. |
zephyr/README.md |
Documents Zephyr usage; a nit remains to document the CONFIG_WOLFSSL=y prerequisite. |
zephyr/module.yml |
Declares the Zephyr module. |
zephyr/Kconfig |
Defines module configuration symbols. |
zephyr/include.am |
Distributes Zephyr files. |
zephyr/CMakeLists.txt |
Integrates the module build and generated options. |
tests/unit/test_http.c |
Tests zero-length HTTP responses. |
tests/integration/test_est_roundtrip.c |
Uses shared EST cases. |
tests/integration/est_client_cases.h |
Shared EST cases; three moderate cleanup findings remain on failed assertion paths. |
src/internal.h |
Handles Zephyr socket macros; a critical issue remains because the guard is too late for public-header declarations. |
src/http.c |
Handles zero-length response bodies safely. |
scripts/ci/zephyr-add-wolfssl.py |
Adds wolfSSL to west manifests. |
Makefile.am |
Includes Zephyr distribution files. |
examples/certs/README.md |
Documents certificate generation. |
examples/certs/mldsa/server-cert.pem |
Updates the server certificate. |
examples/certs/gen-certs.sh |
Adds the QEMU gateway SAN. |
examples/certs/ecc/server-cert.pem |
Updates the server certificate. |
docs/EMBEDDED.md |
Documents embedded sizing and clock requirements. |
.github/workflows/zephyr.yml |
Runs Zephyr QEMU CI. |
Review details
Suppressed comments (4)
tests/integration/est_client_cases.h:59
- This helper now runs as a Zephyr ztest, but
REQUIREreturns immediately afterdk(and latercsr,issued, DER, and certificate-manager objects) are allocated.wolfcert_cleanup()only tears down wolfSSL globally and cannot reclaim these per-test objects, so a failed assertion leaks into subsequent cases and can make the target suite fail for the wrong reason. Route failure paths through cleanup instead of returning directly.
REQUIRE(wolfcert_key_generate(&kcfg, &dk) == WOLFCERT_OK);
tests/integration/est_client_cases.h:118
- On any failed assertion after
dkis generated, this helper returns without freeing the key, CSR, issued buffer, DER, or decoded certificate. Because the same code is executed by multiple Zephyr ztests and the suite teardown does not own these objects, failures can accumulate leaked heap allocations. Use a cleanup path for each failure rather than the direct-returnREQUIREmacro here.
REQUIRE(wolfcert_key_generate(&kcfg, &dk) == WOLFCERT_OK);
tests/integration/est_client_cases.h:174
- This session helper has the same failure-path leak in a more resource-intensive test: a failed
REQUIREcan leave the key, CSR, open EST session, buffers, and DER object live, and can also leavebsopen after the bad-password half.wolfcert_cleanup()does not close these handles, so later ztests may inherit exhausted sockets or heap. Replace the direct-return assertions with cleanup-aware failure paths.
REQUIRE(wolfcert_key_generate(&kcfg, &dk) == WOLFCERT_OK);
zephyr/README.md:45
WOLFCERThasdepends on WOLFSSLinzephyr/Kconfig:15, so setting onlyCONFIG_WOLFCERT=yleaves the module disabled unless the application already enables wolfSSL. Please document the requiredCONFIG_WOLFSSL=yprerequisite (as the shared test config does) or change the Kconfig dependency.
`CONFIG_WOLFCERT=y` enables the library; `menuconfig` lists the rest under
- Files reviewed: 52/52 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
9a8954e to
72e6cf3
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #29
Scan targets checked: wolfcert-bugs
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
60ff893 to
49c12dc
Compare
|
This requires PR #31 |
- The Content-Length branch of the response-body read asks for one byte when the length is zero and skips the copy, matching the read-until-close branch. - test_http's transfer-encoding case asserts the empty body arrives as a non-NULL buffer of length zero.
- zephyr/ carries module.yml, Kconfig, CMakeLists.txt, README.md and include.am. The CMakeLists renders wolfcert/options.h from the CONFIG_WOLFCERT_* symbols and builds the library without the test server. APP_LINK_WITH_WOLFCERT hands the application the same compile definitions the library is built with, and wolfSSL is linked into the interface so an application does not depend on CONFIG_APP_LINK_WITH_WOLFSSL. - zephyr/wolfssl_user_settings.h supplies wolfSSL's configuration, used unless the application sets CONFIG_WOLFSSL_SETTINGS_FILE. - zephyr/tests/ builds each tests/unit program as a qemu_x86 image through a shared shim that renames the test's main() and panics on a nonzero result, so a failing suite ends instead of timing out; wolfcert_est is a ztest suite enrolling against a host wolfcert-server, setting the realtime clock before each test. wolfcert_unit_smoke carries build-only rows for the options the other suites leave at their defaults. - zephyr/samples/wolfcert_est_client enrolls one certificate and prints the result, ending the run on failure so twister reports the error rather than a timeout. - tests/integration/est_client_cases.h holds enroll_one, has_alt, enroll_check_san and session_basic_auth, moved out of test_est_roundtrip.c, which now includes it. - examples/certs/gen-certs.sh adds IP:10.0.2.2 to the server leaf SAN and examples/certs/README.md lists it; both server-cert.pem are re-issued from their existing keys and CAs. - .github/workflows/zephyr.yml runs twister over zephyr/tests and zephyr/samples on qemu_x86, against a west workspace it caches. scripts/ci/twister-assert-ran.py fails a step whose suites were filtered out instead of run; scripts/ci/zephyr-add-wolfssl.py adds wolfSSL to a west manifest. - Makefile.am gains est_client_cases.h and includes zephyr/include.am; docs/EMBEDDED.md gains a Zephyr section.
49c12dc to
1b7bc82
Compare
Problem
wolfCert has no Zephyr integration, so it can only be built and tested on a
POSIX host — nothing proves it works on an RTOS target, and there is no way to
consume it as a Zephyr module.
Getting an on-target run working also surfaced one library bug:
wolfcert_http_request()calledXMALLOC(0)for aContent-Length: 0body,and picolibc returns
NULLfor a zero-size request — so an EST 401 challengesurfaced as
WOLFCERT_ERR_MEMORYinstead ofWOLFCERT_ERR_AUTH.Fix
src/http.casks for one byte on a zero-length body and skips the copy,matching the read-until-close branch. This is the only change to library
sources.
zephyr/is the module:Kconfig, and aCMakeLists.txtthat renderswolfcert/options.hfrom theCONFIG_WOLFCERT_*symbols, reusing the existingoptions.h.in. Client-only — the in-tree test server drives sockets directlyand stays host-side. The transport is
src/net_posix.cunchanged, underCONFIG_POSIX_API.Tests
The four EST client cases move into
tests/integration/est_client_cases.hsohost and target share one copy.
wolfcert_unit_*tests/unitprogramswolfcert_estwolfcert-serverwolfcert.build.*samples/.github/workflows/zephyr.ymlruns both onqemu_x86over a cached westworkspace. twister exits 0 when every configuration is filtered out, so
scripts/ci/twister-assert-ran.pyfails a step whose suites did not run.Verification
ctest, clean build.qemu_x86: 13 configurations, 0 failed, 0 errored; EST gate 3/3.http.cfix makestest_session_basic_authfail on targetwith
rc=-3 (out of memory).Not in this PR
FRDM-MCXN947 support, an NVS store backend, ML-DSA, and a SCEP target test —
all phase 2. A TLS-free build for SCEP-only targets is tracked separately.