-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ec_nistp table generation for scalar multiplication #1669
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1669 +/- ##
==========================================
- Coverage 78.27% 78.21% -0.06%
==========================================
Files 567 571 +4
Lines 95227 95464 +237
Branches 13671 13704 +33
==========================================
+ Hits 74538 74670 +132
- Misses 20095 20185 +90
- Partials 594 609 +15 ☔ View full report in Codecov by Sentry. |
f9276cb
to
c72f9a0
Compare
crypto/fipsmodule/ec/ec_nistp.c
Outdated
const size_t felem_num_bytes = felem_num_limbs * sizeof(ec_nistp_felem_limb); | ||
|
||
// table[0] <-- P. | ||
OPENSSL_memcpy(&table[felem_num_limbs * 0], x_in, felem_num_bytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OPENSSL_memcpy(&table[felem_num_limbs * 0], x_in, felem_num_bytes); | |
OPENSSL_memcpy(&table[0], x_in, felem_num_bytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all redundant multiplications...
crypto/fipsmodule/ec/ec_nistp.c
Outdated
// table[0] <-- P. | ||
OPENSSL_memcpy(&table[felem_num_limbs * 0], x_in, felem_num_bytes); | ||
OPENSSL_memcpy(&table[felem_num_limbs * 1], y_in, felem_num_bytes); | ||
OPENSSL_memcpy(&table[felem_num_limbs * 2], z_in, felem_num_bytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
precompute index since it's the same 3 times in a row.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it more clear this way. what's the reason you'd like it precomputed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x_index, y_index, z_index
. That seems more clear to me being able to name it. And it's faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Issues:
N/A
Description of changes:
Generating the precomputed table for scalar multiplication for curves
P-384 and P-521 was implemented for each curve separately.
This commit refactors the code such that a single implementation
can be used with both curves. It is a step towards moving the whole
scalar multiplication code to ec_nistp.c.
Call-outs:
Point out areas that need special attention or support during the review process. Discuss architecture or design changes.
Testing:
How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer?
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.