Repository navigation
Add WOLFSSL_AES_NO_TOUCH_LINES build option and benchmark AES-256-XTS - #11962
Merged
Merged
Conversation
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The CMake logic can override WC_NO_CACHE_RESISTANT on RISC-V and ignore an explicit touch-lines opt-out when the processor string is missing or unrecognized, causing unwanted per-lookup table scans.
2 open issues
What changed in this PR
Adds targeted control over AES cache-line touching in wolfCrypt and extends XTS benchmarking to cover AES-256 alongside AES-128.
Changes:
- Introduces
WOLFSSL_AES_NO_TOUCH_LINESto disable the RISC-V default without disabling other hardening. - Adds Autotools and CMake controls, generated-header definitions, and documentation.
- Shares the XTS benchmark implementation across key sizes and adds key-size-specific result labels.
| File | Description |
|---|---|
wolfcrypt/src/aes.c |
Honors the opt-out macro when applying the RISC-V default. |
wolfcrypt/benchmark/benchmark.c |
Adds AES-256-XTS benchmarks and distinct result labels. |
doc/ALGORITHM_DEFINES.md |
Documents the new opt-out macro. |
configure.ac |
Adds the touch-lines option and configure summary output. |
CMakeLists.txt |
Adds the touch-lines option and macro selection. |
cmake/options.h.in |
Exports both touch-lines macros in the generated header. |
Review effort: Balanced
dgarske
force-pushed
the
riscv_aes_bench
branch
from
November 3, 2026 00:28
5fe5f4f to
6161c0f
Compare
SparkiDev
approved these changes
Nov 3, 2026
Contributor
|
Jenkins: retest this please |
Contributor
|
Static memory google test failing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Two AES changes that came out of benchmarking wolfCrypt on a RISC-V rv64gc core (PolarFire SoC Video Kit, SiFive U54, Linux):
WOLFSSL_AES_NO_TOUCH_LINESclears theWOLFSSL_AES_TOUCH_LINESdefault thatwolfcrypt/src/aes.capplies to every__riscvbuild, without the rest ofWC_NO_CACHE_RESISTANT. Before, the only way off the per-lookup table scan was--disable-harden, which also drops timing resistance and blinding; the scan makes the C AES modes far slower than the plain T-table code the RISC-V assembly tier already uses. An explicitWOLFSSL_AES_TOUCH_LINESstill wins.--enable-aes-touch-lines=yes|no. The default leaves aes.c's choice alone; the value is shown in the configure summary.WOLFSSL_AES_TOUCH_LINES=default|yes|no.defaultleaves aes.c's choice alone, so a-DWC_NO_CACHE_RESISTANTinCMAKE_C_FLAGSkeeps working;yesandnoemit their macro whateverCMAKE_SYSTEM_PROCESSORsays. Both macros are inoptions.h.in.doc/ALGORITHM_DEFINES.mddocuments the new define next toWOLFSSL_AES_TOUCH_LINES.bench_aesxtsnow times AES-256-XTS as well as AES-128-XTS. The per-key body is a staticbench_aesxts_key()taking the key, its length and the result labels;bench_aesxts()calls it underWOLFSSL_AES_128with a 32-byte key and underWOLFSSL_AES_256with a 64-byte key. The result lines areAES-128-XTS-enc/-decandAES-256-XTS-enc/-dec(plus the-stream-variants withWOLFSSL_AESXTS_STREAM), so anything parsing the oldAES-XTS-enclabel needs the new names.Testing
Checked by configuring with autotools and cmake on x86-64 and with a riscv64 cross compiler for default, yes and no, and by preprocessing
aes.con riscv64 to confirm the macro is set only when intended. The benchmark change ran on the Video Kit with both the C and the--enable-riscv-asmbuilds and on a host--enable-aesxtsbuild; the new configure option was not benchmarked on hardware.