Closed Bug 836562 Opened 11 years ago Closed 11 years ago

Use Horner's rule to calculate the elliptic curve polynomial in ec_GFp_validate_point

Categories

(NSS :: Libraries, defect, P2)

Tracking

(Not tracked)

RESOLVED FIXED
3.14.3

People

(Reporter: wtc, Assigned: wtc)

Details

Attachments

(1 file, 2 obsolete files)

Attached patch Patch (obsolete) — Splinter Review
The attached patch uses Horner's rule to calculate the
x^3 + a*x + b polynomial for elliptic curves over the
prime field.

This saves one group->meth->field_mul operation.
Attachment #708380 - Flags: review?(agl)
Attachment #708380 - Flags: feedback?(douglas)
mp_add, mp_sub, and mp_mul all allow an in/out argument.
I take advantage of this in my patch.

This adds no overhead to mp_add and mp_sub. But to support
an in/out argument, mp_mul needs to copy the in/out argument
to an internal temp variable.

So, if we don't use an in/out argument with group->meth->field_mul,
we can avoid this copying inside mp_mul (which is eventually
called). Since we are copying only 32 - 65 bytes for P-256
and P-521 curves, this copying seems inexpensive, in exchange
for code clarity.

If you prefer this patch, please let me know.
Comment on attachment 708380 [details] [diff] [review]
Patch

I'm happy with either form of this patch (that is, with the additional |tmp| variable or not.)
Attachment #708380 - Flags: review?(agl) → review+
I checked in the patch that uses a local tmp variable. But
I removed the comment to avoid clutter in the code.

Checking in ecp_aff.c;
/cvsroot/mozilla/security/nss/lib/freebl/ecl/ecp_aff.c,v  <--  ecp_aff.c
new revision: 1.5; previous revision: 1.4
done
Attachment #708380 - Attachment is obsolete: true
Attachment #708383 - Attachment is obsolete: true
Attachment #708380 - Flags: feedback?(douglas)
Attachment #708916 - Flags: checked-in+
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Looks good to me!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: