Created attachment 708380 [details] [diff] [review] Patch 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.
Created attachment 708383 [details] [diff] [review] Patch with a local tmp variable (for reference only) 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.)
Created attachment 708916 [details] [diff] [review] Patch with a local tmp variable, v2 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
Looks good to me!