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

driver-only ECDSA: add ssl-opt.sh testing with testing parity #7082

Merged
merged 12 commits into from
Mar 8, 2023

Conversation

valeriosetti
Copy link
Contributor

@valeriosetti valeriosetti commented Feb 10, 2023

Description

The goal of this PR is to re-enable ssl-opt.sh tests when running accelerated ECDSA coverage analysis.
Resolves #6861
Depends on #7064

Gatekeeper checklist

  • changelog not required
  • backport not required
  • tests not required

@valeriosetti valeriosetti requested a review from mpg February 10, 2023 13:09
@valeriosetti valeriosetti self-assigned this Feb 10, 2023
@valeriosetti valeriosetti added enhancement needs-ci Needs to pass CI tests needs-preceding-pr Requires another PR to be merged first size-m Estimated task size: medium (~1w) labels Feb 10, 2023
@valeriosetti
Copy link
Contributor Author

@valeriosetti valeriosetti force-pushed the issue6861 branch 2 times, most recently from a2f2469 to 8a15c4c Compare February 13, 2023 14:39
@valeriosetti
Copy link
Contributor Author

Last rebase is because #6997 was merged and consequently also #7064 was rebased

@mpg mpg changed the base branch from development to features/new-code-style/development February 14, 2023 08:36
@mpg mpg changed the base branch from features/new-code-style/development to development February 14, 2023 08:36
@mpg
Copy link
Contributor

mpg commented Feb 14, 2023

(Changed the base twice just to force-refresh github's list of commits. Now it no longer lists the commits from 7064 as being added by this PR.)

@valeriosetti valeriosetti 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 and removed needs-ci Needs to pass CI tests needs-preceding-pr Requires another PR to be merged first labels Feb 15, 2023
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

Looks pretty good generally, mostly just one point about sometimes using a stronger requirement than necessary.

tests/ssl-opt.sh Outdated Show resolved Hide resolved
library/ssl_misc.h Show resolved Hide resolved
programs/ssl/ssl_server2.c Outdated Show resolved Hide resolved
tests/ssl-opt.sh Outdated Show resolved Hide resolved
tests/ssl-opt.sh Outdated Show resolved Hide resolved
tests/ssl-opt.sh Outdated Show resolved Hide resolved
@valeriosetti valeriosetti requested a review from mpg February 22, 2023 08:56
@valeriosetti valeriosetti added the needs-ci Needs to pass CI tests label Feb 22, 2023
@valeriosetti
Copy link
Contributor Author

Here is the result of the outcome-analysis.sh script
outcome-analysis-results.txt

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
@valeriosetti valeriosetti requested a review from mprse March 2, 2023 16:18
mprse
mprse previously approved these changes Mar 3, 2023
Copy link
Contributor

@mprse mprse 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 addressing my comments. It seems that there is no correct way to skip tests other than ECDSA in ssl-opt, so we need to keep all enabled.

LGTM.

@gilles-peskine-arm
Copy link
Contributor

I think Manuel and Przemysław are both reviewing, hence removing the needs-reviewer label.

@gilles-peskine-arm gilles-peskine-arm removed needs-ci Needs to pass CI tests needs-reviewer This PR needs someone to pick it up for review labels Mar 3, 2023
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

(I'm running out of time for today, just releasing the one comment I have so far, will continue my review tomorrow.)

@@ -2833,6 +2833,7 @@ requires_config_enabled MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE
requires_config_enabled MBEDTLS_DEBUG_C
requires_config_enabled MBEDTLS_SSL_CLI_C
requires_config_enabled MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
requires_pk_alg ECDSA
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: I don't understand why this case needs this but the next one apparently doesn't? The only differences I can see between the command lines is that the next one has sig_algs=ecdsa_secp256r1_sha256 and this one doesn't, but that would suggest the next once needs ECDSA (too).

Can you clarify the reasoning that led to adding this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're absolutely right, this is a redundant requirement (which probably belongs to the initial steps for this PR) that now is automatically satisfied by the changes in detect_required_features().
I'll fix this and all other redundancies.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

Looking pretty good to me. I now think all the dependencies are correct, but that (1) some of them are redundant with what detect_required_feature does thanks to your extension, and (2) some would become redundant with a simple extra extension (detect server7 too).

library/ssl_misc.h Outdated Show resolved Hide resolved
library/ssl_tls.c Outdated Show resolved Hide resolved
@@ -2158,7 +2158,8 @@ component_test_psa_crypto_config_accel_ecdsa_use_psa () {
msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDSA + USE_PSA"
make test

# TODO: ssl-opt.sh (currently doesn't pass) - #6861
msg "test: ssl-opt.sh"
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand the concern for reducing the load, but until we have a solid mechanism for selecting cases, I'd really prefer to run the whole thing. Otherwise it's very hard to be confident we didn't miss anything.

tests/ssl-opt.sh Show resolved Hide resolved
tests/ssl-opt.sh Outdated
@@ -3691,6 +3717,7 @@ run_test "Session resume using tickets: session copy" \
-c "a session has been resumed"

requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
requires_any_configs_enabled $TLS1_2_KEY_EXCHANGES_WITH_ECDSA_CERT
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah right, I missed the things implied by $O_SRV, right. Thanks for clarifying.

Though, isn't that automatically handled by your extension to detect_required_features? (Same question for the bunch with $G_SRV below.)

tests/ssl-opt.sh Outdated
@@ -5535,6 +5595,7 @@ run_test "Authentication: openssl client no cert, server optional" \

requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
requires_any_configs_enabled $TLS1_2_KEY_EXCHANGES_WITH_CERT
requires_any_configs_enabled $TLS1_2_KEY_EXCHANGES_WITH_ECDSA_CERT
Copy link
Contributor

Choose a reason for hiding this comment

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

The line above becomes redundant when adding this one. (Also, it looks to me like this would be auto-detected too.)

tests/ssl-opt.sh Show resolved Hide resolved
tests/ssl-opt.sh Outdated
@@ -9448,7 +9521,8 @@ run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \

requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
requires_config_enabled MBEDTLS_RSA_C
requires_config_enabled MBEDTLS_ECDSA_C
requires_any_configs_enabled $TLS1_2_KEY_EXCHANGES_WITH_CERT
requires_pk_alg "ECDSA"
Copy link
Contributor

Choose a reason for hiding this comment

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

This one and the next few look like they could be auto-detected based on loading a server7 certificate.

tests/ssl-opt.sh Outdated Show resolved Hide resolved
tests/ssl-opt.sh Outdated
@@ -11473,6 +11557,7 @@ requires_config_enabled MBEDTLS_DEBUG_C
requires_config_enabled MBEDTLS_SSL_CLI_C
requires_all_configs_enabled MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE \
MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
requires_pk_alg "ECDSA"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think for this case, and probably all the other TLS 1.3 cases until the end of the files, detect_require_features already does the job so don't need this explicit declaration.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This was a leftover from some debug activity that unfortunately ended up
in previous commits.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
There were some dependencies that are now automatically satisfied by the
detect_required_features() function.

After this check there should be no redundant requirement for:
- requires_pk_alg "ECDSA"
- requires_any_configs_enabled $TLS1_2_KEY_EXCHANGES_WITH_ECDSA_CERT
- requires_any_configs_enabled $TLS1_2_KEY_EXCHANGES_WITH_CERT

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
@valeriosetti
Copy link
Contributor Author

I checked ssl-opt.sh for all occurencies of:

  • requires_pk_alg "ECDSA"
  • requires_any_configs_enabled $TLS1_2_KEY_EXCHANGES_WITH_ECDSA_CERT
  • requires_any_configs_enabled $TLS1_2_KEY_EXCHANGES_WITH_CERT

and removed all redundancies which are automatically satisfied by detect_required_features() (which has also been extended to include server7 certificate).
Here is also the outcome-analysis result:
outcome-analysis.txt

@valeriosetti valeriosetti requested review from mpg and mprse March 8, 2023 09:53
Copy link
Contributor

@mpg mpg 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 addressing my feedback. Looks all good to me now as long as the CI agrees :)

Copy link
Contributor

@mprse mprse left a comment

Choose a reason for hiding this comment

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

Delta Review ok. Only one typo found.

# detect_required_features() function), it does NOT guarantee that the
# result is accurate. It does not check other conditions, such as:
# - MBEDTLS_SSL_PROTO_TLS1_x can be disabled to selectively remove
# TLS 1.2/1.3 suppport
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: support

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ops, sorry for this. In case this PR does not require any change, I will fix this in the following one (#7117)

@mprse mprse 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, labels Mar 8, 2023
@mpg mpg merged commit 289e5ba into Mbed-TLS:development Mar 8, 2023
Comment on lines +9093 to +9095
# Note: the function "detect_required_features()" is not able to detect more than
# one "force_ciphersuite" per client/server and it only picks the 2nd one.
# Therefore the 1st one is added explicitly here
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this comment: detect_required_features runs independently on the client command line and on the server command line. If they have different force_ciphersuite options, this should lead to skipping the test case unless both TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 and TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256 are enabled. So the explicit requirement on MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED should not be necessary. What am I missing?

Copy link
Contributor

Choose a reason for hiding this comment

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

I just had a look and I don't think you're missing anything. @valeriosetti wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's been some time since I did this change, so I'm trying to remember the exact reason for it. I looked at the code and I think the problem with these tests:

  • SSL async private: cancel after start then fall back to transparent key
  • SSL async private: sign, error in resume then fall back to transparent key
    is that they define 2 different ciphersuites for the client (because the client is run twice).

In the scenario you described (which is the most used case) we have 1 ciphersuite for the server and 1 for the client, so detect_required_features works well. Here the problem is that we are running the client twice, with different ciphersuites in each case, but detect_required_features() only picks the 2nd one (ignoring ECDHE-ECDSA). That's why I enforced that in those tests.
I agree that a better approach would have been to extend detect_required_features() in order to support multiple ciphersuites, but it was only a matter of 2 tests, so that's why I didn't try to do so.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh duh, yes, I see, it's because we run the client twice. I agree with not making the detection code more complex just for two test cases. Thanks for the explanation.

@valeriosetti valeriosetti deleted the issue6861 branch December 6, 2024 06:01
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 enhancement size-m Estimated task size: medium (~1w)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

driver-only ECDSA: add ssl-opt.sh testing with testing parity
4 participants