31434 Commits

Author SHA1 Message Date
Gilles Peskine
4daaafebe0 Fix sensitivity of tls13-compat.sh to the exact generation method
Fix `tls13-compat.sh` changing based on exactly how
`generate_tls13_compat_tests.py` was run (e.g. from which directory). This
made `check-generated-files.sh` behave differently from `make`. The script
has no official variations of the content of its output file, so we don't
need to record the full command line.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-20 07:44:36 +02:00
Gilles Peskine
0e9ba089b9 Automatically generate tests/opt-testcases/tls13-compat.sh
`tests/opt-testcases/tls13-compat.sh` is supposed to be automatically
generated by `tests/scripts/generate_tls13_compat_tests.py`. So far, the
output has been updated by running the script manually and committing the
output. Switch to using our framework for generated files.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-20 07:44:36 +02:00
Gilles Peskine
dfede5a5b4 generate_tls13_compat_tests: change default mode to all
With no options, update the output file (former behavior with -a).
Pass -1 to generate a single test case.

Also have the intended output file location as the default.

This way, you can just run the script after updating it, without having to
know the details of the directory structure.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-20 07:44:36 +02:00
Gilles Peskine
0fadf43410 Remove obsolete requirements on middlebox compatibility mode: generated
MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE is no longer required, except in test
cases that are specifically about it. This commit removes the requirement in
tls13-compat.sh (which does not have test cases that actually depend on the
feature).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-20 07:44:36 +02:00
Gilles Peskine
578bfeeb0d 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-20 07:41:47 +02:00
Gilles Peskine
669728a2e8 Remove mid-stanza blank lines
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-20 07:40:02 +02:00
Gilles Peskine
fc3accdde6 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-20 07:40:02 +02:00
Gilles Peskine
78df03aaa5 Separate accepting TLS 1.3 middlebox compatibility from sending it
The compile-time option MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE gates both
support for interoperability with a peer that uses middlebox compatibility
mode, and support for activating that mode ourselves. Change code that is
only needed for interoperability to be guarded by
MBEDTLS_SSL_TLS1_3_ACCEPT_COMPATIBILITY_MODE.

As of this commit, MBEDTLS_SSL_TLS1_3_ACCEPT_COMPATIBILITY_MODE is always
enabled: there is no way to disable it, and there are no tests with it
disabled.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-20 07:40:02 +02:00
Gilles Peskine
365296aace 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-20 07:31:43 +02:00
Gilles Peskine
fde24b85ae Remove test-ref-configs.pl, which no longer does anything
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:57:18 +02:00
Gilles Peskine
ced0edc43e Move config-tfm.h testing to separate all.sh component
Rename the existing component_test_tfm_config which tests a modified version
of config-tfm.h for the sake of driver-vs-reference comparison.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:57:11 +02:00
Gilles Peskine
dbd0f424b0 Move config-symmetric-only.h testing to separate all.sh components
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:57:03 +02:00
Gilles Peskine
e62925f1e6 Move config-thread.h testing to separate all.sh components
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:56:01 +02:00
Gilles Peskine
e9cd6a7011 Move config-suite-b.h testing to separate all.sh components
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:55:53 +02:00
Gilles Peskine
9929237537 Move config-ccm-psk-dtls1_2.h testing to separate all.sh components
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:55:49 +02:00
Gilles Peskine
f3d5019191 Move config-ccm-psk-tls1_2.h testing to separate all.sh components
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:55:44 +02:00
Gilles Peskine
4d347aa433 Move config-no-entropy.h testing to separate all.sh component
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:55:08 +02:00
Gilles Peskine
b35ed4565a make: support "make ssl-opt" to just build what ssl-opt.sh needs
This also suffices for compat.sh.

Include the sample programs in this build. They aren't tested by ssl-opt.sh
yet, but they soon will be.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:47:04 +02:00
Gilles Peskine
7215b1e9c9 CMake: support "make ssl-opt" to just build what ssl-opt.sh needs
This also suffices for compat.sh.

Include the sample programs in this build. They aren't tested by ssl-opt.sh
yet, but they soon will be.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:46:58 +02:00
Gilles Peskine
bb47c7368b CMake: support "make programs"
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:46:52 +02:00
David Horstmann
04176756d8
Merge pull request #9568 from eleuzi01/issue-9473
Backport 3.6: Fix incorrect dependencies
2024-09-19 13:53:21 +00:00
Gilles Peskine
3415dc828e Fix obsolete comment about MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER has been compatible with
MBEDTLS_USE_PSA_CRYPTO since https://github.com/Mbed-TLS/mbedtls/pull/5380.
We still don't want to enable it in the full config because it's a behavior
change, even an interface change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 13:45:39 +02:00
Gabor Mezei
bf1c8f9d29
Update framework
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2024-09-19 13:01:06 +02:00
Gabor Mezei
76f147d597
Remove unused CombinedConfig class
In 3.6 `MbedTLSConfig` is used instead of `ConbinedConfig` due to keep compatibility

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2024-09-19 13:01:06 +02:00
Gabor Mezei
6f90e79ae5
Update old class names
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2024-09-19 10:51:59 +02:00
Gabor Mezei
1a0bd776b2
Use MbedTLSConfig for config handling to keep campatibility
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2024-09-19 10:51:59 +02:00
Gabor Mezei
8b54f0e7e8
Apply the parameter change
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2024-09-19 10:51:59 +02:00
Gabor Mezei
d72c9f9401
Fix documentation
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2024-09-19 10:51:59 +02:00
Gabor Mezei
2285ed8282
Update member variable names
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2024-09-19 10:51:59 +02:00
Gabor Mezei
3ae480ba7d
Fix documentation
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2024-09-19 10:51:58 +02:00
Gabor Mezei
634103c9f9
Update config.py to use config_common.py from the framework
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2024-09-19 10:51:58 +02:00
Gilles Peskine
83af88306d Document the C compiler requirement
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-18 14:17:14 +02:00
Gilles Peskine
605bc16e67 Make the file a bit more readable
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-18 14:17:13 +02:00
Elena Uziunaite
6a229f926e Remove some dependencies
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-17 16:06:18 +01:00
Elena Uziunaite
db0ed75c0f Add PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-17 15:45:19 +01:00
Elena Uziunaite
47a9b3d5a5 Replace MBEDTLS_PK_CAN_ECDSA_SOME with MBEDTLS_PK_CAN_ECDSA_SIGN
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-16 14:25:38 +01:00
Elena Uziunaite
fbab4f88dc Add missing ALG_SHA_1
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-09-16 12:34:11 +01:00
Gilles Peskine
ab84fe8052 opt-testcases/*.sh are not executable
The *.sh files in opt-testcases cannot be executed directly: they can only
be sourced by ssl-opt.sh. So don't make them executable and don't give them
a shebang line.

Also make sure that the first paragraph of each file is a short description.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 16:30:57 +02:00
Gilles Peskine
26fc0390c9
Merge pull request #9498 from minosgalanakis/bugfix/return_early_in_ccm_star_bp36
[Backport 3.6] ccm.c: Return early when ccm* is used without tag.
2024-09-13 09:35:12 +00:00
Gilles Peskine
78b1362b42
Merge pull request #9546 from gilles-peskine-arm/ssl-opt-psk-detection-3.6
[3.6] ssl-opt: improve PSK mode detection
2024-09-13 09:35:07 +00:00
Gilles Peskine
cfbaffdfcc 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:49:04 +02:00
Gilles Peskine
d57212ee9e Documentation improvements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:49:04 +02:00
Gilles Peskine
19c60d262b Fix detection of TLS 1.2 PSK-ephemeral key exchange modes
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:49:04 +02:00
Gilles Peskine
5838a64bff Improve some comments
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:49:04 +02:00
Gilles Peskine
4c1347c1e8 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:49:04 +02:00
Gilles Peskine
07e24e9ac3 Fix weirdly quoted invocations of requires_any_configs_enabled
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:49:04 +02:00
Gilles Peskine
d98b363bec 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:49:04 +02:00
Gilles Peskine
0a9f9d6f4f 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:49:04 +02:00
Gilles Peskine
bbdc1a3575 Detect PSK-only mode in TLS 1.3 as well
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-13 09:49:04 +02:00
Gilles Peskine
5c766dcb01 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:49:04 +02:00