Repository navigation
Conversation
|
@claude review |
There was a problem hiding this comment.
🔵 Needs a closer look
Cryptographic arithmetic across feature-gated build variants needs final human validation despite no identified blocking findings.
No open issues 🎉
What changed in this PR
Adds even-modulus exponentiation support for RSA public-only and verify-only builds where the constant-time implementation is omitted.
Changes:
- Adds a non-constant-time fallback for even moduli.
- Extends regression tests with varied bases, exponents, and even moduli.
- Adds CI coverage for RSA public-only builds with public multiprecision APIs enabled.
| File | Description |
|---|---|
| wolfcrypt/test/test.c | Tests even-modulus exponentiation through both APIs. |
| wolfcrypt/src/sp_int.c | Implements and routes calls to the even-modulus fallback. |
| .github/configs/os-check-linux.json | Adds a targeted RSA public-only CI configuration. |
Review effort: Balanced
|
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11849
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs
Not reviewed (no scan target covers them): .github/configs/os-check-linux.json
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: Lite
|
Why are we handling even modulus values??? |
@SparkiDev If you'd rather not support even moduli there, I can return MP_VAL instead and skip that test for this build. Which do you prefer? |
9d3f862 to
dcdf6d2
Compare
|
@claude review |
There was a problem hiding this comment.
I reviewed the reworked version of this PR and didn't find any bugs. It changes the result of sp_exptmod_nct for even moduli in RSA public-only and verify-only builds, so a maintainer should still sign off on the new MP_VAL behaviour.
What was reviewed:
- The new even-modulus guard in
sp_exptmod_nctmatches the guard around both_sp_exptmod_exdefinitions (line 13155), so the call can't reach an undefined function. - The test's MP_VAL condition is the exact complement wherever
sp_exptmod_nctis compiled (WOLFSSL_SP_MATH_ALLorWOLFSSL_HAVE_SP_DH). In non-SP_MATH_ALL builds DH is on, so the generic path is taken. - In RSA public-only builds with DH on, an even modulus now goes to the generic path instead of falling through to Montgomery. The two new CI configs cover the DH-off and DH-on cases.
Extended reasoning...
The change touches the non-constant-time modular exponentiation in wolfcrypt/src/sp_int.c, its test in wolfcrypt/test/test.c and two CI build configs. This is crypto code: any caller that passes an even modulus in RSA verify-only or public-only builds without DH now gets MP_VAL instead of a silently wrong result. The approach has changed since my earlier review (the PR description still mentions a new generic fallback that isn't in the current diff), and a maintainer commented before the latest commits. Because this is crypto behaviour with an API-visible error change, approval was not appropriate.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11849
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs
Not reviewed (no scan target covers them): .github/configs/os-check-linux.json
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

Description
In RSA public-only and verify-only builds (WOLFSSL_RSA_PUBLIC_ONLY/WOLFSSL_RSA_VERIFY_ONLY), constant-time exponentiation (_sp_exptmod_ex) is disabled to reduce code size. Montgomery modular exponentiation in sp_exptmod_nct only supports odd moduli, leaving no handler for even moduli in these configurations.
Testing
Checklist