wolfCrypt SRAM PUF: configurable error correction and footprint - #11057
wolfCrypt SRAM PUF: configurable error correction and footprint#11057dgarske wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes the wolfCrypt SRAM PUF BCH(127,k,t) fuzzy-extractor configurable (t-profile and number of codewords) while keeping the default build byte-for-byte compatible with prior releases. It also adds a way for applications to query/persist the selected profile to detect enrollment/reconstruction mismatches.
Changes:
- Add configurable PUF parameters (
WC_PUF_BCH_T,WC_PUF_NUM_CODEWORDS), derived sizing macros, and aWC_PUF_PROFILE_ID/wc_PufGetParams()API for mismatch detection. - Generalize BCH encode/decode implementation to work across supported (t,k) profiles and adjust stable/helper data packing accordingly.
- Update unit tests, build-system toggles (Autoconf/CMake), and Doxygen docs for profile selection and sizing.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| wolfssl/wolfcrypt/puf.h | Adds configuration knobs, derived sizing macros, profile fingerprint, and new public wc_PufGetParams() declaration. |
| wolfcrypt/src/puf.c | Implements generalized BCH encode/decode for selectable profiles and adds wc_PufGetParams() implementation. |
| wolfcrypt/test/test.c | Updates PUF unit test to be profile-parameterized (dynamic SRAM fill, noise injection, new failure-mode expectations). |
| scripts/puf_bch_genpoly.py | Adds a generator script for BCH generator polynomials/KAT vectors used by puf.c. |
| doc/dox_comments/header_files/puf.h | Updates public documentation/examples to reflect configurable sizing and the new params API. |
| configure.ac | Adds `--enable-puf=small |
| CMakeLists.txt | Adds WOLFSSL_PUF_PROFILE cache option and maps to WC_PUF_BCH_T definitions when PUF is enabled. |
Suppressed comments (1)
wolfcrypt/test/test.c:24126
- The Test 4b temporary tooNoisySram buffer is also allocated on the stack and scales with WC_PUF_RAW_BYTES. This should follow the same small-stack pattern as the other PUF test buffers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
076941b to
367232d
Compare
|
Jenkins retest this please |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Suppressed comments (2)
wolfssl/wolfcrypt/puf.h:43
- The build-flag documentation here is out of sync with the actual build-system support added in this PR: configure.ac/README/.github/workflows/CMakeLists all accept a “strongest” profile (t=15), but this header only documents small|balanced|strong. This can mislead users into thinking t=15 isn’t supported via configure/CMake.
Build: ./configure --enable-puf[=small|balanced|strong] (auto-enables
HKDF). CMake: -DWOLFSSL_PUF=yes with
-DWOLFSSL_PUF_PROFILE=small|balanced|strong.
CMakeLists.txt:2323
- CMake currently has no supported way to set WC_PUF_NUM_CODEWORDS such that BOTH (1) the library is compiled with the override and (2) the generated wolfssl/options.h records it for separately-built applications. The comment says it can be set via CFLAGS, but CMake’s options.h generation only reflects macros present in WOLFSSL_DEFINITIONS (see the foreach(DEF IN LISTS WOLFSSL_DEFINITIONS) block later in this file), so a CFLAGS-only override risks an ABI/config mismatch and thus a silently wrong key/profile ID at the application level.
# PUF BCH error-correction profile (only surfaced when PUF is enabled).
# Other t values and WC_PUF_NUM_CODEWORDS can still be set via CFLAGS.
add_option("WOLFSSL_PUF_PROFILE"
"PUF BCH profile: balanced (t=10), small (t=7), strong (t=13), strongest (t=15)"
"balanced" "balanced;small;strong;strongest")
|
Jenkins retest this please |
Summary
Makes the wolfCrypt SRAM PUF configurable instead of fixed at BCH(127,64,t=10) with 16 codewords. The default build is unchanged and byte-for-byte compatible with prior releases (identical identity, derived key, and helper data).
Features
WC_PUF_BCH_Tselects the BCH error-correction profile: t=7, t=10 (default), t=13, t=15. Higher t corrects more bit flips per 127-bit codeword; unsupported values are a compile-time error.WC_PUF_NUM_CODEWORDS(default 16) trades SRAM footprint and helper-data size against derived-key entropy.wc_PufGetParams()andWC_PUF_PROFILE_IDlet an application persist the profile with its helper data and detect an enroll/reconstruct build mismatch../configure --enable-puf=small|balanced|strongand CMake-DWOLFSSL_PUF_PROFILE=...; other values (and codeword count) via CPPFLAGS.Testing
Profile-parametrized unit tests, plus on-silicon regression across STM32 Cortex-M0+/M4/M7/M33 boards (see the wolfssl-examples-stm32 companion PR).