1219 Commits

Author SHA1 Message Date
Gilles Peskine
edc8f35ed3 Remove obsolete requirements on middlebox compatibility mode: manual
MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE is no longer required, except in test
cases that are specifically about it. This commit removes the requirement on
all test cases except those whose description contains "middlebox".

Exclude tls13-compat.sh which is automatically generated and will be handled
in a separate commit.

```
perl -0777 -i -pe '
    # With -0777, we act on the whole file.
    # s[REGEXP][EXPR]gm replaces every occurrence of REGEXP by EXPR.
    # The regexp matches "requires_config_enabled MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE",
    # followed by zero or more non-empty lines, followed by a line starting
    # with "run_test" and not containing "middlebox".
    # The replacement is everything matched except the first line.
    s[^requires_config_enabled MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE\n((?:.+\n)*run_test (?!.*middlebox))]
     [$1]gm' tests/ssl-opt.sh tests/opt-testcases/tls13-kex-modes.sh tests/opt-testcases/tls13-misc.sh
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-24 18:59:30 +02:00
Gilles Peskine
671a439ddd Adapt middlebox compatibility tests for always-on acceptance
Adapt the test cases for TLS 1.3 middlebox compatibility mode, now that we
always interoperate with peers that support it, regardless of whether
MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE is enabled.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-24 18:58:49 +02:00
Gilles Peskine
7b02c1f3b6 Avoid multiline requires_all_configs_xxx
For better searchability and readability, call requires_config_enabled or
requires_config_disabled for each option, instead of calling
requires_all_configs_enabled or requires_all_configs_disabled with a long
list of options.

```
perl -0777 -i -pe '
    # With -0777, we act on the whole file.
    # s[REGEXP][CODE]egm replaces every occurrence of REGEXP by the result
    # of running CODE.
    # The regexp matches "requires_all_configs_enabled" or
    # "requires_all_configs_disabled" followed by a list of words ending
    # with a line break. The words can be separated by a sequence of
    # spaces and optionally a backslash-newline.
    s[^requires_all_configs_(enabled|disabled) *((?:(?: \w+) *(?:\\\n)? *)+)\n][
      $state = $1;
      # Extract all the words from the list of words (/(\w+)/g). For each word,
      # For each word, construct a line "requires_config_XXXabled WORD".
      # The replacement text is the concatenation of these lines.
      join("", map {"requires_config_$state $_\n"} $2 =~ /(\w+)/g)
     ]egm' tests/ssl-opt.sh tests/opt-testcases/*.sh
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-24 18:58:47 +02:00
Gilles Peskine
e3eab32600 requires_certificate_authentication: prioritize TLS 1.3
When checking whether the build supports certificate authentication, check
the key exchange modes enabled in the default protocol version. This is TLS
1.3 when it's enabled.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:34 +02:00
Gilles Peskine
6e85e35fcc Documentation improvements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:34 +02:00
Gilles Peskine
2dd4395da0 Fix detection of TLS 1.2 PSK-ephemeral key exchange modes
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:34 +02:00
Gilles Peskine
7f453bfad4 Improve some comments
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:34 +02:00
Gilles Peskine
78df617362 Remove unused auth_mode parameter on a PSK test case
It was causing the test case to be incorrectly skipped as needing
certificate authentication.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:34 +02:00
Gilles Peskine
cd4fe70fe2 Fix weirdly quoted invocations of requires_any_configs_enabled
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:34 +02:00
Gilles Peskine
db26406934 Also activate PSK-only mode when PSK-ephemeral key exchanges are available
The point of PSK-only mode is to transform certificate-based command lines
into PSK-based command lines, when the certificates are not relevant to what
is being tested. So it makes sense to do that in with PSK-ephemeral key
exchanges too.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:34 +02:00
Gilles Peskine
9d3b2079a5 Unify the two requires-key-exchange-with-certificate function
requires_certificate_authentication was called in more places, but did not
do fine-grained analysis of key exchanges and so gave the wrong results in
some builds.

requires_key_exchange_with_cert_in_tls12_or_tls13_enabled gave the correct
result but was only used in some test cases, not in the automatic detection
code.

Remove all uses of requires_key_exchange_with_cert_in_tls12_or_tls13_enabled
because they are in fact covered by automated detection that calls
requires_certificate_authentication.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:34 +02:00
Gilles Peskine
24b4303ddd Detect PSK-only mode in TLS 1.3 as well
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:34 +02:00
Gilles Peskine
4f0986487d Fix PSK-only mode doing less than it should
Don't add a certificate requirement when PSK is enabled.

Do command line requirement detection after the injection of PSK into the
command line in PSK-only mode. Otherwise certificate requirements would be
added even in PSK-only mode.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:34 +02:00
Gilles Peskine
ae3dc17e50 Detect more cases where certificates are required
When requiring a cryptographic mechanism for the sake of certificate
authentication, also require that certificate authentication is enabled.

Setting auth_mode explicitly means that we're testing something related to
how certificate-based authentication is handled, so require a key exchange
with certificate-based authentication.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:34 +02:00
Gilles Peskine
6f9952abfc ssl-opt: Fix GnuTLS PSK injection
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:33 +02:00
Gilles Peskine
9404169146 Use CONFIGS_ENABLED instead of repeatedly calling query_compile_time_config
It's faster and more readable.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:01 +02:00
Gilles Peskine
56ee69de5b Fix "Renegotiation: openssl server, client-initiated" with OpenSSL 3
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:48:01 +02:00
Manuel Pégourié-Gonnard
67072bf39a Fix two dependency declarations in ssl-opt
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-09-02 12:46:03 +02:00
Manuel Pégourié-Gonnard
843a00dec6 Add support for context f_vrfy callback in 1.3
This was only supported in 1.2 for no good reason.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-09-02 12:46:03 +02:00
Ronald Cron
95dd6f57cd ssl-opt.sh: Test trusted certificate callback in TLS 1.3
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-09-02 12:46:03 +02:00
Ronald Cron
7a442c9941 ssl-opt.sh: Fix test case titles
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-09-02 12:46:03 +02:00
Manuel Pégourié-Gonnard
6901504ddb Allow no authentication of the server in 1.3
See notes about optional two commits ago for why we're doing this.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-09-02 12:46:03 +02:00
Manuel Pégourié-Gonnard
18dd213114 Reorder some tests in ssl-opt.sh
The tests above are required then optional then none. Follow the same
pattern here.

Just moving things around (see git's --color-moved option).

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-09-02 12:46:03 +02:00
Manuel Pégourié-Gonnard
58ab9ba0bd Allow optional authentication of the server in 1.3
This is for compatibility, for people transitioning from 1.2 to 1.3.
See https://github.com/Mbed-TLS/mbedtls/issues/9223 "Mandatory server
authentication" and reports linked from there.

In the future we're likely to make server authentication mandatory in
both 1.2 and 1.3. See https://github.com/Mbed-TLS/mbedtls/issues/7080

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-09-02 12:46:03 +02:00
Manuel Pégourié-Gonnard
2ffa53aa28 Test cert alert REVOKED -> CERT_REVOKED
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-09-02 12:46:03 +02:00
Manuel Pégourié-Gonnard
0274175454 Test cert alert NOT_TRUSTED -> UNKNOWN_CA
In terms of line coverage, this was covered, except we never checked the
behaviour was as intended.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-09-02 12:46:03 +02:00
Manuel Pégourié-Gonnard
946d14a7ac Fix ordering of a test case in ssl-opt.sh
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-09-02 12:46:03 +02:00
Manuel Pégourié-Gonnard
a6397f0eb3 Add test forcing TLS 1.2 for clearer coverage
This is a duplicate from the previous test, except it forces TLS 1.2.

The previous test does not force a version, so it picks 1.3 in the
default/full config. However we have a build with 1.2 only in all.sh, in
which the previous test would pick 1.2. So, there was no test gap and
the behaviour was indeed tested with 1.2.

However when measuring code coverage with lcov, currently we can only
use a single build. So, I'm adding this variant of the test case as a
so that the 1.2 code looks covered in the report from
basic-build-test.sh. This is for my convenience while I make sure
everything is covered before refactoring.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-09-02 12:46:03 +02:00
Gilles Peskine
99b57bd35a
Merge pull request #1272 from eleuzi01/forward-1263
Fix 1.3 cli-auth optional reporting of (ext)KeyUsage issues
2024-08-28 19:38:36 +02:00
Gilles Peskine
805ac15e2d
Merge pull request #9244 from waleed-elmelegy-arm/fix-tls13_parse_client_hello-issue
Fix issue in handling legacy_compression_methods in ssl_tls13_parse_client_hello()
2024-08-22 18:56:27 +00:00
Elena Uziunaite
f48bfb00bd Add test cases for extKeyUsage
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-08-16 17:24:44 +01:00
Elena Uziunaite
6a04b168b2 Rationalize extKeyUsage tests
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-08-16 17:24:34 +01:00
Manuel Pégourié-Gonnard
aeda1fd0a8 Use P_CLI when O_CLI's status is not reliable
Generally speaking, in this group of test we use O_SRV when testing our
client's behaviour, and O_CLI when testing our server's behaviour. I
don't think that's essential, but why not.

Well, for these two tests there's a reason why not: O_CLI often exits 0,
seemingly not minding that the server aborted the handshake with a fatal
alert, but sometimes it exits 1. (I've observed 0 on my machine, on two
runs of OpenCI and Internal CI, and 1 in some test in one run of
Internal CI.)

So, use our client instead, which exits non-zero consistently.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-16 17:24:26 +01:00
Manuel Pégourié-Gonnard
19d6d3421c Rationalize keyUsage testing, round 2
- cli-auth 1.2 was missing a test with an irrelevant bit set in addition
to the relevant bit (which was added for 1.3 previously)
- use consistent naming for fail (hard/soft)

Note: currently there are no "fail (soft)" cases for 1.3 authentication
of server by client, as server auth is mandatory in 1.3 (this will
change in 3.6.1).

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-16 17:24:16 +01:00
Manuel Pégourié-Gonnard
92a391e0fe Always print detailed cert errors in test programs
Previously the client was only printing them on handshake success, and
the server was printing them on success and some but not all failures.

This makes ssl-opt.sh more consistent as we can always check for the
presence of the expected message in the output, regardless of whether
the failure is hard or soft.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-16 17:24:05 +01:00
Manuel Pégourié-Gonnard
4956e32538 Fix 1.3 failure to update flags for (ext)KeyUsage
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-16 17:23:47 +01:00
Manuel Pégourié-Gonnard
5a4c8f0ba0 Rationalize ssl-opt tests for keyUsage
- consistent naming with explicit version
- in each section, have a positive case with just the needed bit set,
and one with an irrelevant bit set in addition (cli 1.3 only had the
former, and cli-auth 1.3 only the later)
- when auth_mode optional is supported failing cases should come in
pairs: soft+hard, this wasn't the case for cli-auth 1.3. (Note: cli 1.3
currently does not support auth_mode optional.)
- failing cases should check that the correct flag is printed and the
expected alert is sent.

The last (two) points have uncovered a bug in 1.3 code:
- In fail (hard) cases the correct alert isn't send, but a more generic
one instead.
- In fail (soft) cases the issue with the certificate is not reported,
actually the certificate is reported as valid.

Both share the same root cause: the flags are not updated properly when
checking the keyUsage extension. This will be addressed in future
commits.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-16 17:23:40 +01:00
Manuel Pégourié-Gonnard
8e70c2bcd9 Test cert alert KEY_USAGE -> UNSUPPORTED_CERT
In terms of line coverage, this was covered, except we never checked the
behaviour was as intended.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-16 17:23:31 +01:00
Gilles Peskine
7ab9867fa7
Merge pull request #9290 from sezrab/replace_MBEDTLS_MD_CAN_MD5_with_PSA_WANT
Add MD5 support for `requires_hash_alg`
2024-07-18 09:41:17 +00:00
Waleed Elmelegy
835483335e Remove redundant legacy compression test
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-07-16 10:32:03 +00:00
Waleed Elmelegy
dc99c890a6 Improve legacy compression regression testing
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-07-15 17:25:04 +00:00
Wenxing Hou
b4d03cc179 Fix some typo for include folder
Signed-off-by: Wenxing Hou <wenxing.hou@intel.com>
2024-07-12 15:16:33 +08:00
David Horstmann
184c4f09b9 Use variable for data_files path in ssl-opt.sh
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-07-05 15:49:28 +01:00
David Horstmann
dcf18dd876 Update paths pointing to tests/data_files
These now point to framework/data_files instead.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-07-05 15:49:03 +01:00
Waleed Elmelegy
0b190f1763 Add regression testing to handling Legacy_compression_methods
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-07-04 16:38:04 +00:00
Sam Berry
8121879b3a Reverted requires_cipher_enabled AES
Signed-off-by: Sam Berry <sam.berry@arm.com>
2024-06-26 13:53:47 +01:00
Sam Berry
bd743eb5a0 Changed some tests to use requires_cipher_enabled
I expect some will still skip due to `MBEDTLS_CIPHER_MODE_CBC` being unset.

Signed-off-by: Sam Berry <sam.berry@arm.com>
2024-06-21 11:52:37 +01:00
Sam Berry
d50e843ba7 Added support for MD5 in requires_hash_alg
Signed-off-by: Sam Berry <sam.berry@arm.com>
2024-06-20 10:09:23 +01:00
Gilles Peskine
39c5207d79 ssl-opt.sh, compat.sh: Error out if not executing any tests
Alert if all tests are filtered out or skipped: that probably indicates a
test script that set up an unintended configuration or an overly strict
filter. You can pass `--min 0` to bypass this check. You can pass `--min`
with a larger value to require that many test cases to run.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-23 13:38:26 +02:00
Gilles Peskine
fc73aa02b0 Add missing dependency that isn't autodetected
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-13 21:18:41 +02:00