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

ssl-opt.sh: Fix getting the list of supported ciphersuites. #8561

Conversation

ronald-cron-arm
Copy link
Contributor

@ronald-cron-arm ronald-cron-arm commented Nov 23, 2023

Description

Since the merge of #7844 (3.5.x not impacted) the detection of the supported ciphersuites in ssl-opt.sh is broken and some test cases are not run anymore. This PR fixes this.

PR checklist

Please tick as appropriate and edit the reasons (e.g.: "backport: not needed because this is a new feature")

@ronald-cron-arm ronald-cron-arm added needs-ci Needs to pass CI tests component-test Test framework and CI scripts labels Nov 23, 2023
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

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

Thanks for catching this! I'm approving, but that code is fragile so I'd prefer to add a sanity check.

tests/ssl-opt.sh Outdated
@@ -358,7 +358,7 @@ requires_protocol_version() {

# Space-separated list of ciphersuites supported by this build of
# Mbed TLS.
P_CIPHERSUITES=" $($P_CLI --help 2>/dev/null |
P_CIPHERSUITES=" $($P_CLI help_ciphersuites 2>/dev/null |
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm Nov 23, 2023

Choose a reason for hiding this comment

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

ssl_client2 --help returns a nonzero status, but this did not cause the script to abort, despite using set -e, because the nonzero status is on the left-hand side of a pipe and the status of the pipeline is just the status of the right-hand side. (The rationale for that design is to ignore SIGPIPE if it happens to the left-hand side.)

We should add some other sanity check here. We do expect at least one cipher suite:

if [ "$LIST_TESTS" -eq 0 ] && [ -z "${P_CIPHERSUITES# }" ]; then
    echo >&2 "$0: fatal error: no cipher suites found!"
    exit 125
fi

@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review priority-very-high Highest priority - prioritise this over other review work component-tls needs-backports Backports are missing or are pending review and approval. labels Nov 23, 2023
Fix some dependencies on symmetric crypto that
were not correct in case of driver but not
builtin support. Revealed by "Analyze driver
test_psa_crypto_config_accel_cipher_aead vs reference
test_psa_crypto_config_reference_cipher_aead" in
analyze_outcomes.py.

Signed-off-by: Ronald Cron <[email protected]>
tests/ssl-opt.sh Outdated
@@ -2332,7 +2341,7 @@ run_test "Opaque key for server authentication: invalid alg: ecdh with RSA ke
requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
requires_config_enabled MBEDTLS_X509_CRT_PARSE_C
requires_hash_alg SHA_256
requires_config_enabled MBEDTLS_CCM_C
requires_config_enabled PSA_WANT_ALG_CCM
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 line required? I thought that the automatic requirements for the cipher suite would take care of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes not required, I have removed them.

Same test cases as in the previous commit.
Remove the redundant symmetric crypto dependency.
The dependency is ensured by the fact that:
1) the test case forces a cipher suite
2) ssl-opt.sh enforces automatically that the
   forced ciphersuite is available.
3) The fact that the forced ciphersuite is
   available implies that the symmetric
   cipher algorithm it uses is available as
   well.

Signed-off-by: Ronald Cron <[email protected]>
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@yuhaoth yuhaoth left a comment

Choose a reason for hiding this comment

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

LGTM

@yuhaoth yuhaoth added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review labels Nov 29, 2023
@lpy4105
Copy link
Contributor

lpy4105 commented Nov 29, 2023

I could still see a lot of warnings of analyze_coverage on TLS 1.3 tests being skipped, which I think is false positive. I will push another PR to fix.

@gilles-peskine-arm gilles-peskine-arm added this pull request to the merge queue Nov 29, 2023
Merged via the queue into Mbed-TLS:development with commit 172c0b9 Nov 29, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports bug component-test Test framework and CI scripts component-tls needs-backports Backports are missing or are pending review and approval. needs-ci Needs to pass CI tests priority-very-high Highest priority - prioritise this over other review work
Projects
Development

Successfully merging this pull request may close these issues.

4 participants