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

compat.sh: Skip static ECDH cases if unsupported in openssl #7137

Conversation

lpy4105
Copy link
Contributor

@lpy4105 lpy4105 commented Feb 20, 2023

Description

Fix: #1785

This PR add the ability in compat.sh to check if the under testing openssl program supports static ECDH (i.e. ECDH_ECDSA) key exchange methods. The cases for TLS_ECDH_ECDSA_xxx ciphersuites will be skipped if openssl doesn't support so.

This PR would like to cover all out of box failures of ssl-opt.sh and compat.sh on modern systems (e.g Ubuntu 18.04 and newer).

Gatekeeper checklist

This commit add support to detect if openssl used for testing
supports static ECDH key exchange. Skip the ciphersutes if
openssl doesn't support them.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
@lpy4105 lpy4105 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 size-s Estimated task size: small (~2d) component-test Test framework and CI scripts priority-high High priority - will be reviewed soon labels Feb 20, 2023
Copy link

@yanrayw yanrayw left a comment

Choose a reason for hiding this comment

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

The code looks good to me, except for a minor improvement.

tests/compat.sh Show resolved Hide resolved
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
@lpy4105 lpy4105 requested a review from yanrayw February 21, 2023 08:30
yanrayw
yanrayw previously approved these changes Feb 21, 2023
Copy link

@yanrayw yanrayw 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

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

We're still not skipping enough.

tests/compat.sh Outdated Show resolved Hide resolved
tests/compat.sh Outdated Show resolved Hide resolved
@@ -534,6 +534,15 @@ add_mbedtls_ciphersuites()
esac
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I know it wasn't a requirement of #1785, but since compat.sh is now skipping static ECDH cipher suites automatically, I think we should remove the explicit exclusions in .travis.yml and all.sh.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No explicit exclusions found in all.sh, so I only removed that in .travis.yml.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also found this doesn't work for a more recent OpenSSL (e.g 1.1.1f on Travis CI).

mbedtls/tests/compat.sh

Lines 823 to 824 in ffb92b0

if grep 'Cipher is (NONE)' $CLI_OUT >/dev/null; then
RESULT=1

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, the comment (which was added later by a different person) is wrong. Cipher is (NONE) indicates a null cipher, not a cipher that isn't supported, and that's still true at least in OpenSSL 1.1.1. So what this piece of code really does is to automatically mark null cipher suites as skipped if OpenSSL doesn't support them.

I don't think we need to change the code: it's working well enough. But before we forget, please fix the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I see. But Cipher is (NONE) is also printed if there is a invalid ciphersuite in old OpenSSL. So I misunderstood the code here. Let me update the comment.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
@lpy4105 lpy4105 removed the needs-reviewer This PR needs someone to pick it up for review label Feb 22, 2023
The mechanism of detecting unsupported ciphersuites
for OpenSSL client doesn't work on a modern OpenSSL.
At least, it fails on Travis CI which is installed
with OpenSSL 1.1.1f. So we need to skip ECDH cipher-
suites for O->m.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
Copy link

@yanrayw yanrayw left a comment

Choose a reason for hiding this comment

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

Left a potential issue to consider.

.travis.yml Outdated Show resolved Hide resolved
tests/compat.sh Show resolved Hide resolved
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.

Looks good to me, except, please update the preexisting incorrect comment.

@@ -534,6 +534,15 @@ add_mbedtls_ciphersuites()
esac
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, the comment (which was added later by a different person) is wrong. Cipher is (NONE) indicates a null cipher, not a cipher that isn't supported, and that's still true at least in OpenSSL 1.1.1. So what this piece of code really does is to automatically mark null cipher suites as skipped if OpenSSL doesn't support them.

I don't think we need to change the code: it's working well enough. But before we forget, please fix the comment.

tests/compat.sh Show resolved Hide resolved
@gilles-peskine-arm gilles-peskine-arm added needs-work needs-backports Backports are missing or are pending review and approval. and removed needs-review Every commit must be reviewed by at least two team members, labels Feb 22, 2023
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
@lpy4105 lpy4105 removed the needs-backports Backports are missing or are pending review and approval. label Feb 23, 2023
Copy link

@yanrayw yanrayw 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

@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

@gilles-peskine-arm gilles-peskine-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-work labels Feb 23, 2023
@gilles-peskine-arm gilles-peskine-arm merged commit e461683 into Mbed-TLS:development Feb 28, 2023
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 component-test Test framework and CI scripts priority-high High priority - will be reviewed soon size-s Estimated task size: small (~2d)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSL test scripts fail out of the box on Ubuntu 18.04 and newer
3 participants