Repository navigation
ecc: return infinity for P + (-P) with equal z in the projective add - #11921
Open
yosuke-wolfssl wants to merge 1 commit into
Open
yosuke-wolfssl wants to merge 1 commit into
yosuke-wolfssl wants to merge 1 commit into
Conversation
- _ecc_projective_add_point doubles only when the stored x, y and z of both points are equal; the p - Q->y operand is removed. - ecc_projective_add_point_safe drops the nInf note and override - test_wolfSSL_EC_POINT checks EC_POINT_add(P, -P) in both orders and EC_POINT_mul(1*G + 1*(-G)) give the point at infinity. - test_ecc_fault_whitebox comments describe the add's z == 0 result for A = -B. Issue: F-16891, F-16382
Contributor
Author
|
@claude review |
|
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11921
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-bugs
Coverage: 2 of 3 in-scope changed file(s) opened by the reviewer; not opened: tests/unit-mcdc/test_ecc_fault_whitebox.c
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
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.
Problem
_ecc_projective_add_pointdoubles instead of adding when the two operands have equal stored x and z andP->y == p - Q->y. That input is P = -Q, whose sum is the point at infinity, so the function returns 2P.Fix (
wolfcrypt/src/ecc.c)_ecc_projective_add_pointdoubles only when x, y and z are all equal. P = -Q now goes through the general formula and returns z = 0, whichecc_mapturns into (0, 0, 1). The unusedp - Q->ycomputation is removed, and the doc comment states the z = 0 form of infinity.ecc_projective_add_point_safedropsnInf. Its existing z == 0 branch now handles A = -B for both equal and different z, and still sets the infinity flag.The SP math
sp_ecc_proj_add_point_*path compares U/S values instead and is unaffected.Closes f-16891 and f-16382.
Tests
test_wolfSSL_EC_POINT:EC_POINT_add(P, -P)in both orders is at infinity.test_wolfSSL_EC_POINT:EC_POINT_mul(1*G + 1*(-G))is at infinity. This reaches_safewith A = -B and equal z throughecc_mul2add, and covers thenInfremoval.test_ecc_fault_whitebox.c: comments updated for the new path. No change to test vectors.Verification
--enable-opensslextra,--disable-eccshamir,--disable-harden,--enable-all:test_wolfSSL_EC_POINTandtestwolfcryptpass.-Werror(Ubuntu 24.04): clean build, tests pass.nInf), only theEC_POINT_addcheck fails.test_ecc_whiteboxandtest_ecc_fault_whiteboxpass.