Skip to content

Make SHA3_SMALL a Zephyr Kconfig option, off by default - #12239

Open
Frauschi wants to merge 1 commit into
wolfSSL:masterfrom
Frauschi:zephyr-sha3-small-kconfig
Open

Frauschi wants to merge 1 commit into
wolfSSL:masterfrom
Frauschi:zephyr-sha3-small-kconfig

Conversation

@Frauschi

Copy link
Copy Markdown
Member

Description

The Zephyr module defined WOLFSSL_SHA3_SMALL for every build with ML-KEM, ML-DSA, XMSS or Falcon. That small Keccak permutation made ML-KEM-768 25-35% and ML-DSA-65 36-43% slower on Cortex-M7 and Cortex-M33 to save about 3 KB of flash and 170 bytes of stack. This turns it into an opt-in Kconfig option.

Changes

  • Add CONFIG_WOLFSSL_SHA3_SMALL, default n, offered only where the C permutation is built (no Arm assembly, no FIPS v2/v5/v7/Ready, no user settings file).
  • Map it to WOLFSSL_SHA3_SMALL in zephyr/user_settings.h instead of forcing the define in the PQC block.

Upgrade note

  • PQC builds without the Arm assembly grow by about 3 KB of flash and 170 bytes of stack; set CONFIG_WOLFSSL_SHA3_SMALL=y to keep the old size.
  • FIPS v6 builds compile sha3.c differently and need the usual rehash.

Testing

  • Existing Zephyr CI: the wolfssl_tls_sock and wolfssl_tls_thread samples (ML-KEM on qemu_x86) now build the full C permutation.

Copilot AI balanced review requested due to automatic review settings November 23, 2026 18:22

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.

🟢 Approval recommended

There are no active review issues for the change making Zephyr’s smaller SHA-3/SHAKE implementation opt-in.

No open issues 🎉

What changed in this PR

Makes the smaller SHA-3/SHAKE implementation opt-in for Zephyr, favoring PQC performance by default at the cost of increased flash and stack usage.

Changes:

  • Adds CONFIG_WOLFSSL_SHA3_SMALL, disabled by default and restricted to compatible configurations.
  • Maps the new option to WOLFSSL_SHA3_SMALL instead of enabling it automatically for PQC builds.
File Description
zephyr/​user_settings.h Replaces the forced PQC small-permutation define with the Kconfig-controlled mapping.
zephyr/​Kconfig Adds the small-permutation option with assembly, FIPS, and user-settings restrictions.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +108 B, text +13,800 B (+4.9%, 296,380 B / 67,108,864 B, total: 0% used)
  • RAM: bss +49 B, datas +16 B (+0.1%, 58,423 B / 983,040 B, total: 6% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@Frauschi

Copy link
Copy Markdown
Member Author

@claude review

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code review found no issues

No high-confidence issues detected in this change.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #12239

Scan targets checked: wolfssl-pr-general
Review type: general (no scan target covers the changed files)
Coverage: 2 of 2 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

The module's user_settings.h defined WOLFSSL_SHA3_SMALL for every build
with ML-KEM, ML-DSA, XMSS or Falcon enabled, FIPS v6 builds included.
The small Keccak permutation runs about 1.5x slower: on STM32H743
(Cortex-M7) and RW612 (Cortex-M33) with the C permutation at -O2, it
made BlockSha3 45-50% slower, ML-KEM-768 25-35% slower and ML-DSA-65
key generation and verification 36-43% slower. It saves about 3 KB of
flash (2.8 KB at -Os) and 170 bytes of stack.

Add CONFIG_WOLFSSL_SHA3_SMALL, default n, so PQC builds get the fast
permutation and size-constrained targets can still opt in. The option
is only offered where the C permutation is built: the Arm assembly
BlockSha3 ignores WOLFSSL_SHA3_SMALL, FIPS v7 and FIPS Ready take their
SHA-3 settings from user_settings-fips-v7.h, and FIPS v2 and v5 never
defined it. Builds that supply their own settings file are unaffected.

PQC builds without the Arm assembly grow by about 3 KB of flash and 170
bytes of stack unless they enable the option. Under FIPS v6 the
compiled sha3.c changes, so the module has to be rehashed as after any
other configuration change.
@Frauschi
Frauschi force-pushed the zephyr-sha3-small-kconfig branch from d6a45dd to 03eaddf Compare November 24, 2026 10:31
@Frauschi Frauschi assigned wolfSSL-Bot and unassigned Frauschi Nov 24, 2026
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