Skip to content
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

P-256 scalar mul and modular inverse from s2n-bignum #1794

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jargh
Copy link
Contributor

@jargh jargh commented Aug 23, 2024

Issues:

Resolves #ISSUE-NUMBER1
Addresses #ISSUE-NUMBER2

Description of changes:

This makes use of s2n-bignum's P-256 functions for both the fresh-point scalar multiplication and the modular (actually Montgomery) inverse that arises in conversion from Jacobian to affine.

Call-outs:

Basic #if/#else/#endif versioning is a bit crude and maybe there is a better way to do this stylistically.
Only tested on a few platforms and may need more work to make it completely portable, robust for FIPS builds etc.

Testing:

Ran "ninja run_tests" and a few other aws-lc tests.

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.

When the usual architectural constraints are met, the preprocessor
macro EC_P256_USE_S2N_BIGNUM is set. That in turn triggers the
replacement of the existing Fermat inverse in p256-nistz.c with the
markedly faster and formally verified divstep-based code from
s2n-bignum.
This replaces the general (fresh, not precomputed, point) scalar
multiplication with the corresponding function p256_montjscalarmul
or p256_montjscalarmul_alt from s2n-bignum.
Changing #(I) to #(1*I) in the new macro blocks.
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.31%. Comparing base (2f18797) to head (5523a26).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1794      +/-   ##
==========================================
- Coverage   78.34%   78.31%   -0.03%     
==========================================
  Files         580      581       +1     
  Lines       97255    97228      -27     
  Branches    13945    13939       -6     
==========================================
- Hits        76190    76147      -43     
- Misses      20444    20457      +13     
- Partials      621      624       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants