Repository navigation
zephyr: build the FIPS v5 boundary - #11879
jackctj117 wants to merge 2 commits into
Conversation
|
There was a problem hiding this comment.
🟡 Changes recommended
Legacy Zephyr header compatibility and concurrent initialization behavior need correction before approval.
2 open issues
What changed in this PR
This PR enables the Zephyr module to build a FIPS v5 bundle without modifying sources inside the FIPS boundary.
Changes:
- Defines
BUILDING_WOLFSSLfor library sources to prevent duplicate KDF wrapper symbols. - Adds and distributes compatibility headers for legacy random and time includes.
- Enables configuration macros needed by v5 initialization and ECDSA self-tests.
| File | Description |
|---|---|
zephyr/user_settings.h |
Adds FIPS v5 thread-local and ECDSA settings. |
zephyr/include.am |
Includes both compatibility headers in source distributions. |
zephyr/fips-v5-compat/random/rand32.h |
Maps the legacy random include to newer Zephyr headers. |
zephyr/fips-v5-compat/posix/time.h |
Maps the legacy time include to available headers. |
zephyr/CMakeLists.txt |
Adds library-only build definitions and the v5 compatibility include path. |
Review effort: Balanced
|
retest this please |
|
@claude review |
There was a problem hiding this comment.
Beyond the inline findings, I checked whether adding BUILDING_WOLFSSL only to the library in zephyr/CMakeLists.txt could make the library and the app disagree on struct layout. It can't: in the headers, that define only changes visibility, WARN_UNUSED_RESULT and deprecation attributes on declarations, and the top-level CMakeLists.txt already sets it the same way (PRIVATE).
Extended reasoning...
The PR changes Zephyr module build glue, adds two include shims and adds a FIPS v5.2.3 user_settings file. The inline findings already flag the settings-file problems. The hunt stopped at its bug limit rather than running out of candidates, so this is not an approval. The note above records one more concern that was checked and ruled out: the library-only define changes no struct layout.
Findings marked 🟡 are optional suggestions and need no follow-up push.
Frauschi
left a comment
There was a problem hiding this comment.
Nice to have the v5 boundary building. The two things I'd like sorted before this goes in are the integrity-layout guards, which v5 doesn't get yet, and the assembly that is still reachable through the Kconfig path. The rest are smaller.
0add508 to
5398f40
Compare
Frauschi
left a comment
There was a problem hiding this comment.
Thanks for the quick rework, the earlier comments all look addressed. A few new things came up, mostly around the 5.2.1 and v6 paths and the Kconfig options that still reach into the v5.2.3 set.
|
@jackctj117 also, the Jenkins failure is legit. |
5398f40 to
922848a
Compare
Define BUILDING_WOLFSSL for the library sources so the v5 kdf.c, which predates libwolfssl_sources.h, no longer defines its wc_*_fips wrappers twice. Map the v5 random.c's <random/rand32.h> and <posix/time.h> onto the current headers; the module needs Zephyr 3.7 or later anyway, as CONFIG_WOLFCRYPT_FIPS selects STATIC_INIT_GNU. Define NO_THREAD_LS, since THREAD_LS_T is empty on Zephyr, and WOLFSSL_ECDSA_SET_K for the ECDSA CAST. The v5 wc_GenerateSeed() is a bare sys_rand_get(), so seed the DRBG from the zephyr,entropy device or the Zephyr CSPRNG instead, through wolfSSL_Init() and, for wolfCrypt-only builds, from an APPLICATION-level hook after the power-on self test. Apply the integrity-layout guards to every FIPS boundary instead of only the one with assembly, and keep the symmetric assembly off under FIPS v2, v5 and v6, whose in-boundary assembly this module does not build. Keep the PQC options off under v2 and v5, whose boundaries have no SHAKE.
Select the bundle under CONFIG_WOLFCRYPT_FIPS_V5 with CONFIG_WOLFCRYPT_FIPS_V5_2_3. user_settings.h then sets the 5.2.3 version and includes user_settings-fips-v5.2.3.h for the algorithm set of --enable-fips=v5.2.3, as it does user_settings-fips-v7.h for v7; TLS, certificate and platform options keep following Kconfig. The choice selects the RSA, ECC and P-256 options, which user_settings.h would otherwise disable after the set.
922848a to
e43b6e5
Compare
Frauschi
left a comment
There was a problem hiding this comment.
LGTM, only Jenkins failure is this:
unrecognized macros used:
CONFIG_WOLFCRYPT_FIPS_LEGACY_ASM
CONFIG_WOLFCRYPT_FIPS_V5_2_3
add well-formed but unknown macros to .wolfssl_known_macro_extras at top of source tree.


Description
Master's Zephyr module builds the v7 and FIPS Ready boundaries but not a v5 one. Dropping in a v5 bundle fails in three ways. This PR fixes all three without touching any source inside the boundary, and adds v5.2.3 as a Kconfig choice.
zephyr: build the FIPS v5 boundary
wc_PRF_fips,wc_PRF_TLSv12_fips,wc_Tls13_HKDF_Extract_fipsandwc_SSH_KDF_fipsare defined twice at link. The v5kdf.cpredateslibwolfssl_sources.h, so nothing definesBUILDING_WOLFSSL.types.hthen includeswc_compat.h, which reachesfips.hbeforekdf.csetsFIPS_NO_WRAPPERS. The module now definesBUILDING_WOLFSSLfor the library sources only, as the top-levelCMakeLists.txtalready does.random.ccannot find<random/rand32.h>. UnderCONFIG_WOLFCRYPT_FIPS_V5,zephyr/fips-v5-compat/is added to the library's include path. Itsrandom/rand32.handposix/time.hshims map onto the current headers; the module needs Zephyr 3.7 or later anyway, becauseCONFIG_WOLFCRYPT_FIPSselectsSTATIC_INIT_GNU.NO_THREAD_LS, becauseTHREAD_LS_Tis empty on Zephyr andHAVE_THREAD_LSwould only drop the ECC/SP cache locks;WOLFSSL_ECDSA_SET_K, which the ECDSA CAST needs;WC_RNG_SEED_CB, withwolfssl_zephyr_seedasWC_GENERATE_SEED_DEFAULT, because both v5 bundles'wc_GenerateSeed()is a baresys_rand_get().zephyr/zephyr_fips_seed.creads thezephyr,entropydevice when its chosen node is enabled, or else the Zephyr CSPRNG; a board with neither fails the build unlessCONFIG_TEST_RANDOM_GENERATORis set.wolfSSL_Init()registers it, and an APPLICATION-levelSYS_INIThook, which runs after the POST constructor, registers it for wolfCrypt-only builds and logs a failure.CONFIG_LINKER_SORT_BY_ALIGNMENTcheck, the no-section-splitting flags and the dedicated rodata section. The Kconfig help and the README say to setCONFIG_LINKER_SORT_BY_ALIGNMENT=n, which Zephyr defaults on.WOLFCRYPT_FIPS_LEGACY_ASM). Theiraes.c/sha256.cexpect the boundary's ownarmv8-*.cassembly, which this module does not build, and on x86_64 theirsha256.cwould call the tree'ssha256_asm.Sfrom outside the boundary.CONFIG_WOLFCRYPT_ASMstill accelerates the SP math.zephyr: add FIPS v5.2.3 as a Kconfig choice
CONFIG_WOLFCRYPT_FIPS_V5_2_3, under a new v5 bundle choice that defaults to 5.2.1, setsHAVE_FIPS_VERSION_PATCH 3.user_settings.hthen includesuser_settings-fips-v5.2.3.hfor the--enable-fips=v5.2.3algorithm set, the way v7 includes its own file. TLS, certificate and platform options keep following Kconfig.WOLFSSL_RSA,WOLFSSL_ECCandWOLFSSL_ECC_256, whichuser_settings.hwould otherwise be able to disable after the set.WOLFSSL_SP_SMALL_STACKmoves the 4096-bit mod-exp temporaries to the heap. It only affectssp_*.c, which are outside the boundary.Testing
user_settings.h, each with its Kconfig defaults: no warnings with-Wall, no symbol defined in more than one object,ssl.oreferences the seed callback for both,CONFIG_WOLFSSL_CERT_GENhonoured, and no SHAKE symbol in the v5.2.3sha3.o.zephyr_fips_seed.ccompiled against stub Zephyr headers that reproduce the devicetree token macros, for each seed source, with no warnings under-Wall -Wextra: an enabled chosen node uses the entropy driver, a disabled or missing one falls back to the CSPRNG, and the#errorfires with no source.Checklist