Repository navigation
Conversation
|
There was a problem hiding this comment.
🟡 Changes recommended
Integer-promotion errors can corrupt results with 8- or 16-bit digits, while assembly-enabled huge builds retain secret-dependent timing despite timing-resistant hardening.
2 open issues
What changed in this PR
This PR adds optional finer-grained timing hardening to wolfCrypt’s SP integer modular exponentiation while refactoring arithmetic helpers to reduce overhead.
Changes:
- Introduces
WC_MODEXP_TIMING_RESISTANTfor fixed-length working values and constant-time Montgomery reduction. - Adds a hardened base-2 exponentiation path and separates unclamped multiplication and squaring from public wrappers.
- Revises constant-time clamping and Montgomery subtraction.
| File | Description |
|---|---|
wolfcrypt/src/sp_int.c |
Implements exponentiation hardening and refactors supporting arithmetic. |
.wolfssl_known_macro_extras |
Registers the new timing-resistance macro. |
Review effort: Balanced
b071e69 to
5dbd362
Compare
|
Jenkins: retest this please |
5dbd362 to
b7c7ce9
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The hardened exponentiation path bypasses sign bookkeeping with WOLFSSL_SP_INT_NEGATIVE, causing negative bases to produce incorrect results such as -9 instead of 9 when squared.
1 open issue
2 resolved since last review
Review effort: Balanced
Added WC_MODEXP_TIMING_RESISTANT to perform constant time operations at a finer level. Improved code to mitigate some of the performance loss.
b7c7ce9 to
cecf475
Compare

Description
Added WC_MODEXP_TIMING_RESISTANT to perform constant time operations at a finer level.
Improved code to mitigate some of the performance loss.
Fixes zd#22770
Testing
./configure
./configure --enable-sp-math-all=huge
./configure --enable-sp-math-all=huge CFLAGS=-DWC_MODEXP_TIMING_RESISTANT