Skip to content

wolfCrypt SRAM PUF: configurable error correction and footprint - #11057

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:puf_configurable
Open

wolfCrypt SRAM PUF: configurable error correction and footprint#11057
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:puf_configurable

Conversation

@dgarske

@dgarske dgarske commented Aug 5, 2026

Copy link
Copy Markdown
Member

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_T selects 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() and WC_PUF_PROFILE_ID let an application persist the profile with its helper data and detect an enroll/reconstruct build mismatch.
  • Profile selection via ./configure --enable-puf=small|balanced|strong and 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).

@dgarske dgarske self-assigned this Aug 5, 2026
Copilot AI lite review requested due to automatic review settings August 5, 2026 00:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a WC_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.

Comment thread wolfssl/wolfcrypt/puf.h
Comment thread wolfcrypt/test/test.c Outdated
Comment thread scripts/puf_bch_genpoly.py Outdated
@dgarske

dgarske commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

Jenkins retest this please

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

@dgarske

dgarske commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

Jenkins retest this please

@dgarske dgarske assigned danielinux and wolfSSL-Bot and unassigned dgarske Aug 6, 2026
@dgarske
dgarske requested a review from danielinux August 6, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants