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

Cross library PQ interop test with s2n-tls #2138

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

chockalingamc
Copy link

Description of changes:

Adding cross library PQ interop test with s2n-tls

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.

@chockalingamc chockalingamc requested a review from a team as a code owner January 24, 2025 15:57
@codecov-commenter
Copy link

codecov-commenter commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.96%. Comparing base (39a4383) to head (cf1df0c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2138   +/-   ##
=======================================
  Coverage   78.95%   78.96%           
=======================================
  Files         611      611           
  Lines      105522   105522           
  Branches    14946    14943    -3     
=======================================
+ Hits        83317    83323    +6     
+ Misses      21553    21547    -6     
  Partials      652      652           

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

@torben-hansen
Copy link
Contributor

a s2n-tls integration script exists: https://github.com/aws/aws-lc/blob/main/tests/ci/integration/run_s2n_integration.sh
Should add any new tests to that IMO.

@geedo0
Copy link
Contributor

geedo0 commented Jan 28, 2025

a s2n-tls integration script exists: main/tests/ci/integration/run_s2n_integration.sh
Should add any new tests to that IMO.

The intent of this work was to add a test that can test PQ-TLS interop between AWS-LC's libssl and different PQ-TLS providers of which S2N is one of several. That said, the naming of the script in this PR should be renamed to reflect that generic intent.

Copy link
Contributor

@geedo0 geedo0 left a comment

Choose a reason for hiding this comment

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

Add/augment a YAML file inside .github/workflows to actually run this test. Assert that the test actually succeeds in the checks.

Comment on lines 20 to 28
# clone aws-lc
git clone --depth 1 --branch "${lc_branch}" "${lc_url}" "${scratch_folder}/s2n-tls/aws-lc"

# build aws-lc
echo "building aws-lc"
cd "${scratch_folder}/s2n-tls/aws-lc"
cmake -GNinja -B build
ninja -C build
cmake --install build --prefix install
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the run_build function to build AWS-LC from the source corresponding to the request and put the relevant artifacts in the conventional locations.

cd "${scratch_folder}/s2n-tls"
cmake . -Bbuild-with-lc \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=aws-lc/install
Copy link
Contributor

Choose a reason for hiding this comment

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

Update this to use the correct LC location after making the change to how it gets built.

Copy link
Contributor

Choose a reason for hiding this comment

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

Rename this to be more generic across PQ-TLS implementations. e.g. run_pq_tls_interop_test.sh.

-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=aws-lc/install
cmake --build build-with-lc

Copy link
Contributor

Choose a reason for hiding this comment

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

Please refactor this to loop across different TLS groups to cut down on the repetition.

for group in X25519MLKEM768 SecP256r1MLKEM768; do 
  # lc to s2n
  # s2n to lc
done


# handshake test 1 - aws-lc bssl server with s2n-tls s2nc client for X25519MLKEM768:X25519
cd "${scratch_folder}/s2n-tls"
./aws-lc/build/tool/bssl s_server -curves X25519MLKEM768:X25519 -accept 45000 -debug &> s_server_out &
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't test against the purely classical x25519 group.

-DCMAKE_PREFIX_PATH=aws-lc/install
cmake --build build-with-lc

# handshake test 1 - aws-lc bssl server with s2n-tls s2nc client for X25519MLKEM768:X25519
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment explaining how all this works. It's not immediately apparent what all these workarounds do. e.g. the sleep is there to allow the server time to listen on the socket.

@andrewhop
Copy link
Contributor

Add/augment a YAML file inside .github/workflows to actually run this test. Assert that the test actually succeeds in the checks.

Our preference is to put this in the codebuild integration target like https://github.com/aws/aws-lc/blob/main/tests/ci/cdk/cdk/codebuild/github_ci_integration_omnibus.yaml#L9-L17

git clone --depth 1 --branch "${s2n_branch}" "${s2n_url}" "${scratch_folder}/s2n-tls"

# clone aws-lc
git clone --depth 1 --branch "${lc_branch}" "${lc_url}" "${scratch_folder}/s2n-tls/aws-lc"
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't need to clone AWS-LC since it will already be there when run locally or run in codebuild.

@chockalingamc
Copy link
Author

Add/augment a YAML file inside .github/workflows to actually run this test. Assert that the test actually succeeds in the checks.

Our preference is to put this in the codebuild integration target like https://github.com/aws/aws-lc/blob/main/tests/ci/cdk/cdk/codebuild/github_ci_integration_omnibus.yaml#L9-L17

All targets in that yaml file are for tests/ci/integration/* test scripts. This test is interop testing for aws-lc with different libraries and resides in tests/ci/. The .github/workflows/misc-test.yaml seemed like an appropriate place for this.

@andrewhop
Copy link
Contributor

Add/augment a YAML file inside .github/workflows to actually run this test. Assert that the test actually succeeds in the checks.

Our preference is to put this in the codebuild integration target like https://github.com/aws/aws-lc/blob/main/tests/ci/cdk/cdk/codebuild/github_ci_integration_omnibus.yaml#L9-L17

All targets in that yaml file are for tests/ci/integration/* test scripts. This test is interop testing for aws-lc with different libraries and resides in tests/ci/. The .github/workflows/misc-test.yaml seemed like an appropriate place for this.

I'd argue an interop test is an integration test and we could move the bash file. Either way this shouldn't run in the GitHub actions and should move to CodeBuild general or CodeBuild integration target.

variables:
AWS_LC_CI_TARGET: "tests/ci/integration/run_pq_tls_integration.sh"

- identifier: pq_tls_integration_aarch
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll defer to the LC team, but I don't think we need to cover both ARM and Intel for this test. This is purely application layer stuff so the CPU arch really doesn't matter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, we're a bit inconsistent about that for other projects but just one platform is fine.

S2N_TLS_SRC_FOLDER="${SCRATCH_FOLDER}/s2n-tls"
S2N_TLS_BUILD_FOLDER="${SCRATCH_FOLDER}/s2n-tls-build"

# init setup
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary comment.

Copy link
Contributor

@andrewhop andrewhop left a comment

Choose a reason for hiding this comment

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

Checked the build and it looks good! It also runs in 10 minutes which is great and using BUILD_GENERAL1_SMALL makes sense.

cd "$S2N_TLS_BUILD_FOLDER"
./bin/s2nc -c default_pq -i localhost 45000 &> s2nc_out
wait $S_PID || true
grep "libcrypto" s2nc_out | grep "AWS-LC"
Copy link
Contributor

Choose a reason for hiding this comment

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

I trust the greps but it would be nice to see the output here and down below:

Suggested change
grep "libcrypto" s2nc_out | grep "AWS-LC"
echo $s_server_out
echo $s2nc_out
grep "libcrypto" s2nc_out | grep "AWS-LC"

variables:
AWS_LC_CI_TARGET: "tests/ci/integration/run_pq_tls_integration.sh"

- identifier: pq_tls_integration_aarch
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, we're a bit inconsistent about that for other projects but just one platform is fine.

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.

5 participants