Skip to content

Regenerate asm with constant tables in read-only sections - #12274

Merged
rlm2002 merged 1 commit into
wolfSSL:v7.0.0-user-spacefrom
kaleb-himes:v7-asm-tables-rodata
Nov 26, 2026
Merged

rlm2002 merged 1 commit into
wolfSSL:v7.0.0-user-spacefrom
kaleb-himes:v7-asm-tables-rodata

Conversation

@kaleb-himes

Copy link
Copy Markdown
Contributor

Regenerated from the scripts generators. Constant tables move from .data / __DATA,__data to .rodata / __TEXT,__const, so the FIPS in-core integrity HMAC covers them. Previously an altered table (e.g. the AES-GCM counters) still passed the POST.

The SHA-512 AVX2/RORX transforms now compute the K-table end pointer at run time instead of storing a relocated pointer in .data.

Description

Please describe the scope of the fix or feature addition.

Fixes zd#

Testing

How did you test?

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Regenerated from the scripts generators. Constant tables move from
.data / __DATA,__data to .rodata / __TEXT,__const, so the FIPS in-core
integrity HMAC covers them. Previously an altered table (e.g. the
AES-GCM counters) still passed the POST.

The SHA-512 AVX2/RORX transforms now compute the K-table end pointer
at run time instead of storing a relocated pointer in .data.
Copilot AI balanced review requested due to automatic review settings November 25, 2026 23:24
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +316 B, text +16,216 B (+5.9%, 299,004 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.

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.

🔵 Needs a closer look

Missing FIPS integrity sources and test results leave relocated-table coverage unverified, requiring maintainer validation of ELF/Mach-O measurement boundaries and POST tamper detection.

No open issues 🎉

What changed in this PR

Regenerates wolfCrypt assembly to place constant tables in read-only sections, supporting coverage by the FIPS in-core integrity HMAC.

Changes:

  • Moves x86 constants from .data to .rodata and Apple constants from __DATA,__data to __TEXT,__const.
  • Replaces stored SHA-512 AVX2/RORX K-table end pointers with runtime calculations in GNU and MASM assembly.
  • Adjusts SHA-512 stack allocation to hold the calculated pointers.
File Description
wolfcrypt/​src/​sp_x86_64_asm.S Moves modular-inversion constants to read-only sections.
wolfcrypt/​src/​sha512_asm.S Moves constants and computes K-table end pointers at runtime.
wolfcrypt/​src/​sha512_asm.asm Computes K-table end pointers at runtime; adjusts stack allocation.
wolfcrypt/​src/​sha3_asm.S Moves SHA-3 constants to read-only sections.
wolfcrypt/​src/​sha256_asm.S Moves SHA-256 constants to read-only sections.
wolfcrypt/​src/​port/​ppc64/​ppc64-sha512-asm.S Moves Apple SHA-512 constants to __TEXT,__const.
wolfcrypt/​src/​port/​ppc64/​ppc64-sha3-asm.S Moves Apple SHA-3 constants to __TEXT,__const.
wolfcrypt/​src/​port/​ppc64/​ppc64-sha256-asm.S Moves Apple SHA-256 constants to __TEXT,__const.
wolfcrypt/​src/​port/​ppc64/​ppc64-aes-asm.S Moves Apple AES constants to __TEXT,__const.
wolfcrypt/​src/​port/​ppc32/​ppc32-sha512-asm.S Moves Apple SHA-512 constants to __TEXT,__const.
wolfcrypt/​src/​port/​ppc32/​ppc32-sha3-asm.S Moves Apple SHA-3 constants to __TEXT,__const.
wolfcrypt/​src/​port/​ppc32/​ppc32-sha256-asm.S Moves Apple SHA-256 constants to __TEXT,__const.
wolfcrypt/​src/​port/​ppc32/​ppc32-aes-asm.S Moves Apple AES constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​thumb2-sha512-asm.S Moves Apple SHA-512 constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​thumb2-sha3-asm.S Moves Apple SHA-3 constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​thumb2-sha256-asm.S Moves Apple SHA-256 constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​thumb2-poly1305-asm.S Moves Apple Poly1305 clamp constant to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​thumb2-mlkem-asm.S Moves Apple ML-KEM tables to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​thumb2-chacha-asm.S Moves Apple ChaCha constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​thumb2-aes-asm.S Moves Apple AES tables to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-sha512-asm.S Moves Apple SHA-512 constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-sha3-asm.S Moves Apple SHA-3 constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-sha256-asm.S Moves Apple SHA-256 constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-sha1-asm.S Moves Apple SHA-1 constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-poly1305-asm.S Moves Apple Poly1305 clamp constant to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-mlkem-asm.S Moves Apple ML-KEM tables to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-mldsa-asm.S Moves Apple ML-DSA tables to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-frodokem-asm.S Moves Apple SHA-3 constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-curve25519.S Moves Apple Curve25519 base constant to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-chacha-asm.S Moves Apple ChaCha constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-aes-asm.S Moves Apple AES tables to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-32-sha512-asm.S Moves Apple SHA-512 constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-32-sha3-asm.S Moves Apple SHA-3 constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-32-sha256-asm.S Moves Apple SHA-256 constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-32-poly1305-asm.S Moves Apple Poly1305 clamp constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-32-mlkem-asm.S Moves Apple ML-KEM tables to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-32-mldsa-asm.S Moves Apple ML-DSA tables to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-32-chacha-asm.S Moves Apple ChaCha constants to __TEXT,__const.
wolfcrypt/​src/​port/​arm/​armv8-32-aes-asm.S Moves Apple AES tables to __TEXT,__const.
wolfcrypt/​src/​poly1305_asm.S Moves Poly1305 constants to read-only sections.
wolfcrypt/​src/​fe_x25519_asm.S Moves field-arithmetic constants to read-only sections.
wolfcrypt/​src/​chacha_asm.S Moves ChaCha and combined Poly1305 constants to read-only sections.
wolfcrypt/​src/​aes_xts_asm.S Moves AES-XTS constants to read-only sections.
wolfcrypt/​src/​aes_x86_64_asm.S Moves AES counter-mode constants to read-only sections.
wolfcrypt/​src/​aes_gcm_asm.S Moves AES-GCM counters, masks, and constants to read-only sections.

Review effort: Balanced

@rlm2002

rlm2002 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Thanks @kaleb-himes!

@rlm2002
rlm2002 merged commit 8bef340 into wolfSSL:v7.0.0-user-space Nov 26, 2026
444 of 447 checks passed
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.

5 participants