Skip to content

s2n bignum import method change #2324

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

Merged
merged 15 commits into from
Apr 29, 2025
Merged

Conversation

torben-hansen
Copy link
Contributor

@torben-hansen torben-hansen commented Apr 9, 2025

Description of changes:

This modifies how s2n-bignum is imported. Firstly, it axes the subtree. Secondly, it implements an import script import.sh that will do a simple source import from upstream s2n-bignum repo. Finally, it modies the aws-lc-specific header file.

This is motivated by subtree being a maintenance burden and the need for upstream testing of aws-lc+s2n-bignum code changes before import time.

Obviously, this will increase the size of AWS-LC source because we don't use everything from s2n-bignum currently, and the repo contains a bunch of code-duplication.

Only files we need from s2n-bignum are code from include, arm, and x86_att. All other folders are not imported.

Call-outs:

The aws-lc-specific header file should not be where it currently is. It's unrelated to the third-party source code and is more of an AWS-LC implementation detail.

This PR is not ready for merge yet, because the upstream must first fix all the non-const parameters that's currently assumed by AWS-LC

Some code-changes were needed in the s2n-bignum powered montgomery implementation. Because en upstream change modified file paths, file names, function names, and removed some functions.

Testing:

All relevant code should already be tested as part of CI.

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.

@torben-hansen torben-hansen marked this pull request as ready for review April 22, 2025 21:07
@torben-hansen torben-hansen requested a review from a team as a code owner April 22, 2025 21:07
@torben-hansen torben-hansen changed the title S2n bignum import method change s2n bignum import method change Apr 22, 2025
@codecov-commenter
Copy link

codecov-commenter commented Apr 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.75%. Comparing base (c4db828) to head (61db4e7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2324      +/-   ##
==========================================
- Coverage   78.75%   78.75%   -0.01%     
==========================================
  Files         620      620              
  Lines      107958   107958              
  Branches    15329    15331       +2     
==========================================
- Hits        85026    85022       -4     
- Misses      22275    22279       +4     
  Partials      657      657              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

dkostic
dkostic previously approved these changes Apr 22, 2025
Copy link
Contributor

@dkostic dkostic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.
Nit: do we need to import CODE_OF_CONDUCT.md, CONTRINUTING.md, non_ct_functions.txt?

samuel40791765
samuel40791765 previously approved these changes Apr 25, 2025

#define BN_EXPONENTIATION_S2N_BIGNUM_CAPABLE 1

OPENSSL_INLINE int exponentiation_use_s2n_bignum(void) { return 1; }
OPENSSL_INLINE int exponentiation_use_s2n_bignum(void) {
return CRYPTO_is_NEON_capable();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this moving the capability checks in crypto/fipsmodule/bn/montgomery.c to here instead?

Copy link
Contributor Author

@torben-hansen torben-hansen Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scratch that. They are guarding two different things :)

torben-hansen added a commit to aws/aws-lc-rs that referenced this pull request Apr 28, 2025
…ream AWS-LC change #2324 (#792)

aws/aws-lc#2324 implements a new import method for s2n-bignum upstream in AWS-LC. Among other things it introduces a new folder structure. This messes with assumptions for the aws-lc-rs prefix build, when not using cmake. aws-lc-rs has hard assumptions on the folder structure to add the correct include search paths.

Now s2n-bignum source in upstream AWS-LC is located under third_party/s2n-bignum/s2n-bignum-imported. Note third_party/s2-bignum contains the AWS-LC-specific header files. Hence we keep the existing search path.
@torben-hansen torben-hansen dismissed stale reviews from samuel40791765 and dkostic via 61db4e7 April 28, 2025 17:23
@justsmth
Copy link
Contributor

I think we can now remove the special processing that we do for these assembly files.

I'm wondering whether that might also fix the aws-lc-rs integration test for MacOS:

 + echo File does not exist: /Users/runner/work/aws-lc/aws-lc/aws-lc-rs/aws-lc-sys/aws-lc/third_party/s2n-bignum/arm/curve25519/bignum_madd_n25519.S
+ exit 1
File does not exist: /Users/runner/work/aws-lc/aws-lc/aws-lc-rs/aws-lc-sys/aws-lc/third_party/s2n-bignum/arm/curve25519/bignum_madd_n25519.S

@torben-hansen torben-hansen merged commit fce4cb2 into aws:main Apr 29, 2025
110 of 114 checks passed
justsmth added a commit that referenced this pull request Apr 30, 2025
### Description of changes: 
Bump version to 1.50.1. (Needed so that `aws-lc-sys` can to pick up
latest s2n-bignum changes.)

### Call-outs:
#### What's Changed
* Fix GCC 4.8 docker img; Also w/ GCC 7.5 by @justsmth in
#2344
* Fix LibRdKafka CI by @smittals2 in
#2372
* Expand .clang-tidy configuration by @justsmth in
#2356
* nginx-1.28.0 aws-lc-nginx.patch by @robvanoostenrijk in
#2373
* s2n bignum import method change by @torben-hansen in
#2324
* Fix a theoretical overflow in BIO_printf by @justsmth in
#2369
* Fix tpm2-tss integration test by @justsmth in
#2370


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.
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.

6 participants