Repository navigation
Conversation
Zephyr 4.5 moved the lowercase min() and max() macros out of <zephyr/sys/util.h> into <zephyr/sys/minmax.h>, which has to be included explicitly. The module defines WOLFSSL_HAVE_MIN and WOLFSSL_HAVE_MAX for Zephyr 4.3 and later so that wolfSSL uses those macros, so every wolfSSL build on 4.5 fails with an implicit declaration of min(). Include <zephyr/sys/minmax.h> where it exists, and only when wolfSSL defers to Zephyr's macros: CONFIG_WOLFSSL_NO_HAVE_MIN_MAX builds define their own min() function, which the macro would break. Zephyr 4.5 also removed cmake/app/boilerplate.cmake, which the wolfssl_tls_sock sample still included. Use find_package(Zephyr) as the other samples do. Add v4.5.0 to the Zephyr 4.x CI matrix. It needs the same SDK as 4.4.
|
@claude review |
|
There was a problem hiding this comment.
🟡 Changes recommended
The 3072-bit configuration can still allocate 4096-bit integers, and the CI overlays are overwritten, leaving the intended configuration variants untested.
2 open issues
What changed in this PR
Updates wolfSSL’s Zephyr integration for 4.5, reduces handshake stack use, and refreshes release coverage. It also corrects DTLS pending-data reporting so poll loops can detect unread buffered records.
Changes:
- Adds Zephyr 4.5 compatibility updates and refreshes CI release versions.
- Introduces heap-backed SP temporaries and selectable RSA limits, with 4096 bits now the default.
- Adds DTLS regression coverage and RSA/stack configuration scenarios.
| File | Description |
|---|---|
zephyr/user_settings.h |
Maps new math options and disables the legacy RNG alias. |
zephyr/samples/wolfssl_tls_sock/CMakeLists.txt |
Replaces removed boilerplate with Zephyr package discovery. |
zephyr/samples/wolfssl_test/sample.yaml |
Adds RSA-limit and stack-allocation scenarios. |
zephyr/samples/wolfssl_benchmark/sample.yaml |
Converts tags to Twister-compatible list syntax. |
zephyr/Kconfig |
Adds RSA-size and SP heap-allocation options. |
wolfssl/wolfcrypt/settings.h |
Includes Zephyr’s relocated min/max header when available. |
tests/api/test_ssl_rw.h |
Registers the DTLS pending-data test. |
tests/api/test_ssl_rw.c |
Tests multiple DTLS records buffered in one datagram. |
src/ssl_api_rw.c |
Reports unread buffered DTLS data as pending. |
.github/workflows/zephyr.yml |
Replaces older 3.x releases with 3.7.2 LTS. |
.github/workflows/zephyr-4.x.yml |
Adds 4.5.0 and drops 4.1.0. |
.github/scripts/zephyr-4.x/zephyr-test.sh |
Updates the default release and example to 4.3.0. |
.github/scripts/zephyr-4.x/sp_stack.conf |
Adds a stack-backed SP overlay. |
.github/scripts/zephyr-4.x/rsa_3072.conf |
Adds an RSA-3072 overlay. |
.github/scripts/zephyr-4.x/rsa_2048.conf |
Adds an RSA-2048 overlay. |
.github/scripts/zephyr-4.x/builds.txt |
Adds native simulator entries for the new overlays. |
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12044
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): .github/scripts/zephyr-4.x/builds.txt, .github/scripts/zephyr-4.x/rsa_2048.conf, .github/scripts/zephyr-4.x/rsa_3072.conf, .github/scripts/zephyr-4.x/sp_stack.conf, .github/scripts/zephyr-4.x/zephyr-test.sh, .github/workflows/zephyr-4.x.yml, .github/workflows/zephyr.yml, tests/api/test_ssl_rw.h, zephyr/Kconfig, zephyr/samples/wolfssl_benchmark/sample.yaml, zephyr/samples/wolfssl_test/sample.yaml, zephyr/samples/wolfssl_tls_sock/CMakeLists.txt, zephyr/user_settings.h
Coverage: 3 of 3 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Max
There was a problem hiding this comment.
I reviewed this PR and didn't find any bugs. It changes wolfSSL_has_pending() behavior for DTLS and default crypto settings for every Zephyr build, so a human look is still worthwhile.
What was reviewed:
- The new
#elif defined(WOLFSSL_DTLS)branch insrc/ssl_api_rw.c. It is gated onoptions.dtls, so TLS behavior in builds without the other branch's guard does not change. The new DTLS 1.2/1.3 memio test covers it. - The Kconfig-to-
user_settings.hmapping:SP_INT_BITS 2048only under SP_MATH_ALL,ALT_ECC_SIZEexcluded for FIPS and no-malloc builds, andWOLFSSL_SP_SMALL_STACKskipped when SP_NO_MALLOC is set. - Two user-visible changes are worth confirming on purpose: the default RSA maximum moves from 3072 to 4096 bits (more RAM), and the now-unconditional
NO_OLD_RNGNAMEbreaks Zephyr apps that still use theRNGtype name.
Extended reasoning...
The change touches the wolfSSL TLS read path (wolfSSL_has_pending for DTLS), the Zephyr section of wolfssl/wolfcrypt/settings.h, and the Zephyr port's crypto configuration (RSA key-size limits, SP math stack/heap use, ALT_ECC_SIZE). Those defines change struct layouts, so the library and the application have to agree on them. The rest is CI matrix updates and Zephyr sample/build tweaks. No injection, auth or data-exposure surface is involved, but it changes crypto library defaults and a public API's behavior. Together with the breaking-by-default NO_OLD_RNGNAME and the larger RSA default, that makes a maintainer's look worthwhile even though no bugs were found.
903ebf2 to
f9fcfe1
Compare
A DTLS read takes a whole datagram, which can carry more than one record. Once the application has read the first record, the next one sits undecrypted in the input buffer while the socket has nothing left to report. wolfSSL_has_pending() looked at that buffer only with WOLFSSL_TLS_READ_AHEAD, so an application that polls the socket and asks wolfSSL_has_pending() before blocking waited for a datagram that never comes, with the record already in hand. Report the unprocessed rest of the input buffer for DTLS too. TLS without read-ahead never reads past the record it needs, so nothing changes there. The new test delivers two records in one datagram over DTLS 1.2, with an AEAD and a CBC suite, and over DTLS 1.3, and checks wolfSSL_has_pending() after the first read. It fails without this change.
The TLS handshake runs on the stack of the thread that calls connect(), accept() or send(). With RSA enabled, the single-precision math sizes every big integer for the largest RSA key, so ECC code that keeps such integers on the stack needs over 12 KB on a Cortex-M7 for one P-256 chain. Turn on WOLFSSL_SP_SMALL_STACK by default through the new CONFIG_WOLFCRYPT_SP_SMALL_STACK option. It moves the RSA, DH and ECC temporaries of the SP routines to the heap; the rest of wolfSSL keeps its stack use, so WOLFSSL_SMALL_STACK stays off. Also define ALT_ECC_SIZE when RSA or DH is enabled, as configure does for low-resource builds, so ECC keys and points are sized for the largest curve. An ecc_key drops from 4160 to 352 bytes. Neither applies to a FIPS build, whose math comes from the module settings, or to a build without malloc. Measured on nucleo_h743zi with the Zephyr TLS socket tests, the peak stack of an RSA-2048 chain falls from 7.0 KB to 5.3 KB. Together with the ECC curve parameter change in ecc.c, a P-256 chain falls from 12.4 KB to 5.4 KB. The wolfssl_test sample gains a variant with the option off, and the Zephyr 4.x CI builds and runs it on native_sim.
Add a Kconfig choice for the largest RSA modulus: 2048, 3072 or 4096 bits. It sets WOLFSSL_SP_NO_3072 or WOLFSSL_SP_4096, and with them SP_INT_BITS, which sizes the big integers of the RSA and DH math. With WOLFSSL_SP_MATH_ALL the choice also pins SP_INT_BITS, which settings.h otherwise raises to 4096 on 64-bit assembly builds. A FIPS build keeps the sizes its module settings define, so the choice is hidden there. The default is 4096, the limit mbedTLS applies to PSA RSA keys. The previous build could not verify a signature made with an RSA-4096 key, which many root certificates use. A board that only needs RSA-2048 can pick that and save about 4 KB of heap per handshake. The wolfssl_test sample gains variants for 2048 and 3072, each also with custom curves, and the Zephyr 4.x CI builds and runs the 2048, 3072 and 3072 custom curve ones on native_sim.
Twister in Zephyr 4.5 rejects a space-separated tags value and skips the whole sample.
The WOLFSSL_ZEPHYR block in settings.h includes <zephyr/kernel.h>. Through the arch and CMSIS headers that reaches the SoC's device header, and on an STM32 part with an RNG peripheral that header defines RNG as the peripheral pointer. random.h then redefines RNG as WC_RNG, the type name it keeps for old code, so every file that includes a wolfSSL header warns that RNG is redefined, and a build with -Werror, the twister default, fails. Any later use of the peripheral macro in such a file also gets the wolfSSL type. The STM32 port in settings.h defines NO_OLD_RNGNAME for this reason, but a Zephyr build does not use that port. Define NO_OLD_RNGNAME in zephyr/user_settings.h, outside the settings-file block, so it applies with CONFIG_WOLFSSL_SETTINGS_FILE as well and comes before the FIPS compatibility define in settings.h. Code that still names the type RNG has to use WC_RNG; nothing in wolfSSL or its Zephyr samples and tests does.
Zephyr 4.1 is past its support window. Test 4.3, 4.4 and 4.5, and make 4.3 the default of the local test script. The script still selects the SDK image for 4.0 and 4.1, so those versions can be built by hand.
Zephyr 3.4 and 3.5 were short-term releases and are long out of support, while 3.7, the current LTS release supported until July 2029, had no CI job. Run the zephyr.yml scenarios on v3.7.2 with SDK 0.16.8, the SDK that 3.7 documents. 2.7.4 stays for now. The comment on the twister step now names only the limits that still apply.
f9fcfe1 to
281b7c9
Compare
|
Jenkins retest this please |

Description
Builds the Zephyr module on Zephyr 4.5, cuts handshake stack use, and moves the Zephyr CI to the supported releases.
<zephyr/sys/minmax.h>for 4.5 and replace the removedboilerplate.cmakein thewolfssl_tls_socksamplewolfSSL_has_pending()reports the unread rest of a DTLS datagram, so poll loops no longer stall on a buffered recordCONFIG_WOLFCRYPT_SP_SMALL_STACK(default on) moves SP math temporaries to the heap, plusALT_ECC_SIZEwhen RSA or DH is enabled. The P-256 stack figure in the commit message assumes Size ECC curve parameters for the largest curve with SP math #12042NO_OLD_RNGNAMEso STM32 SoC headers that defineRNGbuild with-Werror. Code that still uses theRNGtype name has to switch toWC_RNGTesting
test_wolfSSL_has_pending_dtls_datagram(DTLS 1.2 and 1.3)wolfssl_testtwister scenarios: RSA 2048, 2048 with custom curves, 3072, and SP small stack offzephyr-4.x.yml: adds v4.5.0, drops v4.1.0, and builds the new RSA and SP overlays on native_simzephyr.yml: replaces v3.4.0 and v3.5.0 with the v3.7.2 LTS release; v2.7.4 stays