Skip to content

Fix PQ Integration tests #2392

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 2 commits into from
May 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions tests/ci/integration/run_pq_tls_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ SCRATCH_FOLDER=${SYS_ROOT}/"pq-tls-scratch"

AWS_LC_BUILD_FOLDER="${SCRATCH_FOLDER}/aws-lc-build"
AWS_LC_INSTALL_FOLDER="${SCRATCH_FOLDER}/aws-lc-install"
AWS_LC_CMD="${AWS_LC_BUILD_FOLDER}/tool/bssl"

S2N_URL='https://github.com/aws/s2n-tls.git'
S2N_BRANCH='main'
S2N_TLS_SRC_FOLDER="${SCRATCH_FOLDER}/s2n-tls"
S2N_TLS_BUILD_FOLDER="${SCRATCH_FOLDER}/s2n-tls-build"
S2NC_CMD=${S2N_TLS_BUILD_FOLDER}/bin/s2nc
S2ND_CMD=${S2N_TLS_BUILD_FOLDER}/bin/s2nd

BSSL_URL='https://github.com/google/boringssl.git'
BSSL_BRANCH='main'
BSSL_SRC_FOLDER="${SCRATCH_FOLDER}/boring-ssl"
BSSL_BUILD_FOLDER="${SCRATCH_FOLDER}/boring-ssl-build"
BSSL_CMD="${SCRATCH_FOLDER}/boring-ssl-build/bssl"

rm -rf "${SCRATCH_FOLDER:?}"
mkdir -p "$SCRATCH_FOLDER"
Expand All @@ -27,6 +31,9 @@ echo "build and install aws-lc"
# Using Debug build as it uses the '-g' compiler flag with gcc without any optimization
aws_lc_build "$SRC_ROOT" "$AWS_LC_BUILD_FOLDER" "$AWS_LC_INSTALL_FOLDER" -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=OFF

[[ -f ${AWS_LC_CMD} ]] || ( echo "Error building AWS-LC. ${AWS_LC_CMD} not found." && exit 1 )
echo "AWS-LC build succeeded. Found ${AWS_LC_CMD}"

echo "clone s2n-tls"
git clone --depth 1 --branch "$S2N_BRANCH" "$S2N_URL" "$S2N_TLS_SRC_FOLDER"

Expand All @@ -38,14 +45,18 @@ cmake . "-B$S2N_TLS_BUILD_FOLDER" -GNinja \
# Suppress stdout for build
ninja -C "$S2N_TLS_BUILD_FOLDER" -j "$NUM_CPU_THREADS" > /dev/null

[[ -f ${S2NC_CMD} ]] || ( echo "Error building s2nc. ${S2NC_CMD} not found." && exit 1 )
[[ -f ${S2ND_CMD} ]] || ( echo "Error building s2nd. ${S2ND_CMD} not found." && exit 1 )
echo "s2n build succeeded. Found: ${S2NC_CMD} ${S2ND_CMD}"

for GROUP in X25519MLKEM768 SecP256r1MLKEM768; do
echo "TLS Handshake: aws-lc server (bssl) with s2n-tls client (s2nc) for group $GROUP"
"$AWS_LC_BUILD_FOLDER"/tool/bssl s_server -curves $GROUP -accept 45000 -debug \
${AWS_LC_CMD} s_server -curves $GROUP -accept 45000 -debug \
&> "$AWS_LC_BUILD_FOLDER"/s_server_out &
sleep 5 # to allow for the server to startup in the background thread
S_PID=$!
# Relying on s2nc behavior that it exits after the first handshake
"$S2N_TLS_BUILD_FOLDER"/bin/s2nc -c default_pq -i localhost 45000 &> "$S2N_TLS_BUILD_FOLDER"/s2nc_out
${S2NC_CMD} -c default_pq -i localhost 45000 &> "$S2N_TLS_BUILD_FOLDER"/s2nc_out
wait $S_PID || true
cat "$AWS_LC_BUILD_FOLDER"/s_server_out
cat "$S2N_TLS_BUILD_FOLDER"/s2nc_out
Expand All @@ -54,12 +65,12 @@ for GROUP in X25519MLKEM768 SecP256r1MLKEM768; do
grep "KEM Group" "$S2N_TLS_BUILD_FOLDER"/s2nc_out | grep "$GROUP"

echo "TLS Handshake: s2n-tls server (s2nd) with aws-lc client (bssl) for group $GROUP"
"$S2N_TLS_BUILD_FOLDER"/bin/s2nd -c default_pq -i localhost 45000 &> "$S2N_TLS_BUILD_FOLDER"/s2nd_out &
${S2ND_CMD} -c default_pq -i localhost 45000 &> "$S2N_TLS_BUILD_FOLDER"/s2nd_out &
sleep 5 # to allow for the server to startup in the background thread
S_PID=$!
# bssl s_client normally does not exit after a handshake, but when run as a background process
# seems to exit by closing the connection after the first handshake. Relying on that behavior here.
"$AWS_LC_BUILD_FOLDER"/tool/bssl s_client -curves $GROUP -connect localhost:45000 -debug \
${AWS_LC_CMD} s_client -curves $GROUP -connect localhost:45000 -debug \
&> "$AWS_LC_BUILD_FOLDER"/s_client_out &
wait $S_PID || true
cat "$S2N_TLS_BUILD_FOLDER"/s2nd_out
Expand All @@ -82,14 +93,17 @@ cmake . "-B$BSSL_BUILD_FOLDER" -GNinja -DCMAKE_BUILD_TYPE=Debug
# Suppress stdout for build
ninja -C "$BSSL_BUILD_FOLDER" -j "$NUM_CPU_THREADS" >/dev/null

[[ -f ${BSSL_CMD} ]] || ( echo "Error building BoringSSL. ${BSSL_CMD} not found." && exit 1 )
echo "BoringSSL build succeeded. Found ${BSSL_CMD}"

# BoringSSL supports only X25519MLKEM768 but not SecP256r1MLKEM768 for key exchange
for GROUP in X25519MLKEM768; do
echo "TLS Handshake: aws-lc server (bssl) with boring-ssl client (bssl) for group $GROUP"
"$AWS_LC_BUILD_FOLDER"/tool/bssl s_server -curves $GROUP -accept 45000 -debug \
${AWS_LC_CMD} s_server -curves $GROUP -accept 45000 -debug \
&> "$AWS_LC_BUILD_FOLDER"/s_server_out &
sleep 5 # to allow for the server to startup in the background thread
S_PID=$!
"$BSSL_BUILD_FOLDER"/tool/bssl s_client -curves $GROUP -connect localhost:45000 -debug \
${BSSL_CMD} s_client -curves $GROUP -connect localhost:45000 -debug \
&> "$BSSL_BUILD_FOLDER"/s_client_out &
wait $S_PID || true
cat "$AWS_LC_BUILD_FOLDER"/s_server_out
Expand All @@ -101,11 +115,11 @@ for GROUP in X25519MLKEM768; do
grep "subject" "$BSSL_BUILD_FOLDER"/s_client_out | grep "BoringSSL"

echo "TLS Handshake: boring-ssl server (bssl) with aws-lc client (bssl) for group $GROUP"
"$BSSL_BUILD_FOLDER"/tool/bssl s_server -curves $GROUP -accept 45000 -debug \
${BSSL_CMD} s_server -curves $GROUP -accept 45000 -debug \
&> "$BSSL_BUILD_FOLDER"/s_server_out &
sleep 5 # to allow for the server to startup in the background thread
S_PID=$!
"$AWS_LC_BUILD_FOLDER"/tool/bssl s_client -curves $GROUP -connect localhost:45000 -debug \
${AWS_LC_CMD} s_client -curves $GROUP -connect localhost:45000 -debug \
&> "$AWS_LC_BUILD_FOLDER"/s_client_out &
wait $S_PID || true
cat "$BSSL_BUILD_FOLDER"/s_server_out
Expand Down
Loading