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

Fix some test cases that weren't getting executed #3463

Merged

Conversation

gilles-peskine-arm
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm commented Jun 26, 2020

Fix some test cases that weren't getting executed for one reason or another. See this analysis for background. This is not intended to fix all cases, just some that are easy to fix.

The check for test cases that are never executed (informational in #3458, mandatory in a follow-up that is yet to come) will ensure that these bug don't come back.

  • Mistakes in dependencies.
  • PSA crypto metadata tests for algorithms that are not implemented.
  • SSL tests skipped because a ciphersuite is not supported, but that are testing that the ciphersuite is rejected.

None of the changes here apply to 2.16 or 2.7. All the changes in unit tests are for new cases added since 2.16, and the bug fix in ssl-opt.sh is caused by requires_ciphersuite which was added after 2.16.

The test case was never executed.

Signed-off-by: Gilles Peskine <[email protected]>
The test cases were never executed.

Signed-off-by: Gilles Peskine <[email protected]>
The metadata tests depend on the corresponding feature because there
is no guarantee that the metadata is correct if the feature is
disabled. There are metadata test cases for some algorithms and key
types that are declared but not supported. These test cases are
present but can never run.

It is debatable whether having these test cases is a good thing in
case they become runnable in the future, or a bad thing because
they're dead code. We're working on detecting test cases that are
never executed for accidental reasons (e.g. typo in a dependency or
missing configuration on the CI), and having test cases that are
deliberately never executed messes this up. So remove these test
cases. If we do implement the corresponding feature, it'll be easy to
add the corresponding metadata test cases.

The features that had metadata tests but no implementations were:

* SHA-512/256 and SHA-512/224 (hypothetical dependency: MBEDTLS_SHA512_256)
* DSA (hypothetical dependency: MBEDTLS_DSA_C)
* SHA-3 and HMAC-SHA-3 (hypothetical dependency: MBEDTLS_SHA3_C)

Signed-off-by: Gilles Peskine <[email protected]>
@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, needs-backports Backports are missing or are pending review and approval. component-tls component-crypto Crypto primitives and low-level interfaces needs-ci Needs to pass CI tests labels Jun 26, 2020
@gilles-peskine-arm gilles-peskine-arm self-assigned this Jun 26, 2020
mpg
mpg previously approved these changes Jul 2, 2020
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 good to me, except for a harmless typo.

tests/ssl-opt.sh Outdated
;;
esac

unset cmd ciphersuite
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: this function doesn't set cmd so it probably doesn't need to unset 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.

Accidental leftover from an earlier draft that used cmd. Since this was the last commit, I amended it to fully remove cmd.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, thanks!

Test cases that force a specific ciphersuites are only executed if
this ciphersuite is enabled. But there are test cases (for RC4) whose
goal is to check that the ciphersuite is not used. These test cases
must run even if (or only if) the ciphersuite is disable, so add an
exception for these test cases.

Signed-off-by: Gilles Peskine <[email protected]>
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.

LGTM

@gilles-peskine-arm gilles-peskine-arm removed the needs-backports Backports are missing or are pending review and approval. label Jul 2, 2020
@gilles-peskine-arm
Copy link
Contributor Author

These are bug fixes that should be backported where applicable, but it turns out that all of them are in new code that didn't exist in 2.16.

@gilles-peskine-arm gilles-peskine-arm removed the needs-ci Needs to pass CI tests label Jul 2, 2020
Copy link
Contributor

@ronald-cron-arm ronald-cron-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

@ronald-cron-arm ronald-cron-arm 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 Jul 3, 2020
@gilles-peskine-arm gilles-peskine-arm merged commit 642a4ef into Mbed-TLS:development Jul 3, 2020
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-crypto Crypto primitives and low-level interfaces component-tls
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants